diff options
Diffstat (limited to 'toolkit/components/timermanager')
-rw-r--r-- | toolkit/components/timermanager/nsUpdateTimerManager.js | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/toolkit/components/timermanager/nsUpdateTimerManager.js b/toolkit/components/timermanager/nsUpdateTimerManager.js index d7fc15960..3ba82f8c0 100644 --- a/toolkit/components/timermanager/nsUpdateTimerManager.js +++ b/toolkit/components/timermanager/nsUpdateTimerManager.js @@ -16,30 +16,10 @@ const PREF_APP_UPDATE_LOG = "app.update.log"; const CATEGORY_UPDATE_TIMER = "update-timer"; XPCOMUtils.defineLazyGetter(this, "gLogEnabled", function tm_gLogEnabled() { - return getPref("getBoolPref", PREF_APP_UPDATE_LOG, false); + return Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false); }); /** - * Gets a preference value, handling the case where there is no default. - * @param func - * The name of the preference function to call, on nsIPrefBranch - * @param preference - * The name of the preference - * @param defaultValue - * The default value to return in the event the preference has - * no setting - * @returns The value of the preference, or undefined if there was no - * user or default value. - */ -function getPref(func, preference, defaultValue) { - try { - return Services.prefs[func](preference); - } catch (e) { - } - return defaultValue; -} - -/** * Logs a string to the error console. * @param string * The string to write to the error console. @@ -93,13 +73,13 @@ TimerManager.prototype = { minInterval = 500; minFirstInterval = 500; case "profile-after-change": - this._timerMinimumDelay = Math.max(1000 * getPref("getIntPref", PREF_APP_UPDATE_TIMERMINIMUMDELAY, 120), + this._timerMinimumDelay = Math.max(1000 * Services.prefs.getIntPref(PREF_APP_UPDATE_TIMERMINIMUMDELAY, 120), minInterval); // Prevent the timer delay between notifications to other consumers from // being greater than 5 minutes which is 300000 milliseconds. this._timerMinimumDelay = Math.min(this._timerMinimumDelay, 300000); // Prevent the first interval from being less than the value of minFirstInterval - let firstInterval = Math.max(getPref("getIntPref", PREF_APP_UPDATE_TIMERFIRSTINTERVAL, + let firstInterval = Math.max(Services.prefs.getIntPref(PREF_APP_UPDATE_TIMERFIRSTINTERVAL, 30000), minFirstInterval); // Prevent the first interval from being greater than 2 minutes which is // 120000 milliseconds. @@ -189,7 +169,7 @@ TimerManager.prototype = { continue; } - let interval = getPref("getIntPref", prefInterval, defaultInterval); + let interval = Services.prefs.getIntPref(prefInterval, defaultInterval); // Allow the update-timer category to specify a maximum value to prevent // values larger than desired. maxInterval = parseInt(maxInterval); @@ -200,7 +180,7 @@ TimerManager.prototype = { timerID); // Initialize the last update time to 0 when the preference isn't set so // the timer will be notified soon after a new profile's first use. - lastUpdateTime = getPref("getIntPref", prefLastUpdate, 0); + lastUpdateTime = Services.prefs.getIntPref(prefLastUpdate, 0); // If the last update time is greater than the current time then reset // it to 0 and the timer manager will correct the value when it fires @@ -315,7 +295,7 @@ TimerManager.prototype = { let prefLastUpdate = PREF_APP_UPDATE_LASTUPDATETIME_FMT.replace(/%ID%/, id); // Initialize the last update time to 0 when the preference isn't set so // the timer will be notified soon after a new profile's first use. - let lastUpdateTime = getPref("getIntPref", prefLastUpdate, 0); + let lastUpdateTime = Services.prefs.getIntPref(prefLastUpdate, 0); let now = Math.round(Date.now() / 1000); if (lastUpdateTime > now) { lastUpdateTime = 0; |