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

Delta Between Two Patch Sets: lib/child/requestNotifier.js

Issue 29329884: Issue 3224 - Unbreak filter assistant (Closed)
Left Patch Set: Created Nov. 9, 2015, 1:45 p.m.
Right Patch Set: Rebased Created Nov. 12, 2015, 3:10 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 responseID, 99 responseID,
100 stats 100 stats
101 }); 101 });
102 } 102 }
103 } 103 }
104 104
105 /** 105 /**
106 * Creates a notifier object for a particular window. After creation the window 106 * Creates a notifier object for a particular window. After creation the window
107 * will first be scanned for previously saved requests. Once that scan is 107 * will first be scanned for previously saved requests. Once that scan is
108 * complete only new requests for this window will be reported. 108 * complete only new requests for this window will be reported.
109 * @param {Window} wnd window to attach the notifier to 109 * @param {Window} window window to attach the notifier to
110 * @param {Integer} id Parent notifier ID to be messaged 110 * @param {Integer} notifierID Parent notifier ID to be messaged
111 */ 111 */
112 function RequestNotifier(window, notifierID) 112 function RequestNotifier(window, notifierID)
113 { 113 {
114 this.window = window; 114 this.window = window;
115 this.id = notifierID; 115 this.id = notifierID;
116 notifiers.set(this.id, this); 116 notifiers.set(this.id, this);
117 this.nodes = new Map(); 117 this.nodes = new Map();
118 this.startScan(window); 118 this.startScan(window);
119 } 119 }
120 exports.RequestNotifier = RequestNotifier; 120 exports.RequestNotifier = RequestNotifier;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 * Starts the initial scan of the window (will recurse into frames). 181 * Starts the initial scan of the window (will recurse into frames).
182 * @param {Window} wnd the window to be scanned 182 * @param {Window} wnd the window to be scanned
183 */ 183 */
184 startScan: function(wnd) 184 startScan: function(wnd)
185 { 185 {
186 let doc = wnd.document; 186 let doc = wnd.document;
187 let walker = doc.createTreeWalker(doc, Ci.nsIDOMNodeFilter.SHOW_ELEMENT, nul l, false); 187 let walker = doc.createTreeWalker(doc, Ci.nsIDOMNodeFilter.SHOW_ELEMENT, nul l, false);
188 188
189 let process = function() 189 let process = function()
190 { 190 {
191 // Don't do anything if the notifier was shut down already.
191 if (!this.window) 192 if (!this.window)
192 return; 193 return;
193 194
194 let node = walker.currentNode; 195 let node = walker.currentNode;
195 let data = nodeData.get(node); 196 let data = nodeData.get(node);
196 if (typeof data != "undefined") 197 if (typeof data != "undefined")
197 for (let k in data) 198 for (let k in data)
198 this.notifyListener(node, data[k]); 199 this.notifyListener(node, data[k]);
199 200
200 if (walker.nextNode()) 201 if (walker.nextNode())
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 responseID, 328 responseID,
328 response: id 329 response: id
329 }); 330 });
330 } 331 }
331 }; 332 };
332 333
333 /** 334 /**
334 * Attaches request data to a DOM node. 335 * Attaches request data to a DOM node.
335 * @param {Node} node node to attach data to 336 * @param {Node} node node to attach data to
336 * @param {Window} topWnd top-level window the node belongs to 337 * @param {Window} topWnd top-level window the node belongs to
337 * @param {String} contentType request type, e.g. "IMAGE" 338 * @param {Object} hitData
338 * @param {String} docDomain domain of the document that initiated the request 339 * @param {String} hitData.contentType request type, e.g. "IMAGE"
339 * @param {Boolean} thirdParty will be true if a third-party server has been re quested 340 * @param {String} hitData.docDomain domain of the document that initiated the request
340 * @param {String} location the address that has been requested 341 * @param {Boolean} hitData.thirdParty will be true if a third-party server has been requested
341 * @param {String} filter filter applied to the request or null if none 342 * @param {String} hitData.location the address that has been requested
342 * @param {String} filterType type of filter applied to the request 343 * @param {String} hitData.filter filter applied to the request or null if non e
344 * @param {String} hitData.filterType type of filter applied to the request
343 */ 345 */
344 RequestNotifier.addNodeData = function(node, topWnd, {contentType, docDomain, th irdParty, location, filter, filterType}) 346 RequestNotifier.addNodeData = function(node, topWnd, {contentType, docDomain, th irdParty, location, filter, filterType})
345 { 347 {
346 let entry = { 348 let entry = {
347 id: ++requestEntryMaxId, 349 id: ++requestEntryMaxId,
348 type: contentType, 350 type: contentType,
349 docDomain, thirdParty, location, filter 351 docDomain, thirdParty, location, filter
350 }; 352 };
351 353
352 let existingData = nodeData.get(node); 354 let existingData = nodeData.get(node);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 node = node.parentNode; 447 node = node.parentNode;
446 } 448 }
447 else 449 else
448 { 450 {
449 node = null; 451 node = null;
450 } 452 }
451 } 453 }
452 454
453 return null; 455 return null;
454 }; 456 };
LEFTRIGHT

Powered by Google App Engine
This is Rietveld