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

Side by Side Diff: lib/child/requestNotifier.js

Issue 29329815: Issue 3274 - Unbreak toolbar icon tooltip (Closed)
Patch Set: Created Nov. 6, 2015, 12:36 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/requestNotifier.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 19 matching lines...) Expand all
30 /** 30 /**
31 * Active RequestNotifier instances by their ID 31 * Active RequestNotifier instances by their ID
32 * @type Map.<number,RequestNotifier> 32 * @type Map.<number,RequestNotifier>
33 */ 33 */
34 let notifiers = new Map(); 34 let notifiers = new Map();
35 35
36 addMessageListener("AdblockPlus:StartWindowScan", onStartScan); 36 addMessageListener("AdblockPlus:StartWindowScan", onStartScan);
37 addMessageListener("AdblockPlus:ShutdownNotifier", onNotifierShutdown); 37 addMessageListener("AdblockPlus:ShutdownNotifier", onNotifierShutdown);
38 addMessageListener("AdblockPlus:FlashNodes", onFlashNodes); 38 addMessageListener("AdblockPlus:FlashNodes", onFlashNodes);
39 addMessageListener("AdblockPlus:RetrieveNodeSize", onRetrieveNodeSize); 39 addMessageListener("AdblockPlus:RetrieveNodeSize", onRetrieveNodeSize);
40 addMessageListener("AdblockPlus:RetrieveWindowStats", onRetrieveWindowStats);
40 41
41 onShutdown.add(() => { 42 onShutdown.add(() => {
42 removeMessageListener("AdblockPlus:StartWindowScan", onStartScan); 43 removeMessageListener("AdblockPlus:StartWindowScan", onStartScan);
43 removeMessageListener("AdblockPlus:ShutdownNotifier", onNotifierShutdown); 44 removeMessageListener("AdblockPlus:ShutdownNotifier", onNotifierShutdown);
44 removeMessageListener("AdblockPlus:FlashNodes", onFlashNodes); 45 removeMessageListener("AdblockPlus:FlashNodes", onFlashNodes);
45 removeMessageListener("AdblockPlus:RetrieveNodeSize", onRetrieveNodeSize); 46 removeMessageListener("AdblockPlus:RetrieveNodeSize", onRetrieveNodeSize);
47 removeMessageListener("AdblockPlus:RetrieveWindowStats", onRetrieveWindowStats );
46 }); 48 });
47 49
48 function onStartScan(message) 50 function onStartScan(message)
49 { 51 {
50 let {notifierID, outerWindowID} = message.data; 52 let {notifierID, outerWindowID} = message.data;
51 let window = Services.wm.getOuterWindowWithId(outerWindowID); 53 let window = Services.wm.getOuterWindowWithId(outerWindowID);
52 if (window) 54 if (window)
53 new RequestNotifier(window, notifierID); 55 new RequestNotifier(window, notifierID);
54 } 56 }
55 57
(...skipping 13 matching lines...) Expand all
69 } 71 }
70 72
71 function onRetrieveNodeSize(message) 73 function onRetrieveNodeSize(message)
72 { 74 {
73 let {notifierID, responseID, requests} = message.data; 75 let {notifierID, responseID, requests} = message.data;
74 let notifier = notifiers.get(notifierID); 76 let notifier = notifiers.get(notifierID);
75 if (notifier) 77 if (notifier)
76 notifier.retrieveNodeSize(requests, responseID); 78 notifier.retrieveNodeSize(requests, responseID);
77 } 79 }
78 80
81 function onRetrieveWindowStats(message)
82 {
83 let {responseID, outerWindowID} = message.data;
84 let window = Services.wm.getOuterWindowWithId(outerWindowID);
85 if (window)
86 {
87 let stats = RequestNotifier.getWindowStatistics(window);
88 sendAsyncMessage("AdblockPlus:RetrieveWindowStatsResponse", {
89 responseID,
90 stats
91 });
92 }
93 }
94
79 /** 95 /**
80 * Creates a notifier object for a particular window. After creation the window 96 * Creates a notifier object for a particular window. After creation the window
81 * will first be scanned for previously saved requests. Once that scan is 97 * will first be scanned for previously saved requests. Once that scan is
82 * complete only new requests for this window will be reported. 98 * complete only new requests for this window will be reported.
83 * @param {Window} wnd window to attach the notifier to 99 * @param {Window} wnd window to attach the notifier to
84 * @param {Integer} id Parent notifier ID to be messaged 100 * @param {Integer} id Parent notifier ID to be messaged
85 */ 101 */
86 function RequestNotifier(window, notifierID) 102 function RequestNotifier(window, notifierID)
87 { 103 {
88 this.window = window; 104 this.window = window;
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 stats.filters[filter]++; 345 stats.filters[filter]++;
330 else 346 else
331 stats.filters[filter] = 1; 347 stats.filters[filter] = 1;
332 } 348 }
333 349
334 // Notify listeners 350 // Notify listeners
335 for (let notifier of notifiers.values()) 351 for (let notifier of notifiers.values())
336 if (!notifier.window || notifier.window == topWnd) 352 if (!notifier.window || notifier.window == topWnd)
337 notifier.notifyListener(node, entry); 353 notifier.notifyListener(node, entry);
338 } 354 }
355
356 /**
357 * Retrieves the statistics for a window.
358 * @result {Object} Object with the properties items, blocked, whitelisted, hidd en, filters containing statistics for the window (might be null)
Thomas Greiner 2015/11/24 17:45:27 Detail: `@result` doesn't exist.
359 */
360 RequestNotifier.getWindowStatistics = function(/**Window*/ wnd)
361 {
362 if (windowStats.has(wnd.document))
363 return windowStats.get(wnd.document);
364 else
365 return null;
366 }
OLDNEW
« no previous file with comments | « no previous file | lib/requestNotifier.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld