OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 10 matching lines...) Expand all Loading... |
21 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); | 21 let {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); |
22 | 22 |
23 let {Utils} = require("utils"); | 23 let {Utils} = require("utils"); |
24 | 24 |
25 let nodeData = new WeakMap(); | 25 let nodeData = new WeakMap(); |
26 let windowStats = new WeakMap(); | 26 let windowStats = new WeakMap(); |
27 let requestEntryMaxId = 0; | 27 let requestEntryMaxId = 0; |
28 | 28 |
29 /** | 29 /** |
30 * Active RequestNotifier instances by their ID | 30 * Active RequestNotifier instances by their ID |
31 * @type Map | 31 * @type Map.<number,RequestNotifier> |
32 */ | 32 */ |
33 let notifiers = new Map(); | 33 let notifiers = new Map(); |
34 | 34 |
35 addMessageListener("AdblockPlus:StartWindowScan", onStartScan); | 35 addMessageListener("AdblockPlus:StartWindowScan", onStartScan); |
36 addMessageListener("AdblockPlus:ShutdownNotifier", onNotifierShutdown); | 36 addMessageListener("AdblockPlus:ShutdownNotifier", onNotifierShutdown); |
37 | 37 |
38 onShutdown.add(() => { | 38 onShutdown.add(() => { |
39 removeMessageListener("AdblockPlus:StartWindowScan", onStartScan); | 39 removeMessageListener("AdblockPlus:StartWindowScan", onStartScan); |
40 removeMessageListener("AdblockPlus:ShutdownNotifier", onNotifierShutdown); | 40 removeMessageListener("AdblockPlus:ShutdownNotifier", onNotifierShutdown); |
41 }); | 41 }); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 /** | 164 /** |
165 * Attaches request data to a DOM node. | 165 * Attaches request data to a DOM node. |
166 * @param {Node} node node to attach data to | 166 * @param {Node} node node to attach data to |
167 * @param {Window} topWnd top-level window the node belongs to | 167 * @param {Window} topWnd top-level window the node belongs to |
168 * @param {String} contentType request type, e.g. "IMAGE" | 168 * @param {String} contentType request type, e.g. "IMAGE" |
169 * @param {String} docDomain domain of the document that initiated the request | 169 * @param {String} docDomain domain of the document that initiated the request |
170 * @param {Boolean} thirdParty will be true if a third-party server has been re
quested | 170 * @param {Boolean} thirdParty will be true if a third-party server has been re
quested |
171 * @param {String} location the address that has been requested | 171 * @param {String} location the address that has been requested |
172 * @param {Filter} filter filter applied to the request or null if none | 172 * @param {Filter} filter filter applied to the request or null if none |
173 */ | 173 */ |
174 RequestNotifier.addNodeData = function(/**Node*/ node, /**Window*/ topWnd, /**St
ring*/ contentType, /**String*/ docDomain, /**Boolean*/ thirdParty, /**String*/
location, /**Filter*/ filter) | 174 RequestNotifier.addNodeData = function(node, topWnd, contentType, docDomain, thi
rdParty, location, filter) |
175 { | 175 { |
176 let entry = { | 176 let entry = { |
177 id: ++requestEntryMaxId, | 177 id: ++requestEntryMaxId, |
178 type: contentType, | 178 type: contentType, |
179 docDomain, thirdParty, location, filter | 179 docDomain, thirdParty, location, filter |
180 }; | 180 }; |
181 | 181 |
182 let existingData = nodeData.get(node); | 182 let existingData = nodeData.get(node); |
183 if (typeof existingData == "undefined") | 183 if (typeof existingData == "undefined") |
184 { | 184 { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 stats.filters[filter.text]++; | 218 stats.filters[filter.text]++; |
219 else | 219 else |
220 stats.filters[filter.text] = 1; | 220 stats.filters[filter.text] = 1; |
221 } | 221 } |
222 | 222 |
223 // Notify listeners | 223 // Notify listeners |
224 for (let notifier of notifiers.values()) | 224 for (let notifier of notifiers.values()) |
225 if (!notifier.window || notifier.window == topWnd) | 225 if (!notifier.window || notifier.window == topWnd) |
226 notifier.notifyListener(entry); | 226 notifier.notifyListener(entry); |
227 } | 227 } |
OLD | NEW |