www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 344bd1fb74d8a6ab5b66279c25c1d6c89527a6a9
parent 6f86d85f89dca399c17dd0ccbc9fb03ebcff4a81
Author: Simon Kornblith <simon@simonster.com>
Date:   Wed, 25 Jul 2012 21:44:10 -0400

Revert "Use setTimeout() on hidden window instead of firing an nsITimer to prevent our JS from getting interpreted instead of JITed."

This reverts commit 0a9fad41246f098c3dad1cc72bdaaf634350e371.

Diffstat:
Mchrome/content/zotero/xpcom/zotero.js | 25+++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js @@ -1473,8 +1473,10 @@ Components.utils.import("resource://gre/modules/Services.jsm"); this.pumpGenerator = function(generator, ms, errorHandler, doneHandler) { _waiting++; - var win = Services.appShell.hiddenDOMWindow; - var intervalID = win.setInterval(function() { + var timer = Components.classes["@mozilla.org/timer;1"]. + createInstance(Components.interfaces.nsITimer), + yielded; + var timerCallback = {"notify":function() { var err = false; _waiting--; try { @@ -1488,7 +1490,8 @@ Components.utils.import("resource://gre/modules/Services.jsm"); err = e; } - win.clearInterval(intervalID); + timer.cancel(); + _runningTimers.splice(_runningTimers.indexOf(timer), 1); // requeue nsITimerCallbacks that came up during generator pumping but couldn't execute for(var i in _waitTimers) { @@ -1506,7 +1509,10 @@ Components.utils.import("resource://gre/modules/Services.jsm"); } else if(doneHandler) { doneHandler(yielded); } - }, ms); + }} + timer.initWithCallback(timerCallback, ms ? ms : 0, Components.interfaces.nsITimer.TYPE_REPEATING_SLACK); + // add timer to global scope so that it doesn't get garbage collected before it completes + _runningTimers.push(timer); }; /** @@ -1530,7 +1536,9 @@ Components.utils.import("resource://gre/modules/Services.jsm"); * is executing */ this.setTimeout = function(func, ms, runWhenWaiting) { - Services.appShell.hiddenDOMWindow.setTimeout(function() { + var timer = Components.classes["@mozilla.org/timer;1"]. + createInstance(Components.interfaces.nsITimer); + var timerCallback = {"notify":function() { if(_waiting && !runWhenWaiting) { // if our callback gets called during Zotero.wait(), queue it to be set again // when Zotero.wait() completes @@ -1539,8 +1547,13 @@ Components.utils.import("resource://gre/modules/Services.jsm"); } else { // execute callback function func(); + // remove timer from global scope, so it can be garbage collected + _runningTimers.splice(_runningTimers.indexOf(timer), 1); } - }, ms); + }} + timer.initWithCallback(timerCallback, ms, Components.interfaces.nsITimer.TYPE_ONE_SHOT); + // add timer to global scope so that it doesn't get garbage collected before it completes + _runningTimers.push(timer); } /**