Bug 1373408 - Make nsUpdateTimerManager notify callbacks on idle. r?rhelmer draft
authorMike Conley <mconley@mozilla.com>
Thu, 12 Jul 2018 14:38:38 -0400
changeset 817517 d222ef2ccdac2a3c864bccd014bfab959d53b1bb
parent 817490 b6e2f74ad3c1fc3161ac7f0444298ec5b6773053
push id116086
push usermconley@mozilla.com
push dateThu, 12 Jul 2018 18:38:59 +0000
reviewersrhelmer
bugs1373408
milestone63.0a1
Bug 1373408 - Make nsUpdateTimerManager notify callbacks on idle. r?rhelmer MozReview-Commit-ID: INSvHMEXOxt
toolkit/components/timermanager/nsUpdateTimerManager.js
--- a/toolkit/components/timermanager/nsUpdateTimerManager.js
+++ b/toolkit/components/timermanager/nsUpdateTimerManager.js
@@ -214,23 +214,25 @@ TimerManager.prototype = {
       // 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 && 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);
-          }
+          ChromeUtils.idleDispatch(() => {
+            try {
+              timerData.callback.notify(timer);
+              LOG("TimerManager:notify - notified timerID: " + timerID);
+            } catch (e) {
+              LOG("TimerManager:notify - error notifying timerID: " + timerID +
+                  ", error: " + e);
+            }
+          });
         } else {
           LOG("TimerManager:notify - timerID: " + timerID + " doesn't " +
               "implement nsITimerCallback - skipping");
         }
         lastUpdateTime = now;
         timerData.lastUpdateTime = lastUpdateTime;
         let prefLastUpdate = PREF_APP_UPDATE_LASTUPDATETIME_FMT.replace(/%ID%/, timerID);
         Services.prefs.setIntPref(prefLastUpdate, lastUpdateTime);