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

Unified Diff: lib/child/requestNotifier.js

Issue 29329815: Issue 3274 - Unbreak toolbar icon tooltip (Closed)
Patch Set: Created Nov. 6, 2015, 12:36 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/requestNotifier.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/child/requestNotifier.js
===================================================================
--- a/lib/child/requestNotifier.js
+++ b/lib/child/requestNotifier.js
@@ -32,22 +32,24 @@ let requestEntryMaxId = 0;
* @type Map.<number,RequestNotifier>
*/
let notifiers = new Map();
addMessageListener("AdblockPlus:StartWindowScan", onStartScan);
addMessageListener("AdblockPlus:ShutdownNotifier", onNotifierShutdown);
addMessageListener("AdblockPlus:FlashNodes", onFlashNodes);
addMessageListener("AdblockPlus:RetrieveNodeSize", onRetrieveNodeSize);
+addMessageListener("AdblockPlus:RetrieveWindowStats", onRetrieveWindowStats);
onShutdown.add(() => {
removeMessageListener("AdblockPlus:StartWindowScan", onStartScan);
removeMessageListener("AdblockPlus:ShutdownNotifier", onNotifierShutdown);
removeMessageListener("AdblockPlus:FlashNodes", onFlashNodes);
removeMessageListener("AdblockPlus:RetrieveNodeSize", onRetrieveNodeSize);
+ removeMessageListener("AdblockPlus:RetrieveWindowStats", onRetrieveWindowStats);
});
function onStartScan(message)
{
let {notifierID, outerWindowID} = message.data;
let window = Services.wm.getOuterWindowWithId(outerWindowID);
if (window)
new RequestNotifier(window, notifierID);
@@ -71,16 +73,30 @@ function onFlashNodes(message)
function onRetrieveNodeSize(message)
{
let {notifierID, responseID, requests} = message.data;
let notifier = notifiers.get(notifierID);
if (notifier)
notifier.retrieveNodeSize(requests, responseID);
}
+function onRetrieveWindowStats(message)
+{
+ let {responseID, outerWindowID} = message.data;
+ let window = Services.wm.getOuterWindowWithId(outerWindowID);
+ if (window)
+ {
+ let stats = RequestNotifier.getWindowStatistics(window);
+ sendAsyncMessage("AdblockPlus:RetrieveWindowStatsResponse", {
+ responseID,
+ stats
+ });
+ }
+}
+
/**
* 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.
* @param {Window} wnd window to attach the notifier to
* @param {Integer} id Parent notifier ID to be messaged
*/
function RequestNotifier(window, notifierID)
@@ -331,8 +347,20 @@ RequestNotifier.addNodeData = function(n
stats.filters[filter] = 1;
}
// Notify listeners
for (let notifier of notifiers.values())
if (!notifier.window || notifier.window == topWnd)
notifier.notifyListener(node, entry);
}
+
+/**
+ * Retrieves the statistics for a window.
+ * @result {Object} Object with the properties items, blocked, whitelisted, hidden, filters containing statistics for the window (might be null)
Thomas Greiner 2015/11/24 17:45:27 Detail: `@result` doesn't exist.
+ */
+RequestNotifier.getWindowStatistics = function(/**Window*/ wnd)
+{
+ if (windowStats.has(wnd.document))
+ return windowStats.get(wnd.document);
+ else
+ return null;
+}
« 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