Bug 1416638 - Add a PrefValueKind arg to Preferences::Get*(), and remove Preferences::GetDefault*(). r=glandium draft
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 14 Nov 2017 19:06:01 +1100
changeset 697565 d8c3a5d2af7b150b1d060497db98223efe4d6d23
parent 697564 05ac45f5cfa3d6927b7ef4a51a10e620a91f2236
child 697566 82fdd10073c1bcc700be7f3d5748917d0622f718
push id89043
push usernnethercote@mozilla.com
push dateTue, 14 Nov 2017 08:06:49 +0000
reviewersglandium
bugs1416638
milestone58.0a1
Bug 1416638 - Add a PrefValueKind arg to Preferences::Get*(), and remove Preferences::GetDefault*(). r=glandium MozReview-Commit-ID: LgnZAf1pAl1
docshell/shistory/nsSHistory.cpp
gfx/config/gfxFeature.cpp
gfx/thebes/gfxPlatform.cpp
modules/libpref/Preferences.cpp
modules/libpref/Preferences.h
netwerk/cache2/CacheObserver.cpp
toolkit/components/startup/nsAppStartup.cpp
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -330,17 +330,17 @@ nsSHistory::UpdatePrefs()
 nsresult
 nsSHistory::Startup()
 {
   UpdatePrefs();
 
   // The goal of this is to unbreak users who have inadvertently set their
   // session history size to less than the default value.
   int32_t defaultHistoryMaxSize =
-    Preferences::GetDefaultInt(PREF_SHISTORY_SIZE, 50);
+    Preferences::GetInt(PREF_SHISTORY_SIZE, 50, PrefValueKind::Default);
   if (gHistoryMaxSize < defaultHistoryMaxSize) {
     gHistoryMaxSize = defaultHistoryMaxSize;
   }
 
   // Allow the user to override the max total number of cached viewers,
   // but keep the per SHistory cached viewer limit constant
   if (!gObserver) {
     gObserver = new nsSHistoryObserver();
--- a/gfx/config/gfxFeature.cpp
+++ b/gfx/config/gfxFeature.cpp
@@ -55,17 +55,18 @@ FeatureState::SetDefault(bool aEnable,
   return true;
 }
 
 void
 FeatureState::SetDefaultFromPref(const char* aPrefName,
                                  bool aIsEnablePref,
                                  bool aDefaultValue)
 {
-  bool baseValue = Preferences::GetDefaultBool(aPrefName, aDefaultValue);
+  bool baseValue =
+    Preferences::GetBool(aPrefName, aDefaultValue, PrefValueKind::Default);
   SetDefault(baseValue == aIsEnablePref, FeatureStatus::Disabled, "Disabled by default");
 
   if (Preferences::HasUserValue(aPrefName)) {
     bool userValue = Preferences::GetBool(aPrefName, aDefaultValue);
     if (userValue == aIsEnablePref) {
       nsCString message("Enabled via ");
       message.AppendASCII(aPrefName);
       UserEnable(message.get());
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -2591,17 +2591,17 @@ gfxPlatform::InitOMTPConfig()
       reporter.SetSuccessful();
     }
     return;
   }
 
   omtp.SetDefaultFromPref(
     "layers.omtp.enabled",
     true,
-    Preferences::GetDefaultBool("layers.omtp.enabled", false));
+    Preferences::GetBool("layers.omtp.enabled", false, PrefValueKind::Default));
 
   if (mContentBackend == BackendType::CAIRO) {
     omtp.ForceDisable(FeatureStatus::Broken, "OMTP is not supported when using cairo",
       NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_PREF"));
   }
 
   if (InSafeMode()) {
     omtp.ForceDisable(FeatureStatus::Blocked, "OMTP blocked by safe-mode",
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -4478,24 +4478,24 @@ pref_InitInitialObjects()
   NS_ENSURE_SUCCESS(
     rv, Err("pref_LoadPrefsInDirList(NS_APP_PREFS_DEFAULTS_DIR_LIST) failed"));
 
 #ifdef MOZ_WIDGET_ANDROID
   // Set up the correct default for toolkit.telemetry.enabled. If this build
   // has MOZ_TELEMETRY_ON_BY_DEFAULT *or* we're on the beta channel, telemetry
   // is on by default, otherwise not. This is necessary so that beta users who
   // are testing final release builds don't flipflop defaults.
-  if (Preferences::GetDefaultType(kTelemetryPref) ==
+  if (Preferences::GetType(kTelemetryPref, PrefValueKind::Default) ==
       nsIPrefBranch::PREF_INVALID) {
     bool prerelease = false;
 #ifdef MOZ_TELEMETRY_ON_BY_DEFAULT
     prerelease = true;
 #else
     nsAutoCString prefValue;
-    Preferences::GetDefaultCString(kChannelPref, prefValue);
+    Preferences::GetCString(kChannelPref, prefValue, PrefValueKind::Default);
     if (prefValue.EqualsLiteral("beta")) {
       prerelease = true;
     }
 #endif
     PREF_SetBoolPref(kTelemetryPref, prerelease, true);
   }
 #else
   // For platforms with Unified Telemetry (here meaning not-Android),
@@ -4532,93 +4532,118 @@ pref_InitInitialObjects()
   return Ok();
 }
 
 //----------------------------------------------------------------------------
 // Static utilities
 //----------------------------------------------------------------------------
 
 /* static */ nsresult
-Preferences::GetBool(const char* aPref, bool* aResult)
+Preferences::GetBool(const char* aPrefName, bool* aResult, PrefValueKind aKind)
 {
   NS_PRECONDITION(aResult, "aResult must not be NULL");
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return PREF_GetBoolPref(aPref, aResult, false);
+  return PREF_GetBoolPref(aPrefName, aResult, aKind == PrefValueKind::Default);
 }
 
 /* static */ nsresult
-Preferences::GetInt(const char* aPref, int32_t* aResult)
+Preferences::GetInt(const char* aPrefName,
+                    int32_t* aResult,
+                    PrefValueKind aKind)
 {
   NS_PRECONDITION(aResult, "aResult must not be NULL");
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return PREF_GetIntPref(aPref, aResult, false);
+  return PREF_GetIntPref(aPrefName, aResult, aKind == PrefValueKind::Default);
 }
 
 /* static */ nsresult
-Preferences::GetFloat(const char* aPref, float* aResult)
+Preferences::GetFloat(const char* aPrefName,
+                      float* aResult,
+                      PrefValueKind aKind)
 {
   NS_PRECONDITION(aResult, "aResult must not be NULL");
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
   nsAutoCString result;
-  nsresult rv = PREF_GetCStringPref(aPref, result, false);
+  nsresult rv =
+    PREF_GetCStringPref(aPrefName, result, aKind == PrefValueKind::Default);
   if (NS_SUCCEEDED(rv)) {
     *aResult = result.ToFloat(&rv);
   }
   return rv;
 }
 
 /* static */ nsresult
-Preferences::GetCString(const char* aPref, nsACString& aResult)
+Preferences::GetCString(const char* aPrefName,
+                        nsACString& aResult,
+                        PrefValueKind aKind)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return PREF_GetCStringPref(aPref, aResult, false);
+  return PREF_GetCStringPref(
+    aPrefName, aResult, aKind == PrefValueKind::Default);
 }
 
 /* static */ nsresult
-Preferences::GetString(const char* aPref, nsAString& aResult)
+Preferences::GetString(const char* aPrefName,
+                       nsAString& aResult,
+                       PrefValueKind aKind)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
   nsAutoCString result;
-  nsresult rv = PREF_GetCStringPref(aPref, result, false);
+  nsresult rv =
+    PREF_GetCStringPref(aPrefName, result, aKind == PrefValueKind::Default);
   if (NS_SUCCEEDED(rv)) {
     CopyUTF8toUTF16(result, aResult);
   }
   return rv;
 }
 
 /* static */ nsresult
-Preferences::GetLocalizedCString(const char* aPref, nsACString& aResult)
+Preferences::GetLocalizedCString(const char* aPrefName,
+                                 nsACString& aResult,
+                                 PrefValueKind aKind)
 {
   nsAutoString result;
-  nsresult rv = GetLocalizedString(aPref, result);
+  nsresult rv = GetLocalizedString(aPrefName, result);
   if (NS_SUCCEEDED(rv)) {
     CopyUTF16toUTF8(result, aResult);
   }
   return rv;
 }
 
 /* static */ nsresult
-Preferences::GetLocalizedString(const char* aPref, nsAString& aResult)
+Preferences::GetLocalizedString(const char* aPrefName,
+                                nsAString& aResult,
+                                PrefValueKind aKind)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
   nsCOMPtr<nsIPrefLocalizedString> prefLocalString;
-  nsresult rv = sPreferences->mRootBranch->GetComplexValue(
-    aPref, NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(prefLocalString));
+  nsCOMPtr<nsIPrefBranch> branch = (aKind == PrefValueKind::Default)
+                                     ? sPreferences->mDefaultRootBranch
+                                     : sPreferences->mRootBranch;
+  nsresult rv = branch->GetComplexValue(aPrefName,
+                                        NS_GET_IID(nsIPrefLocalizedString),
+                                        getter_AddRefs(prefLocalString));
   if (NS_SUCCEEDED(rv)) {
     NS_ASSERTION(prefLocalString, "Succeeded but the result is NULL");
     prefLocalString->GetData(aResult);
   }
   return rv;
 }
 
 /* static */ nsresult
-Preferences::GetComplex(const char* aPref, const nsIID& aType, void** aResult)
+Preferences::GetComplex(const char* aPrefName,
+                        const nsIID& aType,
+                        void** aResult,
+                        PrefValueKind aKind)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return sPreferences->mRootBranch->GetComplexValue(aPref, aType, aResult);
+  nsCOMPtr<nsIPrefBranch> branch = (aKind == PrefValueKind::Default)
+                                     ? sPreferences->mDefaultRootBranch
+                                     : sPreferences->mRootBranch;
+  return branch->GetComplexValue(aPrefName, aType, aResult);
 }
 
 /* static */ nsresult
 Preferences::SetCString(const char* aPrefName,
                         const char* aValue,
                         PrefValueKind aKind)
 {
   ENSURE_MAIN_PROCESS("SetCString", aPrefName);
@@ -4706,21 +4731,24 @@ Preferences::ClearUser(const char* aPref
 /* static */ bool
 Preferences::HasUserValue(const char* aPref)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), false);
   return PREF_HasUserPref(aPref);
 }
 
 /* static */ int32_t
