Bug 1394578 - Rename dom::PrefSetting as dom::Pref. r=glandium draft
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 22 Nov 2017 21:21:19 +1100
changeset 702905 760e6eb36238a19c4c27b942d59c2c38bce2fb8f
parent 702904 d3c9b81dd78c01ccb0d91e728584c9bc8a574b14
child 702906 fb1320a01b2994baf0aefca432112e0ea4dff444
push id90624
push usernnethercote@mozilla.com
push dateThu, 23 Nov 2017 23:13:32 +0000
reviewersglandium
bugs1394578
milestone59.0a1
Bug 1394578 - Rename dom::PrefSetting as dom::Pref. r=glandium It represents a pref, so `Pref` is a better name. Within Preferences.cpp the patch uses domPref/aDomPref to distinguish it from PrefHashEntry values. MozReview-Commit-ID: HXTl0GX4BtO
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/ContentProcess.cpp
dom/ipc/PContent.ipdl
modules/libpref/Preferences.cpp
modules/libpref/Preferences.h
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -2380,17 +2380,17 @@ ContentChild::AddRemoteAlertObserver(con
                                      nsIObserver* aObserver)
 {
   NS_ASSERTION(aObserver, "Adding a null observer?");
   mAlertObservers.AppendElement(new AlertObserver(aObserver, aData));
   return NS_OK;
 }
 
 mozilla::ipc::IPCResult
