diff options
author | Ascrod <32915892+Ascrod@users.noreply.github.com> | 2019-04-13 10:53:58 -0400 |
---|---|---|
committer | Ascrod <32915892+Ascrod@users.noreply.github.com> | 2019-04-13 11:37:45 -0400 |
commit | 714e9c9074d9eb2f4063962d07bae6b4f02a1e7a (patch) | |
tree | a1ce0e95383947c2cd5f3b514c2e736240d876f8 /toolkit/components/osfile | |
parent | 2d3b7717ae8ddfa5e6561cff5d6daa7f80a939e5 (diff) | |
download | UXP-714e9c9074d9eb2f4063962d07bae6b4f02a1e7a.tar UXP-714e9c9074d9eb2f4063962d07bae6b4f02a1e7a.tar.gz UXP-714e9c9074d9eb2f4063962d07bae6b4f02a1e7a.tar.lz UXP-714e9c9074d9eb2f4063962d07bae6b4f02a1e7a.tar.xz UXP-714e9c9074d9eb2f4063962d07bae6b4f02a1e7a.zip |
Issue #991 Part 7: Toolkit Components
Diffstat (limited to 'toolkit/components/osfile')
-rw-r--r-- | toolkit/components/osfile/modules/osfile_async_front.jsm | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/toolkit/components/osfile/modules/osfile_async_front.jsm b/toolkit/components/osfile/modules/osfile_async_front.jsm index 93c7e66d6..1d1d7c73f 100644 --- a/toolkit/components/osfile/modules/osfile_async_front.jsm +++ b/toolkit/components/osfile/modules/osfile_async_front.jsm @@ -239,10 +239,9 @@ var Scheduler = this.Scheduler = { * Prepare to kill the OS.File worker after a few seconds. */ restartTimer: function(arg) { - let delay; - try { - delay = Services.prefs.getIntPref("osfile.reset_worker_delay"); - } catch(e) { + let delay = Services.prefs.getIntPref("osfile.reset_worker_delay", 0); + + if (!delay) { // Don't auto-shutdown if we don't have a delay preference set. return; } @@ -469,42 +468,24 @@ const PREF_OSFILE_LOG = "toolkit.osfile.log"; const PREF_OSFILE_LOG_REDIRECT = "toolkit.osfile.log.redirect"; /** - * Safely read a PREF_OSFILE_LOG preference. - * Returns a value read or, in case of an error, oldPref or false. - * - * @param bool oldPref - * An optional value that the DEBUG flag was set to previously. - */ -function readDebugPref(prefName, oldPref = false) { - let pref = oldPref; - try { - pref = Services.prefs.getBoolPref(prefName); - } catch (x) { - // In case of an error when reading a pref keep it as is. - } - // If neither pref nor oldPref were set, default it to false. - return pref; -}; - -/** * Listen to PREF_OSFILE_LOG changes and update gShouldLog flag * appropriately. */ Services.prefs.addObserver(PREF_OSFILE_LOG, function prefObserver(aSubject, aTopic, aData) { - SharedAll.Config.DEBUG = readDebugPref(PREF_OSFILE_LOG, SharedAll.Config.DEBUG); + SharedAll.Config.DEBUG = Services.prefs.getBoolPref(PREF_OSFILE_LOG, SharedAll.Config.DEBUG); if (Scheduler.launched) { // Don't start the worker just to set this preference. Scheduler.post("SET_DEBUG", [SharedAll.Config.DEBUG]); } }, false); -SharedAll.Config.DEBUG = readDebugPref(PREF_OSFILE_LOG, false); +SharedAll.Config.DEBUG = Services.prefs.getBoolPref(PREF_OSFILE_LOG, false); Services.prefs.addObserver(PREF_OSFILE_LOG_REDIRECT, function prefObserver(aSubject, aTopic, aData) { - SharedAll.Config.TEST = readDebugPref(PREF_OSFILE_LOG_REDIRECT, OS.Shared.TEST); + SharedAll.Config.TEST = Services.prefs.getBoolPref(PREF_OSFILE_LOG_REDIRECT, OS.Shared.TEST); }, false); -SharedAll.Config.TEST = readDebugPref(PREF_OSFILE_LOG_REDIRECT, false); +SharedAll.Config.TEST = Services.prefs.getBoolPref(PREF_OSFILE_LOG_REDIRECT, false); /** @@ -515,7 +496,7 @@ var nativeWheneverAvailable = true; const PREF_OSFILE_NATIVE = "toolkit.osfile.native"; Services.prefs.addObserver(PREF_OSFILE_NATIVE, function prefObserver(aSubject, aTopic, aData) { - nativeWheneverAvailable = readDebugPref(PREF_OSFILE_NATIVE, nativeWheneverAvailable); + nativeWheneverAvailable = Services.prefs.getBoolPref(PREF_OSFILE_NATIVE, nativeWheneverAvailable); }, false); @@ -557,10 +538,9 @@ Services.prefs.addObserver(PREF_OSFILE_TEST_SHUTDOWN_OBSERVER, function prefObserver() { // The temporary phase topic used to trigger the unclosed // phase warning. - let TOPIC = null; + let TOPIC = Services.prefs.getCharPref(PREF_OSFILE_TEST_SHUTDOWN_OBSERVER, + ""); try { - TOPIC = Services.prefs.getCharPref( - PREF_OSFILE_TEST_SHUTDOWN_OBSERVER); } catch (x) { } if (TOPIC) { |