Bug 1524687: Part 11 - Convert browser modules to static registration. r=mossop
☠☠ backed out by 3b1b94e39795 ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Fri, 25 Jan 2019 16:41:53 -0800
changeset 458971 46e13c453538
parent 458970 614be688767f
child 458972 625f71135038
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 11 - Convert browser modules to static registration. r=mossop
browser/components/about/components.conf
browser/components/about/moz.build
browser/components/build/components.conf
browser/components/build/moz.build
browser/components/build/nsBrowserCompsCID.h
browser/components/build/nsModule.cpp
browser/components/shell/nsWindowsShellService.cpp
xpcom/components/nsComponentManager.cpp
new file mode 100644
--- /dev/null
+++ b/browser/components/about/components.conf
@@ -0,0 +1,40 @@
+# -*- 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/.
+
+pages = [
+    'blocked',
+    'certerror',
+    'config',
+    'downloads',
+    'home',
+    'library',
+    'newinstall',
+    'newtab',
+    'pocket-saved',
+    'pocket-signup',
+    'policies',
+    'preferences',
+    'privatebrowsing',
+    'reader',
+    'restartrequired',
+    'rights',
+    'robots',
+    'searchreset',
+    'sessionrestore',
+    'tabcrashed',
+    'welcome',
+    'welcomeback',
+]
+
+Classes = [
+    {
+        'cid': '{7e4bb6ad-2fc4-4dc6-89ef-23e8e5ccf980}',
+        'contract_ids': ['@mozilla.org/network/protocol/about;1?what=%s' % page
+                         for page in pages],
+        'legacy_constructor': 'mozilla::browser::AboutRedirector::Create',
+        'headers': ['/browser/components/about/AboutRedirector.h'],
+    },
+]
--- a/browser/components/about/moz.build
+++ b/browser/components/about/moz.build
@@ -12,16 +12,20 @@ EXPORTS.mozilla.browser += [
 ]
 
 XPCSHELL_TESTS_MANIFESTS += ['test/unit/xpcshell.ini']
 
 SOURCES += [
     'AboutRedirector.cpp',
 ]
 
+XPCOM_MANIFESTS += [
+    'components.conf',
+]
+
 EXTRA_JS_MODULES.aboutpages = [
     'AboutPrivateBrowsingHandler.jsm',
 ]
 
 FINAL_LIBRARY = 'browsercomps'
 
 LOCAL_INCLUDES += [
     '../build',
new file mode 100644
--- /dev/null
+++ b/browser/components/build/components.conf
@@ -0,0 +1,67 @@
+# -*- 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': '{6deb193c-f87d-4078-bc78-5e64655b4d62}',
+        'contract_ids': ['@mozilla.org/browser/directory-provider;1'],
+        'type': 'mozilla::browser::DirectoryProvider',
+        'headers': ['mozilla/browser/DirectoryProvider.h'],
+        'categories': {'xpcom-directory-providers': 'browser-directory-provider'},
+    },
+]
+
+TOOLKIT = buildconfig.substs['MOZ_WIDGET_TOOLKIT']
+
+shell_service_contracts = [
+    '@mozilla.org/browser/shell-service;1',
+    '@mozilla.org/toolkit/shell-service;1',
+]
+
+if TOOLKIT == 'gtk3':
+    Classes += [
+        {
+            'cid': '{63c7b9f4-0cc8-43f8-b666-0a661655cb73}',
+            'contract_ids': shell_service_contracts,
+            'type': 'nsGNOMEShellService',
+            'headers': ['/browser/components/shell/nsGNOMEShellService.h'],
+            'init_method': 'Init',
+        },
+    ]
+elif TOOLKIT == 'cocoa':
+    Classes += [
+        {
+            'cid': '{6fc66a78-6cbc-4b3f-b7ba-379289b29276}',
+            'contract_ids': ['@mozilla.org/mac-attribution;1'],
+            'type': 'nsMacAttributionService',
+            'headers': ['nsMacAttribution.h'],
+        },
+    ]
+
+if buildconfig.substs['OS_ARCH'] == 'Darwin':
+    Classes += [
+        {
+            'cid': '{63c7b9f4-0cc8-43f8-b666-0a661655cb73}',
+            'contract_ids': shell_service_contracts,
+            'type': 'nsMacShellService',
+            'headers': ['/browser/components/shell/nsMacShellService.h'],
+        },
+    ]
+elif buildconfig.substs['OS_ARCH'] == 'WINNT':
+    Classes += [
+        {
+            'cid': '{63c7b9f4-0cc8-43f8-b666-0a661655cb73}',
+            'contract_ids': shell_service_contracts,
+            'type': 'nsWindowsShellService',
+            'headers': ['/browser/components/shell/nsWindowsShellService.h'],
+        },
+        {
+            'cid': '{93480624-806e-4756-b7cb-0fb7dd746a8f}',
+            'contract_ids': ['@mozilla.org/profile/migrator/iehistoryenumerator;1'],
+            'type': 'nsIEHistoryEnumerator',
+            'headers': ['/browser/components/migration/nsIEHistoryEnumerator.h'],
+        },
+    ]
--- a/browser/components/build/moz.build
+++ b/browser/components/build/moz.build
@@ -2,22 +2,18 @@
 # 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/.
 
 with Files("**"):
     BUG_COMPONENT = ("Firefox Build System", "General")
 