-Preferences::GetType(const char* aPref)
+Preferences::GetType(const char* aPrefName, PrefValueKind aKind)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), nsIPrefBranch::PREF_INVALID);
+  nsCOMPtr<nsIPrefBranch> branch = (aKind == PrefValueKind::Default)
+                                     ? sPreferences->mDefaultRootBranch
+                                     : sPreferences->mRootBranch;
   int32_t result;
-  return NS_SUCCEEDED(sPreferences->mRootBranch->GetPrefType(aPref, &result))
+  return NS_SUCCEEDED(branch->GetPrefType(aPrefName, &result))
            ? result
            : nsIPrefBranch::PREF_INVALID;
 }
 
 /* static */ nsresult
 Preferences::AddStrongObserver(nsIObserver* aObserver, const char* aPref)
 {
   MOZ_ASSERT(aObserver);
@@ -4992,97 +5020,16 @@ Preferences::AddFloatVarCache(float* aCa
   CacheData* data = new CacheData();
   data->mCacheLocation = aCache;
   data->mDefaultValueFloat = aDefault;
   CacheDataAppendElement(data);
   RegisterVarCacheCallback(FloatVarChanged, aPref, data);
   return NS_OK;
 }
 
-/* static */ nsresult
-Preferences::GetDefaultBool(const char* aPref, bool* aResult)
-{
-  NS_PRECONDITION(aResult, "aResult must not be NULL");
-  NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return PREF_GetBoolPref(aPref, aResult, true);
-}
-
-/* static */ nsresult
-Preferences::GetDefaultInt(const char* aPref, int32_t* aResult)
-{
-  NS_PRECONDITION(aResult, "aResult must not be NULL");
-  NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return PREF_GetIntPref(aPref, aResult, true);
-}
-
-/* static */ nsresult
-Preferences::GetDefaultCString(const char* aPref, nsACString& aResult)
-{
-  NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return PREF_GetCStringPref(aPref, aResult, true);
-}
-
-/* static */ nsresult
-Preferences::GetDefaultString(const char* aPref, nsAString& aResult)
-{
-  NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  nsAutoCString result;
-  nsresult rv = PREF_GetCStringPref(aPref, result, true);
-  if (NS_SUCCEEDED(rv)) {
-    CopyUTF8toUTF16(result, aResult);
-  }
-  return rv;
-}
-
-/* static */ nsresult
-Preferences::GetDefaultLocalizedCString(const char* aPref, nsACString& aResult)
-{
-  nsAutoString result;
-  nsresult rv = GetDefaultLocalizedString(aPref, result);
-  if (NS_SUCCEEDED(rv)) {
-    CopyUTF16toUTF8(result, aResult);
-  }
-  return rv;
-}
-
-/* static */ nsresult
-Preferences::GetDefaultLocalizedString(const char* aPref, nsAString& aResult)
-{
-  NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  nsCOMPtr<nsIPrefLocalizedString> prefLocalString;
-  nsresult rv = sPreferences->mDefaultRootBranch->GetComplexValue(
-    aPref, NS_GET_IID(nsIPrefLocalizedString), getter_AddRefs(prefLocalString));
-  if (NS_SUCCEEDED(rv)) {
-    NS_ASSERTION(prefLocalString, "Succeeded but the result is NULL");
-    prefLocalString->GetData(aResult);
-  }
-  return rv;
-}
-
-/* static */ nsresult
-Preferences::GetDefaultComplex(const char* aPref,
-                               const nsIID& aType,
-                               void** aResult)
-{
-  NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
-  return sPreferences->mDefaultRootBranch->GetComplexValue(
-    aPref, aType, aResult);
-}
-
-/* static */ int32_t
-Preferences::GetDefaultType(const char* aPref)
-{
-  NS_ENSURE_TRUE(InitStaticMembers(), nsIPrefBranch::PREF_INVALID);
-  int32_t result;
-  return NS_SUCCEEDED(
-           sPreferences->mDefaultRootBranch->GetPrefType(aPref, &result))
-           ? result
-           : nsIPrefBranch::PREF_INVALID;
-}
-
 } // namespace mozilla
 
 #undef ENSURE_MAIN_PROCESS
 
 //===========================================================================
 // Module and factory stuff
 //===========================================================================
 