-ContentChild::RecvPreferenceUpdate(const PrefSetting& aPref)
+ContentChild::RecvPreferenceUpdate(const Pref& aPref)
 {
   Preferences::SetPreference(aPref);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 ContentChild::RecvVarUpdate(const GfxVarUpdate& aVar)
 {
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -366,17 +366,17 @@ public:
   virtual mozilla::ipc::IPCResult RecvBidiKeyboardNotify(const bool& isLangRTL,
                                                          const bool& haveBidiKeyboards) override;
 
   virtual mozilla::ipc::IPCResult RecvNotifyVisited(const URIParams& aURI) override;
 
   // auto remove when alertfinished is received.
   nsresult AddRemoteAlertObserver(const nsString& aData, nsIObserver* aObserver);
 
-  virtual mozilla::ipc::IPCResult RecvPreferenceUpdate(const PrefSetting& aPref) override;
+  virtual mozilla::ipc::IPCResult RecvPreferenceUpdate(const Pref& aPref) override;
   virtual mozilla::ipc::IPCResult RecvVarUpdate(const GfxVarUpdate& pref) override;
 
   virtual mozilla::ipc::IPCResult RecvDataStoragePut(const nsString& aFilename,
                                                      const DataStorageItem& aItem) override;
 
   virtual mozilla::ipc::IPCResult RecvDataStorageRemove(const nsString& aFilename,
                                                         const nsCString& aKey,
                                                         const DataStorageType& aType) override;
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -2792,17 +2792,17 @@ ContentParent::Observe(nsISupports* aSub
       if (NS_strncmp(entry.mPrefBranch, aData, entry.mLen) == 0) {
         return NS_OK;
       }
     }
 
     // We know prefs are ASCII here.
     NS_LossyConvertUTF16toASCII strData(aData);
 
-    PrefSetting pref(strData, null_t(), null_t());
+    Pref pref(strData, null_t(), null_t());
     Preferences::GetPreference(&pref);
     if (!SendPreferenceUpdate(pref)) {
       return NS_ERROR_NOT_AVAILABLE;
     }
   }
   else if (!strcmp(aTopic, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC)) {
     NS_ConvertUTF16toUTF8 dataStr(aData);
     const char *offline = dataStr.get();
--- a/dom/ipc/ContentProcess.cpp
+++ b/dom/ipc/ContentProcess.cpp
@@ -110,17 +110,17 @@ ContentProcess::Init(int aArgc, char* aA
 
 #if defined(XP_MACOSX) && defined(MOZ_CONTENT_SANDBOX)
   // If passed in grab the profile path for sandboxing
   bool foundProfile = false;
   nsCOMPtr<nsIFile> profileDir;
 #endif
 
   char* schedulerPrefs = nullptr;
-  InfallibleTArray<PrefSetting> prefsArray;
+  InfallibleTArray<Pref> prefsArray;
   for (int idx = aArgc; idx > 0; idx--) {
     if (!aArgv[idx]) {
       continue;
     }
 
     if (!strcmp(aArgv[idx], "-appdir")) {
       MOZ_ASSERT(!foundAppdir);
       if (foundAppdir) {
@@ -151,48 +151,48 @@ ContentProcess::Init(int aArgc, char* aA
       char* str = aArgv[idx + 1];
       while (*str) {
         int32_t index = strtol(str, &str, 10);
         MOZ_ASSERT(str[0] == ':');
         str++;
         MaybePrefValue value(PrefValue(static_cast<int32_t>(strtol(str, &str, 10))));
         MOZ_ASSERT(str[0] == '|');
         str++;
-        PrefSetting pref(nsCString(ContentPrefs::GetContentPref(index)), value, MaybePrefValue());
+        Pref pref(nsCString(ContentPrefs::GetContentPref(index)), value, MaybePrefValue());
         prefsArray.AppendElement(pref);
       }
       SET_PREF_PHASE(END_INIT_PREFS);
       foundIntPrefs = true;
     } else if (!strcmp(aArgv[idx], "-boolPrefs")) {
       SET_PREF_PHASE(BEGIN_INIT_PREFS);
       char* str = aArgv[idx + 1];
       while (*str) {
         int32_t index = strtol(str, &str, 10);
         MOZ_ASSERT(str[0] == ':');
         str++;
         MaybePrefValue value(PrefValue(!!strtol(str, &str, 10)));
         MOZ_ASSERT(str[0] == '|');
         str++;
-        PrefSetting pref(nsCString(ContentPrefs::GetContentPref(index)), value, MaybePrefValue());
+        Pref pref(nsCString(ContentPrefs::GetContentPref(index)), value, MaybePrefValue());
         prefsArray.AppendElement(pref);
       }
       SET_PREF_PHASE(END_INIT_PREFS);
       foundBoolPrefs = true;
     } else if (!strcmp(aArgv[idx], "-stringPrefs")) {
       SET_PREF_PHASE(BEGIN_INIT_PREFS);
       char* str = aArgv[idx + 1];
       while (*str) {
         int32_t index = strtol(str, &str, 10);
         MOZ_ASSERT(str[0] == ':');
         str++;
         int32_t length = strtol(str, &str, 10);
         MOZ_ASSERT(str[0] == ';');
         str++;
         MaybePrefValue value(PrefValue(nsCString(str, length)));
-        PrefSetting pref(nsCString(ContentPrefs::GetContentPref(index)), value, MaybePrefValue());
+        Pref pref(nsCString(ContentPrefs::GetContentPref(index)), value, MaybePrefValue());
         prefsArray.AppendElement(pref);
         str += length + 1;
         MOZ_ASSERT(*(str - 1) == '|');
       }
       SET_PREF_PHASE(END_INIT_PREFS);
       foundStringPrefs = true;
     } else if (!strcmp(aArgv[idx], "-schedulerPrefs")) {
       schedulerPrefs = aArgv[idx + 1];
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -151,17 +151,17 @@ union PrefValue {
   bool;
 };
 
 union MaybePrefValue {
   PrefValue;
   null_t;
 };
 
-struct PrefSetting {
+struct Pref {
   nsCString name;
   MaybePrefValue defaultValue;
   MaybePrefValue userValue;
 };
 
 struct DataStorageItem {
   nsCString key;
   nsCString value;
@@ -267,17 +267,17 @@ struct XPCOMInitData
     bool isConnected;
     int32_t captivePortalState;
     bool isLangRTL;
     bool haveBidiKeyboards;
     nsString[] dictionaries;
     ClipboardCapabilities clipboardCaps;
     DomainPolicyClone domainPolicy;
     OptionalURIParams userContentSheetURL;
-    PrefSetting[] prefs;
+    Pref[] prefs;
     GfxVarUpdate[] gfxNonDefaultVarUpdates;
     ContentDeviceData contentDeviceData;
     GfxInfoFeatureStatus[] gfxFeatureStatus;
     DataStorageEntry[] dataStorage;
     nsCString[] appLocales;
     nsCString[] requestedLocales;
     DynamicScalarDefinition[] dynamicScalarDefs;
 };
@@ -422,17 +422,17 @@ child:
     async ClearImageCache(bool privateLoader, bool chrome);
 
     async SetOffline(bool offline);
     async SetConnectivity(bool connectivity);
     async SetCaptivePortalState(int32_t aState);
 
     async NotifyVisited(URIParams uri);
 
-    async PreferenceUpdate(PrefSetting pref);
+    async PreferenceUpdate(Pref pref);
     async VarUpdate(GfxVarUpdate var);
 
     async DataStoragePut(nsString aFilename, DataStorageItem aItem);
     async DataStorageRemove(nsString aFilename, nsCString aKey, DataStorageType aType);
     async DataStorageClear(nsString aFilename);
 
     async NotifyAlertsObserver(nsCString topic, nsString data);
 
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -384,41 +384,41 @@ private:
         return;
 
       default:
         MOZ_CRASH();
     }
   }
 
 public:
-  void ToSetting(dom::PrefSetting* aSetting)
+  void ToDomPref(dom::Pref* aDomPref)
   {
-    aSetting->name() = mName;
+    aDomPref->name() = mName;
 
     if (mHasDefaultValue) {
-      aSetting->defaultValue() = dom::PrefValue();
+      aDomPref->defaultValue() = dom::PrefValue();
       AssignPrefValueToDomPrefValue(
-        Type(), &mDefaultValue, &aSetting->defaultValue().get_PrefValue());
+        Type(), &mDefaultValue, &aDomPref->defaultValue().get_PrefValue());
     } else {
-      aSetting->defaultValue() = null_t();
+      aDomPref->defaultValue() = null_t();
     }
 
     if (mHasUserValue) {
-      aSetting->userValue() = dom::PrefValue();
+      aDomPref->userValue() = dom::PrefValue();
       AssignPrefValueToDomPrefValue(
-        Type(), &mUserValue, &aSetting->userValue().get_PrefValue());
+        Type(), &mUserValue, &aDomPref->userValue().get_PrefValue());
     } else {
-      aSetting->userValue() = null_t();
+      aDomPref->userValue() = null_t();
     }
 
-    MOZ_ASSERT(aSetting->defaultValue().type() ==
+    MOZ_ASSERT(aDomPref->defaultValue().type() ==
                  dom::MaybePrefValue::Tnull_t ||
-               aSetting->userValue().type() == dom::MaybePrefValue::Tnull_t ||
-               (aSetting->defaultValue().get_PrefValue().type() ==
-                aSetting->userValue().get_PrefValue().type()));
+               aDomPref->userValue().type() == dom::MaybePrefValue::Tnull_t ||
+               (aDomPref->defaultValue().get_PrefValue().type() ==
+                aDomPref->userValue().get_PrefValue().type()));
   }
 
   bool HasAdvisablySizedValues()
   {
     if (!IsTypeString()) {
       return true;
     }
 
@@ -3230,17 +3230,17 @@ public:
   NS_IMETHOD Run() override
   {
     return RegisterStrongMemoryReporter(new PreferenceServiceReporter());
   }
 };
 
 } // namespace
 
-static InfallibleTArray<Preferences::PrefSetting>* gInitSettings;
+static InfallibleTArray<dom::Pref>* gInitDomPrefs;
 
 /* static */ already_AddRefed<Preferences>
 Preferences::GetInstanceForService()
 {
   if (sPreferences) {
     return do_AddRef(sPreferences);
   }
 
@@ -3258,22 +3258,22 @@ Preferences::GetInstanceForService()
   Result<Ok, const char*> res = InitInitialObjects();
   if (res.isErr()) {
     sPreferences = nullptr;
     gCacheDataDesc = res.unwrapErr();
     return nullptr;
   }
 
   if (!XRE_IsParentProcess()) {
-    MOZ_ASSERT(gInitSettings);
-    for (unsigned int i = 0; i < gInitSettings->Length(); i++) {
-      Preferences::SetPreference(gInitSettings->ElementAt(i));
+    MOZ_ASSERT(gInitDomPrefs);
+    for (unsigned int i = 0; i < gInitDomPrefs->Length(); i++) {
+      Preferences::SetPreference(gInitDomPrefs->ElementAt(i));
     }
-    delete gInitSettings;
-    gInitSettings = nullptr;
+    delete gInitDomPrefs;
+    gInitDomPrefs = nullptr;
 
   } else {
     // Check if there is a deployment configuration file. If so, set up the
     // pref config machinery, which will actually read the file.
     nsAutoCString lockFileName;
     nsresult rv = Preferences::GetCString(
       "general.config.filename", lockFileName, PrefValueKind::User);
     if (NS_SUCCEEDED(rv)) {
@@ -3405,19 +3405,19 @@ NS_INTERFACE_MAP_BEGIN(Preferences)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
 NS_INTERFACE_MAP_END
 
 //
 // nsIPrefService Implementation
 //
 
 /* static */ void
-Preferences::SetInitPreferences(nsTArray<PrefSetting>* aSettings)
+Preferences::SetInitPreferences(nsTArray<dom::Pref>* aDomPrefs)
 {
-  gInitSettings = new InfallibleTArray<PrefSetting>(mozilla::Move(*aSettings));
+  gInitDomPrefs = new InfallibleTArray<dom::Pref>(mozilla::Move(*aDomPrefs));
 }
 
 /* static */ void
 Preferences::InitializeUserPrefs()
 {
   MOZ_ASSERT(!sPreferences->mCurrentFile, "Should only initialize prefs once");
 
   // Prefs which are set before we initialize the profile are silently
@@ -3606,21 +3606,21 @@ Preferences::SetValueFromDom(const char*
         aPrefName, aValue.get_bool(), aKind);
 
     default:
       MOZ_CRASH();
   }
 }
 
 void
-Preferences::SetPreference(const PrefSetting& aSetting)
+Preferences::SetPreference(const dom::Pref& aDomPref)
 {
-  const char* prefName = aSetting.name().get();
-  const dom::MaybePrefValue& defaultValue = aSetting.defaultValue();
-  const dom::MaybePrefValue& userValue = aSetting.userValue();
+  const char* prefName = aDomPref.name().get();
+  const dom::MaybePrefValue& defaultValue = aDomPref.defaultValue();
+  const dom::MaybePrefValue& userValue = aDomPref.userValue();
 
   if (defaultValue.type() == dom::MaybePrefValue::TPrefValue) {
     nsresult rv = SetValueFromDom(
       prefName, defaultValue.get_PrefValue(), PrefValueKind::Default);
     if (NS_FAILED(rv)) {
       return;
     }
   }
@@ -3631,34 +3631,34 @@ Preferences::SetPreference(const PrefSet
     Preferences::ClearUserInAnyProcess(prefName);
   }
 
   // NB: we should never try to clear a default value, that doesn't
   // make sense
 }
 
 void
-Preferences::GetPreference(PrefSetting* aSetting)
+Preferences::GetPreference(dom::Pref* aDomPref)
 {
-  PrefHashEntry* pref = pref_HashTableLookup(aSetting->name().get());
+  PrefHashEntry* pref = pref_HashTableLookup(aDomPref->name().get());
   if (pref && pref->HasAdvisablySizedValues()) {
-    pref->ToSetting(aSetting);
+    pref->ToDomPref(aDomPref);
   }
 }
 
 void
-Preferences::GetPreferences(InfallibleTArray<PrefSetting>* aSettings)
+Preferences::GetPreferences(InfallibleTArray<dom::Pref>* aDomPrefs)
 {
-  aSettings->SetCapacity(gHashTable->Capacity());
+  aDomPrefs->SetCapacity(gHashTable->Capacity());
   for (auto iter = gHashTable->Iter(); !iter.Done(); iter.Next()) {
     auto pref = static_cast<PrefHashEntry*>(iter.Get());
 
     if (pref->HasAdvisablySizedValues()) {
-      dom::PrefSetting* setting = aSettings->AppendElement();
-      pref->ToSetting(setting);
+      dom::Pref* setting = aDomPrefs->AppendElement();
+      pref->ToDomPref(setting);
     }
   }
 }
 
 #ifdef DEBUG
 void
 Preferences::SetInitPhase(pref_initPhase aPhase)
 {
--- a/modules/libpref/Preferences.h
+++ b/modules/libpref/Preferences.h
@@ -46,17 +46,17 @@ enum pref_initPhase
   } while (0)
 #endif
 
 class nsPrefBranch;
 
 namespace mozilla {
 
 namespace dom {
-class PrefSetting;
+class Pref;
 class PrefValue;
 } // namespace dom
 
 struct PrefsSizes;
 
 enum class PrefValueKind : bool
 {
   Default,
@@ -67,18 +67,16 @@ class Preferences final
   : public nsIPrefService
   , public nsIObserver
   , public nsIPrefBranch
   , public nsSupportsWeakReference
 {
   friend class ::nsPrefBranch;
 
 public:
-  typedef mozilla::dom::PrefSetting PrefSetting;
-
   NS_DECL_THREADSAFE_ISUPPORTS
   NS_DECL_NSIPREFSERVICE
   NS_FORWARD_NSIPREFBRANCH(mRootBranch->)
   NS_DECL_NSIOBSERVER
 
   Preferences();
 
   // Returns true if the Preferences service is available, false otherwise.
@@ -337,23 +335,23 @@ public:
                                         const char* aPref,
                                         uint32_t aDefault = 0);
   static nsresult AddFloatVarCache(float* aVariable,
                                    const char* aPref,
                                    float aDefault = 0.0f);
 
   // When a content process is created these methods are used to pass prefs in
   // bulk from the parent process.
-  static void GetPreferences(InfallibleTArray<PrefSetting>* aSettings);
-  static void SetInitPreferences(nsTArray<PrefSetting>* aSettings);
+  static void GetPreferences(InfallibleTArray<dom::Pref>* aSettings);
+  static void SetInitPreferences(nsTArray<dom::Pref>* aSettings);
 
   // When a pref is changed in the parent process, these methods are used to
   // pass the update to content processes.
-  static void GetPreference(PrefSetting* aPref);
-  static void SetPreference(const PrefSetting& aPref);
+  static void GetPreference(dom::Pref* aPref);
+  static void SetPreference(const dom::Pref& aPref);
 
 #ifdef DEBUG
   static void SetInitPhase(pref_initPhase phase);
   static pref_initPhase InitPhase();
 #endif
 
   static void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
                                      PrefsSizes& aSizes);