| 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) |