Bug 1524687: Part 2 - Convert most of the embedding module to static registration. r=mossop
☠☠ backed out by 3b1b94e39795 ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Thu, 24 Jan 2019 15:32:56 -0800
changeset 458962 10c69df4444d
parent 458961 219b84a58f50
child 458963 df95a56dae04
push id111908
push usermaglione.k@gmail.com
push dateThu, 14 Feb 2019 02:29:45 +0000
treeherdermozilla-inbound@625f71135038 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmossop
bugs1524687
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524687: Part 2 - Convert most of the embedding module to static registration. r=mossop Differential Revision: https://phabricator.services.mozilla.com/D18397
chrome/test/unit/test_data_protocol_registration.js
chrome/test/unit/test_no_remote_registration.js
toolkit/xre/components.conf
toolkit/xre/moz.build
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsAppRunner.h
toolkit/xre/nsEmbeddingModule.cpp
--- a/chrome/test/unit/test_data_protocol_registration.js
+++ b/chrome/test/unit/test_data_protocol_registration.js
@@ -50,17 +50,16 @@ function run_test() {
       // to be restored later and register the new one.
       if (registrar.isContractIDRegistered(factory.contractID)) {
         dump(factory.scheme + " is already registered. Storing currently registered object for restoration later.");
         old_factories.push({
           CID: registrar.contractIDToCID(factory.contractID),
           factory: Components.manager.getClassObject(Cc[factory.contractID], Ci.nsIFactory),
         });
         old_factories_inds.push(true);
-        registrar.unregisterFactory(old_factories[i].CID, old_factories[i].factory);
       } else {
         dump(factory.scheme + " has never been registered. Registering...");
         old_factories.push({CID: "", factory: null});
         old_factories_inds.push(false);
       }
 
       registrar.registerFactory(factory.CID, "test-" + factory.scheme, factory.contractID, factory);
     } else {
@@ -90,12 +89,12 @@ function run_test() {
   // Unregister our factories so we do not leak
   for (let i = 0; i < factories.length; i++) {
     let factory = factories[i];
     let ind = old_factories_inds[i];
     registrar.unregisterFactory(factory.CID, factory);
 
     if (ind) {
       let old_factory = old_factories[i];
-      registrar.registerFactory(old_factory.CID, factory.scheme, factory.contractID, old_factory.factory);
+      registrar.registerFactory(old_factory.CID, factory.scheme, factory.contractID, null);
     }
   }
 }
--- a/chrome/test/unit/test_no_remote_registration.js
+++ b/chrome/test/unit/test_no_remote_registration.js
@@ -120,17 +120,16 @@ function run_test() {
   if (!registrar.isCIDRegistered(XULAppInfoFactory.CID)) {
     // Check to see if a contract was already registered and
     // register it if it is not. Otherwise, store the previous one
     // to be restored later and register the new one.
     if (registrar.isContractIDRegistered(XULAppInfoFactory.contractID)) {
       dump(XULAppInfoFactory.scheme + " is already registered. Storing currently registered object for restoration later.");
       old_factory.CID = registrar.contractIDToCID(XULAppInfoFactory.contractID);
       old_factory.factory = Components.manager.getClassObject(Cc[XULAppInfoFactory.contractID], Ci.nsIFactory);
-      registrar.unregisterFactory(old_factory.CID, old_factory.factory);
     } else {
       dump(XULAppInfoFactory.scheme + " has never been registered. Registering...");
     }
 
     registrar.registerFactory(XULAppInfoFactory.CID, "test-" + XULAppInfoFactory.scheme, XULAppInfoFactory.contractID, XULAppInfoFactory);
   } else {
     do_throw("CID " + XULAppInfoFactory.CID + " has already been registered!");
   }
@@ -209,11 +208,11 @@ function run_test() {
   for (let i = 0; i < factories.length; i++) {
     let factory = factories[i];
     registrar.unregisterFactory(factory.CID, factory);
   }
 
   // Unregister XULAppInfoFactory
   registrar.unregisterFactory(XULAppInfoFactory.CID, XULAppInfoFactory);
   if (old_factory.factory != null) {
-    registrar.registerFactory(old_factory.CID, "", XULAppInfoFactory.contractID, old_factory.factory);
+    registrar.registerFactory(old_factory.CID, "", XULAppInfoFactory.contractID, null);
   }
 }
new file mode 100644
--- /dev/null
+++ b/toolkit/xre/components.conf
@@ -0,0 +1,54 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+Classes = [
+    {
+        'cid': '{95d89e3e-a169-41a3-8e56-719978e15b12}',
+        'contract_ids': [
+            '@mozilla.org/xre/app-info;1',
+            '@mozilla.org/xre/runtime;1',
+        ],
+        'legacy_constructor': 'mozilla::AppInfoConstructor',
+        'headers': ['nsAppRunner.h'],
+    },
+    {
+        'cid': '{471f4944-1dd2-11b2-87ac-90be0a51d609}',
+        'contract_ids': ['@mozilla.org/embedcomp/rangefind;1'],
+        'type': 'nsFind',
+        'headers': ['/toolkit/components/find/nsFind.h'],
+    },
+    {
+        'cid': '{7e677795-c582-4cd1-9e8d-8271b3474d2a}',
+        'contract_ids': ['@mozilla.org/embedding/browser/nsWebBrowserPersist;1'],
+        'type': 'nsWebBrowserPersist',
+        'headers': ['/dom/webbrowserpersist/nsWebBrowserPersist.h'],
+    },
+    {
+        'cid': '{a21bfa01-f349-4394-a84c-8de5cf0737d0}',
+        'contract_ids': ['@mozilla.org/embedcomp/window-watcher;1'],
+        'type': 'nsWindowWatcher',
+        'headers': ['nsWindowWatcher.h'],
+        'init_method': 'Init',
+    },
+    {
+        'cid': '{5573967d-f6cf-4c63-8e0e-9ac06e04d62b}',
+        'contract_ids': ['@mozilla.org/xre/directory-provider;1'],
+        'singleton': True,
+        'type': 'nsXREDirProvider',
+        'constructor': 'nsXREDirProvider::GetSingleton',
+        'headers': ['/toolkit/xre/nsXREDirProvider.h'],
+    },
+]
+
+if defined('MOZ_XUL'):
+    Classes += [
+        {
+            'cid': '{4e4aae11-8901-46cc-8217-dad7c5415873}',
+            'contract_ids': ['@mozilla.org/embedcomp/dialogparam;1'],
+            'type': 'nsDialogParamBlock',
+            'headers': ['/toolkit/components/windowwatcher/nsDialogParamBlock.h'],
+        },
+    ]
--- a/toolkit/xre/moz.build
+++ b/toolkit/xre/moz.build
@@ -153,16 +153,20 @@ if CONFIG['MOZ_UPDATER']:
         ]
 
 if CONFIG['MOZ_PDF_PRINTING']:
     DEFINES['PROXY_PRINTING'] = 1
     LOCAL_INCLUDES += [
         '../components/printingui',
     ]
 
+XPCOM_MANIFESTS += [
+    'components.conf',
+]
+
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 
 if CONFIG['MOZ_X11']:
     DEFINES['USE_GLX_TEST'] = True
 
 for var in ('MOZ_APP_NAME', 'MOZ_APP_BASENAME', 'MOZ_APP_DISPLAYNAME',
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -1243,22 +1243,24 @@ nsXULAppInfo::Callback(nsISupports* aDat
   nsCOMPtr<nsIFile> file = do_QueryInterface(aData);
   MOZ_ASSERT(file);
 
   CrashReporter::SetMemoryReportFile(file);
   return NS_OK;
 }
 
 static const nsXULAppInfo kAppInfo;
-static nsresult AppInfoConstructor(nsISupports* aOuter, REFNSIID aIID,
-                                   void** aResult) {
+namespace mozilla {
+nsresult AppInfoConstructor(nsISupports* aOuter, REFNSIID aIID,
+                            void** aResult) {
   NS_ENSURE_NO_AGGREGATION(aOuter);
 
   return const_cast<nsXULAppInfo*>(&kAppInfo)->QueryInterface(aIID, aResult);
 }
+}  // namespace mozilla
 
 bool gLogConsoleErrors = false;
 
 #define NS_ENSURE_TRUE_LOG(x, ret)               \
   PR_BEGIN_MACRO                                 \
   if (MOZ_UNLIKELY(!(x))) {                      \
     NS_WARNING("NS_ENSURE_TRUE(" #x ") failed"); \
     gLogConsoleErrors = true;                    \
--- a/toolkit/xre/nsAppRunner.h
+++ b/toolkit/xre/nsAppRunner.h
@@ -46,16 +46,21 @@ extern char** gArgv;
 extern int gRestartArgc;
 extern char** gRestartArgv;
 extern bool gRestartedByOS;
 extern bool gLogConsoleErrors;
 extern nsString gAbsoluteArgv0Path;
 
 extern bool gIsGtest;
 
+namespace mozilla {
+nsresult AppInfoConstructor(nsISupports* aOuter, const nsID& aIID,
+                            void** aResult);
+}  // namespace mozilla
+
 /**
  * Create the nativeappsupport implementation.
  *
  * @note XPCOMInit has not happened yet.
  */
 nsresult NS_CreateNativeAppSupport(nsINativeAppSupport** aResult);
 already_AddRefed<nsINativeAppSupport> NS_GetNativeAppSupport();
 
--- a/toolkit/xre/nsEmbeddingModule.cpp
+++ b/toolkit/xre/nsEmbeddingModule.cpp
@@ -1,88 +1,45 @@
 /* -*- Mode: C++; tab-width: 4; 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 "nsDialogParamBlock.h"
-#include "nsWindowWatcher.h"
-#include "nsFind.h"
-#include "nsWebBrowserPersist.h"
-#include "nsNetCID.h"
-#include "nsEmbedCID.h"
-#include "nsXREDirProvider.h"
 
-#ifdef NS_PRINTING
+#if defined(MOZ_XUL) && defined(NS_PRINTING)
 #  include "nsPrintingPromptService.h"
 #  include "nsPrintingProxy.h"
-#endif
 
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWindowWatcher, Init)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsFind)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsWebBrowserPersist)
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsXREDirProvider,
-                                         nsXREDirProvider::GetSingleton)
-
-#ifdef MOZ_XUL
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsDialogParamBlock)
-#  ifdef NS_PRINTING
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPrintingPromptService,
                                          nsPrintingPromptService::GetSingleton)
-#    ifdef PROXY_PRINTING
+#  ifdef PROXY_PRINTING
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPrintingProxy,
                                          nsPrintingProxy::GetInstance)
-#    endif
 #  endif
+
+NS_DEFINE_NAMED_CID(NS_PRINTINGPROMPTSERVICE_CID);
 #endif
 
-#ifdef MOZ_XUL
-NS_DEFINE_NAMED_CID(NS_DIALOGPARAMBLOCK_CID);
-#  ifdef NS_PRINTING
-NS_DEFINE_NAMED_CID(NS_PRINTINGPROMPTSERVICE_CID);
-#  endif
-#endif
-NS_DEFINE_NAMED_CID(NS_WINDOWWATCHER_CID);
-NS_DEFINE_NAMED_CID(NS_FIND_CID);
-NS_DEFINE_NAMED_CID(NS_WEBBROWSERPERSIST_CID);
-NS_DEFINE_NAMED_CID(NS_XREDIRPROVIDER_CID);
-
 static const mozilla::Module::CIDEntry kEmbeddingCIDs[] = {
-#ifdef MOZ_XUL
-    {&kNS_DIALOGPARAMBLOCK_CID, false, nullptr, nsDialogParamBlockConstructor},
-#  ifdef NS_PRINTING
-
-#    ifdef PROXY_PRINTING
+#if defined(MOZ_XUL) && defined(NS_PRINTING)
+#  ifdef PROXY_PRINTING
     {&kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr,
      nsPrintingPromptServiceConstructor, mozilla::Module::MAIN_PROCESS_ONLY},
     {&kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr, nsPrintingProxyConstructor,
      mozilla::Module::CONTENT_PROCESS_ONLY},
-#    else
+#  else
     {&kNS_PRINTINGPROMPTSERVICE_CID, false, nullptr,
      nsPrintingPromptServiceConstructor},
-#    endif
 #  endif
 #endif
-    {&kNS_WINDOWWATCHER_CID, false, nullptr, nsWindowWatcherConstructor},
-    {&kNS_FIND_CID, false, nullptr, nsFindConstructor},
-    {&kNS_WEBBROWSERPERSIST_CID, false, nullptr,
-     nsWebBrowserPersistConstructor},
-    {&kNS_XREDIRPROVIDER_CID, false, nullptr, nsXREDirProviderConstructor},
     {nullptr}};
 
 static const mozilla::Module::ContractIDEntry kEmbeddingContracts[] = {
-#ifdef MOZ_XUL
-    {NS_DIALOGPARAMBLOCK_CONTRACTID, &kNS_DIALOGPARAMBLOCK_CID},
-#  ifdef NS_PRINTING
+#if defined(MOZ_XUL) && defined(NS_PRINTING)
     {NS_PRINTINGPROMPTSERVICE_CONTRACTID, &kNS_PRINTINGPROMPTSERVICE_CID},
-#  endif
 #endif
-    {NS_WINDOWWATCHER_CONTRACTID, &kNS_WINDOWWATCHER_CID},
-    {NS_FIND_CONTRACTID, &kNS_FIND_CID},
-    {NS_WEBBROWSERPERSIST_CONTRACTID, &kNS_WEBBROWSERPERSIST_CID},
-    {NS_XREDIRPROVIDER_CONTRACTID, &kNS_XREDIRPROVIDER_CID},
     {nullptr}};
 
 static const mozilla::Module kEmbeddingModule = {
     mozilla::Module::kVersion, kEmbeddingCIDs, kEmbeddingContracts};
 
 NSMODULE_DEFN(embedcomponents) = &kEmbeddingModule;