--- a/modules/libpref/Preferences.h
+++ b/modules/libpref/Preferences.h
@@ -86,110 +86,94 @@ public:
   // Returns shared pref service instance NOTE: not addreffed.
   static nsIPrefService* GetService()
   {
     NS_ENSURE_TRUE(InitStaticMembers(), nullptr);
     return sPreferences;
   }
 
   // Returns shared pref branch instance. NOTE: not addreffed.
-  static nsIPrefBranch* GetRootBranch()
+  static nsIPrefBranch* GetRootBranch(PrefValueKind aKind = PrefValueKind::User)
   {
     NS_ENSURE_TRUE(InitStaticMembers(), nullptr);
-    return sPreferences->mRootBranch;
-  }
-
-  // Returns shared default pref branch instance. NOTE: not addreffed.
-  static nsIPrefBranch* GetDefaultRootBranch()
-  {
-    NS_ENSURE_TRUE(InitStaticMembers(), nullptr);
-    return sPreferences->mDefaultRootBranch;
+    return (aKind == PrefValueKind::Default) ? sPreferences->mDefaultRootBranch
+                                             : sPreferences->mRootBranch;
   }
 
   // Gets the type of the pref.
-  static int32_t GetDefaultType(const char* aPref);
+  static int32_t GetType(const char* aPrefName,
+                         PrefValueKind aKind = PrefValueKind::User);
 
-  // Fallible getters of default values.
-  static nsresult GetDefaultBool(const char* aPref, bool* aResult);
-  static nsresult GetDefaultInt(const char* aPref, int32_t* aResult);
-  static nsresult GetDefaultUint(const char* aPref, uint32_t* aResult)
-  {
-    return GetDefaultInt(aPref, reinterpret_cast<int32_t*>(aResult));
-  }
-  static nsresult GetDefaultCString(const char* aPref, nsACString& aResult);
-  static nsresult GetDefaultString(const char* aPref, nsAString& aResult);
-  static nsresult GetDefaultLocalizedCString(const char* aPref,
-                                             nsACString& aResult);
-  static nsresult GetDefaultLocalizedString(const char* aPref,
-                                            nsAString& aResult);
-  static nsresult GetDefaultComplex(const char* aPref,
-                                    const nsIID& aType,
-                                    void** aResult);
-
-  // Infallible getters of default values, with fallback results on failure.
-  static bool GetDefaultBool(const char* aPref, bool aFailedResult)
-  {
-    bool result;
-    return NS_SUCCEEDED(GetDefaultBool(aPref, &result)) ? result
-                                                        : aFailedResult;
-  }
-  static int32_t GetDefaultInt(const char* aPref, int32_t aFailedResult)
+  // Fallible value getters.
+  static nsresult GetBool(const char* aPrefName,
+                          bool* aResult,
+                          PrefValueKind aKind = PrefValueKind::User);
+  static nsresult GetInt(const char* aPrefName,
+                         int32_t* aResult,
+                         PrefValueKind aKind = PrefValueKind::User);
+  static nsresult GetUint(const char* aPrefName,
+                          uint32_t* aResult,
+                          PrefValueKind aKind = PrefValueKind::User)
   {
-    int32_t result;
-    return NS_SUCCEEDED(GetDefaultInt(aPref, &result)) ? result : aFailedResult;
-  }
-  static uint32_t GetDefaultUint(const char* aPref, uint32_t aFailedResult)
-  {
-    return static_cast<uint32_t>(
-      GetDefaultInt(aPref, static_cast<int32_t>(aFailedResult)));
+    return GetInt(aPrefName, reinterpret_cast<int32_t*>(aResult), aKind);
   }
-
-  // Gets the type of the pref.
-  static int32_t GetType(const char* aPref);
-
-  // Fallible getters of user or default values.
-  static nsresult GetBool(const char* aPref, bool* aResult);
-  static nsresult GetInt(const char* aPref, int32_t* aResult);
-  static nsresult GetUint(const char* aPref, uint32_t* aResult)
-  {
-    return GetInt(aPref, reinterpret_cast<int32_t*>(aResult));
-  }
-  static nsresult GetFloat(const char* aPref, float* aResult);
-  static nsresult GetCString(const char* aPref, nsACString& aResult);
-  static nsresult GetString(const char* aPref, nsAString& aResult);
-  static nsresult GetLocalizedCString(const char* aPref, nsACString& aResult);
-  static nsresult GetLocalizedString(const char* aPref, nsAString& aResult);
-  static nsresult GetComplex(const char* aPref,
+  static nsresult GetFloat(const char* aPrefName,
+                           float* aResult,
+                           PrefValueKind aKind = PrefValueKind::User);
+  static nsresult GetCString(const char* aPrefName,
+                             nsACString& aResult,
+                             PrefValueKind aKind = PrefValueKind::User);
+  static nsresult GetString(const char* aPrefName,
+                            nsAString& aResult,
+                            PrefValueKind aKind = PrefValueKind::User);
+  static nsresult GetLocalizedCString(
+    const char* aPrefName,
+    nsACString& aResult,
+    PrefValueKind aKind = PrefValueKind::User);
+  static nsresult GetLocalizedString(const char* aPrefName,
+                                     nsAString& aResult,
+                                     PrefValueKind aKind = PrefValueKind::User);
+  static nsresult GetComplex(const char* aPrefName,
                              const nsIID& aType,
-                             void** aResult);
+                             void** aResult,
+                             PrefValueKind aKind = PrefValueKind::User);
 
   // Infallible getters of user or default values, with fallback results on
   // failure.
-  static bool GetBool(const char* aPref, bool aDefault = false)
+  // Infallible value getters.
+  static bool GetBool(const char* aPrefName,
+                      bool aFallback = false,
+                      PrefValueKind aKind = PrefValueKind::User)
   {
-    bool result = aDefault;
-    GetBool(aPref, &result);
+    bool result = aFallback;
+    GetBool(aPrefName, &result);
     return result;
   }
-  static int32_t GetInt(const char* aPref, int32_t aDefault = 0)
+  static int32_t GetInt(const char* aPrefName,
+                        int32_t aFallback = 0,
+                        PrefValueKind aKind = PrefValueKind::User)
   {
-    int32_t result = aDefault;
-    GetInt(aPref, &result);
+    int32_t result = aFallback;
+    GetInt(aPrefName, &result);
     return result;
   }
-  static uint32_t GetUint(const char* aPref, uint32_t aDefault = 0)
+  static uint32_t GetUint(const char* aPrefName,
+                          uint32_t aFallback = 0,
+                          PrefValueKind aKind = PrefValueKind::User)
   {
-    uint32_t result = aDefault;
-    GetUint(aPref, &result);
+    uint32_t result = aFallback;
+    GetUint(aPrefName, &result);
     return result;
   }
-  static float GetFloat(const char* aPref, float aDefault = 0)
+  static float GetFloat(const char* aPrefName,
+                        float aFallback = 0.0f,
+                        PrefValueKind aKind = PrefValueKind::User)
   {
-    float result = aDefault;
-    GetFloat(aPref, &result);
+    float result = aFallback;
+    GetFloat(aPrefName, &result);
     return result;
   }
 
   // Value setters.
   static nsresult SetBool(const char* aPrefName,
                           bool aValue,
                           PrefValueKind aKind = PrefValueKind::User);
   static nsresult SetInt(const char* aPrefName,
--- a/netwerk/cache2/CacheObserver.cpp
+++ b/netwerk/cache2/CacheObserver.cpp
@@ -181,18 +181,19 @@ CacheObserver::AttachToPreferences()
 
   mozilla::Preferences::GetComplex(
     "browser.cache.disk.parent_directory", NS_GET_IID(nsIFile),
     getter_AddRefs(mCacheParentDirectoryOverride));
 
   // First check the default value.  If it is at -1, the experient
   // is turned off.  If it is at 0, then use the user pref value
   // instead.
-  sHalfLifeExperiment = mozilla::Preferences::GetDefaultInt(
-    "browser.cache.frecency_experiment", kDefaultHalfLifeExperiment);
+  sHalfLifeExperiment = mozilla::Preferences::GetInt(
+    "browser.cache.frecency_experiment", kDefaultHalfLifeExperiment,
+    PrefValueKind::Default);
 
   if (sHalfLifeExperiment == 0) {
     // Default preferences indicate we want to run the experiment,
     // hence read the user value.
     sHalfLifeExperiment = mozilla::Preferences::GetInt(
       "browser.cache.frecency_experiment", sHalfLifeExperiment);
   }
 
--- a/toolkit/components/startup/nsAppStartup.cpp
+++ b/toolkit/components/startup/nsAppStartup.cpp
@@ -956,17 +956,18 @@ nsAppStartup::TrackStartupCrashEnd()
       NS_WARNING("Could not set startup crash detection pref.");
   }
 
   if (inSafeMode && mIsSafeModeNecessary) {
     // On a successful startup in automatic safe mode, allow the user one more crash
     // in regular mode before returning to safe mode.
     int32_t maxResumedCrashes = 0;
     int32_t prefType;
-    rv = Preferences::GetDefaultRootBranch()->GetPrefType(kPrefMaxResumedCrashes, &prefType);
+    rv = Preferences::GetRootBranch(
+      PrefValueKind::Default)->GetPrefType(kPrefMaxResumedCrashes, &prefType);
     NS_ENSURE_SUCCESS(rv, rv);
     if (prefType == nsIPrefBranch::PREF_INT) {
       rv = Preferences::GetInt(kPrefMaxResumedCrashes, &maxResumedCrashes);
       NS_ENSURE_SUCCESS(rv, rv);
     }
     rv = Preferences::SetInt(kPrefRecentCrashes, maxResumedCrashes);
     NS_ENSURE_SUCCESS(rv, rv);
   } else if (!inSafeMode) {