Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: lib/requestNotifier.js

Issue 5121479175831552: issue 47 - use WeakMap instead of setUserData and getUserData methods (Closed)
Patch Set: Created May 18, 2014, 12:48 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 11 matching lines...) Expand all
22 Cu.import("resource://gre/modules/Services.jsm"); 22 Cu.import("resource://gre/modules/Services.jsm");
23 23
24 let {Utils} = require("utils"); 24 let {Utils} = require("utils");
25 let {BlockingFilter, WhitelistFilter, ElemHideBase, ElemHideFilter, ElemHideExce ption} = require("filterClasses"); 25 let {BlockingFilter, WhitelistFilter, ElemHideBase, ElemHideFilter, ElemHideExce ption} = require("filterClasses");
26 26
27 let nodeData = new WeakMap(); 27 let nodeData = new WeakMap();
28 let windowStats = new WeakMap(); 28 let windowStats = new WeakMap();
29 let windowSelection = new WeakMap(); 29 let windowSelection = new WeakMap();
30 30
31 let setEntry, hasEntry, getEntry; 31 let setEntry, hasEntry, getEntry;
32 if (false) 32 // Last issue(Bug 982561) preventing us from using WeakMap fixed for FF version 32
33 if (Services.vc.compare(Utils.platformVersion, "32.0a1") >= 0)
33 { 34 {
34 // This branch can be enabled again once all of bug 673468, bug 819131 and
35 // bug 982561 are fixed and we can use weak maps.
36 setEntry = function(map, key, value) map.set(key, value); 35 setEntry = function(map, key, value) map.set(key, value);
37 hasEntry = function(map, key) map.has(key); 36 hasEntry = function(map, key) map.has(key);
38 getEntry = function(map, key) map.get(key); 37 getEntry = function(map, key) map.get(key);
39 } 38 }
40 else 39 else
41 { 40 {
42 // Fall back to user data 41 // Fall back to user data
43 let dataSeed = Math.random(); 42 let dataSeed = Math.random();
44 let nodeDataProp = "abpNodeData" + dataSeed; 43 let nodeDataProp = "abpNodeData" + dataSeed;
45 let windowStatsProp = "abpWindowStats" + dataSeed; 44 let windowStatsProp = "abpWindowStats" + dataSeed;
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 if (typeof existingData == "undefined") 363 if (typeof existingData == "undefined")
365 { 364 {
366 existingData = {}; 365 existingData = {};
367 setEntry(nodeData, node, existingData); 366 setEntry(nodeData, node, existingData);
368 } 367 }
369 368
370 // Add this request to the node data 369 // Add this request to the node data
371 existingData[this.type + " " + this.location] = this; 370 existingData[this.type + " " + this.location] = this;
372 } 371 }
373 }; 372 };
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld