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

Unified Diff: lib/requestNotifier.js

Issue 5743717579227136: Get rid of Utils.threadManager (Closed)
Patch Set: Removed a line that is no longer in use Created March 13, 2014, 11:52 a.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 | « chrome/content/ui/sendReport.js ('k') | lib/utils.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/requestNotifier.js
===================================================================
--- a/lib/requestNotifier.js
+++ b/lib/requestNotifier.js
@@ -148,61 +148,50 @@ RequestNotifier.prototype =
eventsPosted: 0,
/**
* Starts the initial scan of the window (will recurse into frames).
* @param {Window} wnd the window to be scanned
*/
startScan: function(wnd)
{
- let currentThread = Utils.threadManager.currentThread;
-
let doc = wnd.document;
let walker = doc.createTreeWalker(doc, Ci.nsIDOMNodeFilter.SHOW_ELEMENT, null, false);
- let runnable =
+ let process = function()
{
- notifier: null,
+ if (!this.listener)
+ return;
- run: function()
+ let node = walker.currentNode;
+ let data = getEntry(nodeData, node);
+ if (typeof data != "undefined")
+ for (let k in data)
+ this.notifyListener(wnd, node, data[k]);
+
+ if (walker.nextNode())
+ Utils.runAsync(process);
+ else
{
- if (!this.notifier.listener)
- return;
+ // Done with the current window, start the scan for its frames
+ for (let i = 0; i < wnd.frames.length; i++)
+ this.startScan(wnd.frames[i]);
- let node = walker.currentNode;
- let data = getEntry(nodeData, node);
- if (typeof data != "undefined")
- for (let k in data)
- this.notifier.notifyListener(wnd, node, data[k]);
-
- if (walker.nextNode())
- currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL);
- else
+ this.eventsPosted--;
+ if (!this.eventsPosted)
{
- // Done with the current window, start the scan for its frames
- for (let i = 0; i < wnd.frames.length; i++)
- this.notifier.startScan(wnd.frames[i]);
-
- this.notifier.eventsPosted--;
- if (!this.notifier.eventsPosted)
- {
- this.notifier.scanComplete = true;
- this.notifier.notifyListener(wnd, null, null);
- }
-
- this.notifier = null;
+ this.scanComplete = true;
+ this.notifyListener(wnd, null, null);
}
}
- };
- runnable.notifier = this;
+ }.bind(this);
- // Process each node in a separate event on current thread to allow other
- // events to process
+ // Process each node in a separate event to allow other events to process
this.eventsPosted++;
- currentThread.dispatch(runnable, Ci.nsIEventTarget.DISPATCH_NORMAL);
+ Utils.runAsync(process);
}
};
RequestNotifier.storeSelection = function(/**Window*/ wnd, /**String*/ selection)
{
setEntry(windowSelection, wnd.document, selection);
};
RequestNotifier.getSelection = function(/**Window*/ wnd) /**String*/
« no previous file with comments | « chrome/content/ui/sendReport.js ('k') | lib/utils.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld