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

Unified Diff: lib/child/requestNotifier.js

Issue 29333172: Issue 3259 - Store blockable items selection in the content process (Closed)
Patch Set: Created Jan. 4, 2016, 8:08 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
Index: lib/child/requestNotifier.js
===================================================================
--- a/lib/child/requestNotifier.js
+++ b/lib/child/requestNotifier.js
@@ -20,38 +20,43 @@
*/
let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
let {Utils} = require("utils");
let {Flasher} = require("child/flasher");
let nodeData = new WeakMap();
let windowStats = new WeakMap();
+let windowData = new WeakMap();
let requestEntryMaxId = 0;
/**
* Active RequestNotifier instances by their ID
* @type Map.<number,RequestNotifier>
*/
let notifiers = new Map();
addMessageListener("AdblockPlus:StartWindowScan", onStartScan);
addMessageListener("AdblockPlus:ShutdownNotifier", onNotifierShutdown);
addMessageListener("AdblockPlus:FlashNodes", onFlashNodes);
addMessageListener("AdblockPlus:RetrieveNodeSize", onRetrieveNodeSize);
addMessageListener("AdblockPlus:StoreNodesForEntries", onStoreNodes);
addMessageListener("AdblockPlus:RetrieveWindowStats", onRetrieveWindowStats);
+addMessageListener("AdblockPlus:StoreWindowData", onStoreWindowData);
+addMessageListener("AdblockPlus:RetrieveWindowData", onRetrieveWindowData);
onShutdown.add(() => {
removeMessageListener("AdblockPlus:StartWindowScan", onStartScan);
removeMessageListener("AdblockPlus:ShutdownNotifier", onNotifierShutdown);
removeMessageListener("AdblockPlus:FlashNodes", onFlashNodes);
removeMessageListener("AdblockPlus:RetrieveNodeSize", onRetrieveNodeSize);
removeMessageListener("AdblockPlus:StoreNodesForEntries", onStoreNodes);
removeMessageListener("AdblockPlus:RetrieveWindowStats", onRetrieveWindowStats);
+ removeMessageListener("AdblockPlus:StoreWindowData", onStoreWindowData);
+ removeMessageListener("AdblockPlus:RetrieveWindowData", onRetrieveWindowData);
});
function onStartScan(message)
{
let {notifierID, outerWindowID} = message.data;
let window = Services.wm.getOuterWindowWithId(outerWindowID);
if (window)
new RequestNotifier(window, notifierID);
@@ -97,16 +102,38 @@ function onRetrieveWindowStats(message)
let stats = RequestNotifier.getWindowStatistics(window);
sendAsyncMessage("AdblockPlus:RetrieveWindowStatsResponse", {
responseID,
stats
});
}
}
+function onStoreWindowData(message)
+{
+ let {outerWindowID, data} = message.data;
+ let window = Services.wm.getOuterWindowWithId(outerWindowID);
+ if (window)
+ windowData.set(window.document, data);
+};
+
+function onRetrieveWindowData(message)
+{
+ let {responseID, outerWindowID} = message.data;
+ let window = Services.wm.getOuterWindowWithId(outerWindowID);
+ if (window)
+ {
+ let data = windowData.get(window.document) || null;
+ sendAsyncMessage("AdblockPlus:RetrieveWindowDataResponse", {
+ responseID,
+ data
+ });
+ }
+};
+
/**
* Creates a notifier object for a particular window. After creation the window
* will first be scanned for previously saved requests. Once that scan is
* complete only new requests for this window will be reported.
* @param {Window} window window to attach the notifier to
* @param {Integer} notifierID Parent notifier ID to be messaged
*/
function RequestNotifier(window, notifierID)
« no previous file with comments | « chrome/content/ui/sidebar.js ('k') | lib/requestNotifier.js » ('j') | lib/requestNotifier.js » ('J')

Powered by Google App Engine
This is Rietveld