Index: lib/requestNotifier.js |
=================================================================== |
--- a/lib/requestNotifier.js |
+++ b/lib/requestNotifier.js |
@@ -14,47 +14,44 @@ |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
/** |
* @fileOverview Stores Adblock Plus data to be attached to a window. |
*/ |
+let {Utils} = require("utils"); |
+ |
let windowSelection = new WeakMap(); |
let requestNotifierMaxId = 0; |
/** |
* Active RequestNotifier instances by their ID |
* @type Map.<number,RequestNotifier> |
*/ |
let notifiers = new Map(); |
let messageManager = Cc["@mozilla.org/parentprocessmessagemanager;1"] |
.getService(Ci.nsIMessageListenerManager) |
.QueryInterface(Ci.nsIMessageBroadcaster); |
-messageManager.addMessageListener("AdblockPlus:FoundNodeData", onNodeData); |
-messageManager.addMessageListener("AdblockPlus:ScanComplete", onScanComplete); |
-onShutdown.add(() => { |
- messageManager.removeMessageListener("AdblockPlus:FoundNodeData", onNodeData); |
- messageManager.removeMessageListener("AdblockPlus:ScanComplete", onScanComplete); |
-}); |
+Utils.addChildMessageListener("AdblockPlus:FoundNodeData", onNodeData); |
+Utils.addChildMessageListener("AdblockPlus:ScanComplete", onScanComplete); |
-function onNodeData(message) |
+function onNodeData({notifierID, data}) |
{ |
- let {notifierID, data} = message.data; |
let notifier = notifiers.get(notifierID); |
if (notifier) |
notifier.notifyListener(data); |
} |
-function onScanComplete(message) |
+function onScanComplete(notifierID) |
{ |
- let notifier = notifiers.get(message.data); |
+ let notifier = notifiers.get(notifierID); |
if (notifier) |
notifier.onComplete(); |
} |
/** |
* 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. |