Bug 1407112 (part 1) - Merge nsPrefsFactory.cpp into Preferences.cpp. r=glandium. draft
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 10 Oct 2017 16:12:50 +1100
changeset 677124 9b386a41822d3582cc2df517171796bca32fb156
parent 677123 d16958d3126b9dea70ee9849779fd4afc41ff0ac
child 677125 8f60740b1bb7ec2ef3da464fcdc21805b8744f9b
push id83701
push usernnethercote@mozilla.com
push dateTue, 10 Oct 2017 05:22:10 +0000
reviewersglandium
bugs1407112
milestone58.0a1
Bug 1407112 (part 1) - Merge nsPrefsFactory.cpp into Preferences.cpp. r=glandium. MozReview-Commit-ID: V1tONOw0wT
modules/libpref/Preferences.cpp
modules/libpref/moz.build
modules/libpref/nsPrefsFactory.cpp
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "GeckoProfiler.h"
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/PContent.h"
 #include "mozilla/HashFunctions.h"
 #include "mozilla/MemoryReporting.h"
+#include "mozilla/ModuleUtils.h"
 #include "mozilla/Omnijar.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ResultExtensions.h"
 #include "mozilla/ScopeExit.h"
 #include "mozilla/ServoStyleSet.h"
 #include "mozilla/SyncRunnable.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/UniquePtrExtensions.h"
@@ -80,16 +81,20 @@ public:
   if (MOZ_UNLIKELY(!XRE_IsParentProcess())) {                                  \
     return NS_ERROR_NOT_AVAILABLE;                                             \
   }
 
 #define WATCHING_PREF_RAII()
 
 #endif // DEBUG
 
+//===========================================================================
+// Core prefs code
+//===========================================================================
+
 class PrefCallback;
 
 namespace mozilla {
 
 #define INITIAL_PREF_FILES 10
 
 static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
 
@@ -2296,8 +2301,56 @@ Preferences::GetDefaultType(const char* 
   return NS_SUCCEEDED(sDefaultRootBranch->GetPrefType(aPref, &result))
            ? result
            : nsIPrefBranch::PREF_INVALID;
 }
 
 } // namespace mozilla
 
 #undef ENSURE_MAIN_PROCESS
+
+//===========================================================================
+// Module and factory stuff
+//===========================================================================
+
+NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(Preferences,
+                                         Preferences::GetInstanceForService)
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefLocalizedString, Init)
+NS_GENERIC_FACTORY_CONSTRUCTOR(nsRelativeFilePref)
+
+static NS_DEFINE_CID(kPrefServiceCID, NS_PREFSERVICE_CID);
+static NS_DEFINE_CID(kPrefLocalizedStringCID, NS_PREFLOCALIZEDSTRING_CID);
+static NS_DEFINE_CID(kRelativeFilePrefCID, NS_RELATIVEFILEPREF_CID);
+
+static mozilla::Module::CIDEntry kPrefCIDs[] = {
+  { &kPrefServiceCID, true, nullptr, PreferencesConstructor },
+  { &kPrefLocalizedStringCID,
+    false,
+    nullptr,
+    nsPrefLocalizedStringConstructor },
+  { &kRelativeFilePrefCID, false, nullptr, nsRelativeFilePrefConstructor },
+  { nullptr }
+};
+
+static mozilla::Module::ContractIDEntry kPrefContracts[] = {
+  { NS_PREFSERVICE_CONTRACTID, &kPrefServiceCID },
+  { NS_PREFLOCALIZEDSTRING_CONTRACTID, &kPrefLocalizedStringCID },
+  { NS_RELATIVEFILEPREF_CONTRACTID, &kRelativeFilePrefCID },
+  // compatibility for extension that uses old service
+  { "@mozilla.org/preferences;1", &kPrefServiceCID },
+  { nullptr }
+};
+
+static void
+UnloadPrefsModule()
+{
+  Preferences::Shutdown();
+}
+
+static const mozilla::Module kPrefModule = { mozilla::Module::kVersion,
+                                             kPrefCIDs,
+                                             kPrefContracts,
+                                             nullptr,
+                                             nullptr,
+                                             nullptr,
+                                             UnloadPrefsModule };
+
+NSMODULE_DEFN(nsPrefModule) = &kPrefModule;
--- a/modules/libpref/moz.build
+++ b/modules/libpref/moz.build
@@ -25,17 +25,16 @@ XPIDL_SOURCES += [
 XPIDL_MODULE = 'pref'
 
 EXPORTS.mozilla += [
     'Preferences.h',
 ]
 
 UNIFIED_SOURCES += [
     'nsPrefBranch.cpp',
-    'nsPrefsFactory.cpp',
     'prefapi.cpp',
     'Preferences.cpp',
     'prefread.cpp',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
deleted file mode 100644
--- a/modules/libpref/nsPrefsFactory.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "mozilla/ModuleUtils.h"
-#include "mozilla/Preferences.h"
-#include "nsPrefBranch.h"
-#include "prefapi.h"
-
-using namespace mozilla;
-
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(Preferences,
-                                         Preferences::GetInstanceForService)
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefLocalizedString, Init)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsRelativeFilePref)
-
-static NS_DEFINE_CID(kPrefServiceCID, NS_PREFSERVICE_CID);
-static NS_DEFINE_CID(kPrefLocalizedStringCID, NS_PREFLOCALIZEDSTRING_CID);
-static NS_DEFINE_CID(kRelativeFilePrefCID, NS_RELATIVEFILEPREF_CID);
-
-static mozilla::Module::CIDEntry kPrefCIDs[] = {
-  { &kPrefServiceCID, true, nullptr, PreferencesConstructor },
-  { &kPrefLocalizedStringCID,
-    false,
-    nullptr,
-    nsPrefLocalizedStringConstructor },
-  { &kRelativeFilePrefCID, false, nullptr, nsRelativeFilePrefConstructor },
-  { nullptr }
-};
-
-static mozilla::Module::ContractIDEntry kPrefContracts[] = {
-  { NS_PREFSERVICE_CONTRACTID, &kPrefServiceCID },
-  { NS_PREFLOCALIZEDSTRING_CONTRACTID, &kPrefLocalizedStringCID },
-  { NS_RELATIVEFILEPREF_CONTRACTID, &kRelativeFilePrefCID },
-  // compatibility for extension that uses old service
-  { "@mozilla.org/preferences;1", &kPrefServiceCID },
-  { nullptr }
-};
-
-static void
-UnloadPrefsModule()
-{
-  Preferences::Shutdown();
-}
-
-static const mozilla::Module kPrefModule = { mozilla::Module::kVersion,
-                                             kPrefCIDs,
-                                             kPrefContracts,
-                                             nullptr,
-                                             nullptr,
-                                             nullptr,
-                                             UnloadPrefsModule };
-
-NSMODULE_DEFN(nsPrefModule) = &kPrefModule;