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

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

Issue 29329654: Issue 3222 - Split up requestNotifier module into a parent and child part (Closed)
Left Patch Set: Created Nov. 2, 2015, 7:48 p.m.
Right Patch Set: Improved comments Created Nov. 12, 2015, 12:40 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
« no previous file with change/comment | « lib/child/contentPolicy.js ('k') | lib/requestNotifier.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 { 52 {
53 let notifier = notifiers.get(message.data); 53 let notifier = notifiers.get(message.data);
54 if (notifier) 54 if (notifier)
55 notifier.shutdown(); 55 notifier.shutdown();
56 } 56 }
57 57
58 /** 58 /**
59 * Creates a notifier object for a particular window. After creation the window 59 * Creates a notifier object for a particular window. After creation the window
60 * will first be scanned for previously saved requests. Once that scan is 60 * will first be scanned for previously saved requests. Once that scan is
61 * complete only new requests for this window will be reported. 61 * complete only new requests for this window will be reported.
62 * @param {Window} wnd window to attach the notifier to 62 * @param {Window} window window to attach the notifier to
63 * @param {Integer} id Parent notifier ID to be messaged 63 * @param {Integer} notifierID Parent notifier ID to be messaged
64 */ 64 */
65 function RequestNotifier(window, notifierID) 65 function RequestNotifier(window, notifierID)
66 { 66 {
67 this.window = window; 67 this.window = window;
68 this.id = notifierID; 68 this.id = notifierID;
69 notifiers.set(this.id, this); 69 notifiers.set(this.id, this);
70 this.startScan(window); 70 this.startScan(window);
71 } 71 }
72 exports.RequestNotifier = RequestNotifier; 72 exports.RequestNotifier = RequestNotifier;
73 73
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 * Starts the initial scan of the window (will recurse into frames). 122 * Starts the initial scan of the window (will recurse into frames).
123 * @param {Window} wnd the window to be scanned 123 * @param {Window} wnd the window to be scanned
124 */ 124 */
125 startScan: function(wnd) 125 startScan: function(wnd)
126 { 126 {
127 let doc = wnd.document; 127 let doc = wnd.document;
128 let walker = doc.createTreeWalker(doc, Ci.nsIDOMNodeFilter.SHOW_ELEMENT, nul l, false); 128 let walker = doc.createTreeWalker(doc, Ci.nsIDOMNodeFilter.SHOW_ELEMENT, nul l, false);
129 129
130 let process = function() 130 let process = function()
131 { 131 {
132 // Don't do anything if the notifier was shut down already.
132 if (!this.window) 133 if (!this.window)
133 return; 134 return;
134 135
135 let node = walker.currentNode; 136 let node = walker.currentNode;
136 let data = nodeData.get(node); 137 let data = nodeData.get(node);
137 if (typeof data != "undefined") 138 if (typeof data != "undefined")
138 for (let k in data) 139 for (let k in data)
139 this.notifyListener(data[k]); 140 this.notifyListener(data[k]);
140 141
141 if (walker.nextNode()) 142 if (walker.nextNode())
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 stats.filters[filter.text]++; 219 stats.filters[filter.text]++;
219 else 220 else
220 stats.filters[filter.text] = 1; 221 stats.filters[filter.text] = 1;
221 } 222 }
222 223
223 // Notify listeners 224 // Notify listeners
224 for (let notifier of notifiers.values()) 225 for (let notifier of notifiers.values())
225 if (!notifier.window || notifier.window == topWnd) 226 if (!notifier.window || notifier.window == topWnd)
226 notifier.notifyListener(entry); 227 notifier.notifyListener(entry);
227 } 228 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld