Bug 1373408 - Make nsUpdateTimerManager notify callbacks on idle. r?rhelmer
MozReview-Commit-ID: INSvHMEXOxt
--- 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);