Bug 897221 - Support JS objects and avoid negative delay in nsUpdateTimerManager; r=rstrong
authorJim Chen <nchen@mozilla.com>
Mon, 09 Sep 2013 15:47:46 -0400
changeset 159179 59214bd5b8942e5024710685fe9e45f659bf1e56
parent 159178 8dc5604a4a880179fb4bf4f2e5e98a036561d936
child 159180 d0938d3591a94c7bb3e222cf34c03246d2fc7a7a
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs897221
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 897221 - Support JS objects and avoid negative delay in nsUpdateTimerManager; r=rstrong
toolkit/mozapps/update/nsUpdateTimerManager.js
--- a/toolkit/mozapps/update/nsUpdateTimerManager.js
+++ b/toolkit/mozapps/update/nsUpdateTimerManager.js
@@ -217,17 +217,17 @@ TimerManager.prototype = {
       // it to 0 and the timer manager will correct the value when it fires
       // next for this consumer.
       if (timerData.lastUpdateTime > now) {
         let prefLastUpdate = PREF_APP_UPDATE_LASTUPDATETIME_FMT.replace(/%ID%/, timerID);
         timerData.lastUpdateTime = 0;
         Services.prefs.setIntPref(prefLastUpdate, timerData.lastUpdateTime);
       }
       tryFire(function() {
-        if (timerData.callback instanceof Ci.nsITimerCallback) {
+        if (timerData.callback && timerData.callback.notify) {
           try {
             timerData.callback.notify(timer);
             LOG("TimerManager:notify - notified timerID: " + timerID);
           }
           catch (e) {
             LOG("TimerManager:notify - error notifying timerID: " + timerID +
                 ", error: " + e);
           }
@@ -267,17 +267,17 @@ TimerManager.prototype = {
       return;
     if (!this._timer) {
       this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
       this._timer.initWithCallback(this, interval,
                                    Ci.nsITimer.TYPE_REPEATING_SLACK);
       this.lastTimerReset = Date.now();
     } else {
       if (Date.now() + interval < this.lastTimerReset + this._timer.delay) 
-        this._timer.delay = this.lastTimerReset + interval - Date.now();
+        this._timer.delay = Math.max(this.lastTimerReset + interval - Date.now(), 0);
     }
   },
 
   /**
    * Stops the timer, if it is running.
    */
   _cancelTimer: function() {
     if (this._timer) {