-EXPORTS += [
-    'nsBrowserCompsCID.h',
-]
-
-SOURCES += [
-    'nsModule.cpp',
+XPCOM_MANIFESTS += [
+    'components.conf',
 ]
 
 Library('browsercomps')
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '../about',
     '../dirprovider',
--- a/browser/components/build/nsBrowserCompsCID.h
+++ b/browser/components/build/nsBrowserCompsCID.h
@@ -35,34 +35,15 @@
 // 136e2c4d-c5a4-477c-b131-d93d7d704f64
 #define NS_PRIVATE_BROWSING_SERVICE_WRAPPER_CID      \
   {                                                  \
     0x136e2c4d, 0xc5a4, 0x477c, {                    \
       0xb1, 0x31, 0xd9, 0x3d, 0x7d, 0x70, 0x4f, 0x64 \
     }                                                \
   }
 
-// 7e4bb6ad-2fc4-4dc6-89ef-23e8e5ccf980
-#define NS_BROWSER_ABOUT_REDIRECTOR_CID              \
-  {                                                  \
-    0x7e4bb6ad, 0x2fc4, 0x4dc6, {                    \
-      0x89, 0xef, 0x23, 0xe8, 0xe5, 0xcc, 0xf9, 0x80 \
-    }                                                \
-  }
-
 // {6DEB193C-F87D-4078-BC78-5E64655B4D62}
 #define NS_BROWSERDIRECTORYPROVIDER_CID              \
   {                                                  \
     0x6deb193c, 0xf87d, 0x4078, {                    \
       0xbc, 0x78, 0x5e, 0x64, 0x65, 0x5b, 0x4d, 0x62 \
     }                                                \
   }
-
-#if defined(MOZ_WIDGET_COCOA)
-#  define NS_MACATTRIBUTIONSERVICE_CONTRACTID "@mozilla.org/mac-attribution;1"
-
-#  define NS_MACATTRIBUTIONSERVICE_CID                 \
-    {                                                  \
-      0x6FC66A78, 0x6CBC, 0x4B3F, {                    \
-        0xB7, 0xBA, 0x37, 0x92, 0x89, 0xB2, 0x92, 0x76 \
-      }                                                \
-    }
-#endif
deleted file mode 100644
--- a/browser/components/build/nsModule.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/* -*- 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 "nsBrowserCompsCID.h"
-#include "DirectoryProvider.h"
-
-#if defined(XP_WIN)
-#  include "nsWindowsShellService.h"
-#elif defined(XP_MACOSX)
-#  include "nsMacShellService.h"
-#elif defined(MOZ_WIDGET_GTK)
-#  include "nsGNOMEShellService.h"
-#endif
-#include "nsIToolkitShellService.h"
-
-#if defined(MOZ_WIDGET_COCOA)
-#  include "nsMacAttribution.h"
-#endif
-
-#if defined(XP_WIN)
-#  include "nsIEHistoryEnumerator.h"
-#endif
-
-#include "AboutRedirector.h"
-#include "nsIAboutModule.h"
-
-#include "nsNetCID.h"
-
-using namespace mozilla::browser;
-
-/////////////////////////////////////////////////////////////////////////////
-
-NS_GENERIC_FACTORY_CONSTRUCTOR(DirectoryProvider)
-#if defined(XP_WIN)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindowsShellService)
-#elif defined(XP_MACOSX)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacShellService)
-#elif defined(MOZ_WIDGET_GTK)
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsGNOMEShellService, Init)
-#endif
-
-#if defined(MOZ_WIDGET_COCOA)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacAttributionService)
-#endif
-
-#if defined(XP_WIN)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsIEHistoryEnumerator)
-#endif
-
-NS_DEFINE_NAMED_CID(NS_BROWSERDIRECTORYPROVIDER_CID);
-#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || defined(XP_MACOSX)
-NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID);
-#endif
-NS_DEFINE_NAMED_CID(NS_BROWSER_ABOUT_REDIRECTOR_CID);
-#if defined(XP_WIN)
-NS_DEFINE_NAMED_CID(NS_WINIEHISTORYENUMERATOR_CID);
-#endif
-#if defined(MOZ_WIDGET_COCOA)
-NS_DEFINE_NAMED_CID(NS_MACATTRIBUTIONSERVICE_CID);
-#endif
-
-static const mozilla::Module::CIDEntry kBrowserCIDs[] = {
-    // clang-format off
-    { &kNS_BROWSERDIRECTORYPROVIDER_CID, false, nullptr, DirectoryProviderConstructor },
-#if defined(XP_WIN)
-    { &kNS_SHELLSERVICE_CID, false, nullptr, nsWindowsShellServiceConstructor },
-#elif defined(MOZ_WIDGET_GTK)
-    { &kNS_SHELLSERVICE_CID, false, nullptr, nsGNOMEShellServiceConstructor },
-#elif defined(XP_MACOSX)
-    { &kNS_SHELLSERVICE_CID, false, nullptr, nsMacShellServiceConstructor },
-#endif
-    { &kNS_BROWSER_ABOUT_REDIRECTOR_CID, false, nullptr, AboutRedirector::Create },
-#if defined(XP_WIN)
-    { &kNS_WINIEHISTORYENUMERATOR_CID, false, nullptr, nsIEHistoryEnumeratorConstructor },
-#endif
-#if defined(MOZ_WIDGET_COCOA)
-    { &kNS_MACATTRIBUTIONSERVICE_CID, false, nullptr, nsMacAttributionServiceConstructor },
-#endif
-    { nullptr }
-    // clang-format on
-};
-
-static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
-    // clang-format off
-    { NS_BROWSERDIRECTORYPROVIDER_CONTRACTID, &kNS_BROWSERDIRECTORYPROVIDER_CID },
-#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || defined(XP_MACOSX)
-    { NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
-    { NS_TOOLKITSHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
-#endif
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "blocked", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "certerror", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "config", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "tabcrashed", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "privatebrowsing", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "rights", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "robots", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "searchreset", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "sessionrestore", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "welcomeback", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "home", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "newtab", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "library", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "preferences", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "downloads", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "reader", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "restartrequired", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "welcome", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "policies", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "pocket-saved", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "pocket-signup", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-    { NS_ABOUT_MODULE_CONTRACTID_PREFIX "newinstall", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
-#if defined(XP_WIN)
-    { NS_IEHISTORYENUMERATOR_CONTRACTID, &kNS_WINIEHISTORYENUMERATOR_CID },
-#endif
-#if defined(MOZ_WIDGET_COCOA)
-    { NS_MACATTRIBUTIONSERVICE_CONTRACTID, &kNS_MACATTRIBUTIONSERVICE_CID },
-#endif
-    { nullptr }
-    // clang-format on
-};
-
-static const mozilla::Module::CategoryEntry kBrowserCategories[] = {
-    {XPCOM_DIRECTORY_PROVIDER_CATEGORY, "browser-directory-provider",
-     NS_BROWSERDIRECTORYPROVIDER_CONTRACTID},
-    {nullptr}};
-
-static const mozilla::Module kBrowserModule = {mozilla::Module::kVersion,
-                                               kBrowserCIDs, kBrowserContracts,
-                                               kBrowserCategories};
-
-NSMODULE_DEFN(nsBrowserCompsModule) = &kBrowserModule;
--- a/browser/components/shell/nsWindowsShellService.cpp
+++ b/browser/components/shell/nsWindowsShellService.cpp
@@ -16,17 +16,16 @@
 #include "nsIPrefLocalizedString.h"
 #include "nsIServiceManager.h"
 #include "nsIStringBundle.h"
 #include "nsNetUtil.h"
 #include "nsServiceManagerUtils.h"
 #include "nsShellService.h"
 #include "nsIProcess.h"
 #include "nsICategoryManager.h"
-#include "nsBrowserCompsCID.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsIWindowsRegKey.h"
 #include "nsUnicharUtils.h"
 #include "nsIURLFormatter.h"
 #include "nsXULAppAPI.h"
 #include "mozilla/WindowsVersion.h"
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -333,17 +333,17 @@ nsresult nsComponentManagerImpl::Create(
 
   if (!gComponentManager) {
     return NS_ERROR_FAILURE;
   }
 
   return gComponentManager->QueryInterface(aIID, aResult);
 }
 
-static const int CONTRACTID_HASHTABLE_INITIAL_LENGTH = 256;
+static const int CONTRACTID_HASHTABLE_INITIAL_LENGTH = 128;
 
 nsComponentManagerImpl::nsComponentManagerImpl()
     : mFactories(CONTRACTID_HASHTABLE_INITIAL_LENGTH),
       mContractIDs(CONTRACTID_HASHTABLE_INITIAL_LENGTH),
       mLock("nsComponentManagerImpl.mLock"),
       mStatus(NOT_INITIALIZED) {}
 
 static nsTArray<const mozilla::Module*>* sExtraStaticModules;