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

Unified Diff: lib/requestNotifier.js

Issue 9241058: Bug 819131 work-around, use user data instead of weak maps (Closed)
Patch Set: Created Jan. 23, 2013, 2:47 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/requestNotifier.js
===================================================================
--- a/lib/requestNotifier.js
+++ b/lib/requestNotifier.js
@@ -24,44 +24,45 @@ Cu.import("resource://gre/modules/Servic
let {Utils} = require("utils");
let {BlockingFilter, WhitelistFilter, ElemHideBase, ElemHideFilter, ElemHideException} = require("filterClasses");
let nodeData = new WeakMap();
let windowStats = new WeakMap();
let windowSelection = new WeakMap();
let setEntry, hasEntry, getEntry;
-if (Services.vc.compare(Utils.platformVersion, "13.0") >= 0)
+if (false)
{
- // Bug 673468 is fixed, we can use weak maps
+ // This branch can be enabled again once both bug 673468 and bug 819131 are
+ // fixed and we can use weak maps
setEntry = function(map, key, value) map.set(key, value);
hasEntry = function(map, key) map.has(key);
getEntry = function(map, key) map.get(key);
}
else
{
// Fall back to user data
let dataSeed = Math.random();
let nodeDataProp = "abpNodeData" + dataSeed;
let windowStatsProp = "abpWindowStats" + dataSeed;
let windowSelectionProp = "abpWindowSelection" + dataSeed;
- function getProp(map)
+ let getProp = function(map)
Wladimir Palant 2013/01/23 14:48:33 Please ignore this change, it's from a different c
{
switch (map)
{
case nodeData:
return nodeDataProp;
case windowStats:
return windowStatsProp;
case windowSelection:
return windowSelectionProp;
default:
return null;
}
- }
+ };
setEntry = function(map, key, value) key.setUserData(getProp(map), value, null);
hasEntry = function(map, key) key.getUserData(getProp(map));
getEntry = function(map, key) key.getUserData(getProp(map)) || undefined;
}
/**
* List of notifiers in use - these notifiers need to receive notifications on
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld