Bug 1478124: Part 8b - Update DocShell module to use a static component manifest. r=bzbarsky
☠☠ backed out by 1e042fc7de3d ☠ ☠
authorKris Maglione <maglione.k@gmail.com>
Sun, 16 Dec 2018 17:27:58 -0800
changeset 455929 b0444e0bc801f828b49f9953a73498cf5ff5024b
parent 455928 d94039b199437180309264cb4c206ae7ebb7d21d
child 455930 21f4fda0315963e42bae8784c63116f00ee0fa92
push id35463
push usershindli@mozilla.com
push dateTue, 29 Jan 2019 21:38:17 +0000
treeherdermozilla-central@4440fbf71c72 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1478124
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 1478124: Part 8b - Update DocShell module to use a static component manifest. r=bzbarsky Differential Revision: https://phabricator.services.mozilla.com/D15040
accessible/base/DocManager.cpp
caps/nsScriptSecurityManager.cpp
docshell/base/ChildProcessChannelListener.h
docshell/base/moz.build
docshell/base/nsAboutRedirector.h
docshell/base/nsCDefaultURIFixup.idl
docshell/base/nsDocShell.cpp
docshell/base/nsWebNavigationInfo.h
docshell/build/components.conf
docshell/build/moz.build
docshell/build/nsDocShellModule.cpp
docshell/build/nsDocShellModule.h
docshell/shistory/nsISHEntry.idl
dom/base/Link.cpp
dom/base/Location.cpp
dom/base/nsContentSink.cpp
dom/base/nsContentUtils.cpp
dom/base/nsGlobalWindowInner.cpp
dom/base/nsGlobalWindowOuter.cpp
dom/base/nsObjectLoadingContent.cpp
dom/html/nsHTMLDNSPrefetch.cpp
dom/ipc/ContentParent.cpp
dom/ipc/TabChild.cpp
dom/offline/nsDOMOfflineResourceList.cpp
dom/security/nsContentSecurityManager.cpp
dom/system/nsOSPermissionRequestBase.h
layout/printing/nsPrintJob.cpp
uriloader/base/nsCURILoader.idl
uriloader/base/nsDocLoader.cpp
uriloader/base/nsURILoader.cpp
uriloader/exthandler/ContentHandlerService.h
uriloader/exthandler/android/nsExternalURLHandlerService.h
uriloader/exthandler/mac/nsOSHelperAppService.h
uriloader/exthandler/moz.build
uriloader/exthandler/nsCExternalHandlerService.idl
uriloader/exthandler/nsDBusHandlerApp.cpp
uriloader/exthandler/unix/nsOSHelperAppService.h
uriloader/exthandler/win/nsOSHelperAppService.h
uriloader/prefetch/moz.build
uriloader/prefetch/nsCPrefetchService.h
uriloader/prefetch/nsOfflineCacheUpdate.cpp
uriloader/prefetch/nsOfflineCacheUpdateService.cpp
uriloader/prefetch/nsPrefetchService.cpp
uriloader/prefetch/nsPrefetchService.h
widget/android/nsAppShell.cpp
xpfe/appshell/nsContentTreeOwner.cpp
--- a/accessible/base/DocManager.cpp
+++ b/accessible/base/DocManager.cpp
@@ -15,20 +15,20 @@
 #include "Platform.h"
 #include "RootAccessibleWrap.h"
 #include "xpcAccessibleDocument.h"
 
 #ifdef A11Y_LOG
 #  include "Logging.h"
 #endif
 
+#include "mozilla/Components.h"
 #include "mozilla/EventListenerManager.h"
 #include "mozilla/dom/Event.h"  // for Event
 #include "nsContentUtils.h"
-#include "nsCURILoader.h"
 #include "nsDocShellLoadTypes.h"
 #include "nsIChannel.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIWebNavigation.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIWebProgress.h"
 #include "nsCoreUtils.h"
 #include "nsXULAppAPI.h"
@@ -166,30 +166,28 @@ bool DocManager::IsProcessingRefreshDriv
   return false;
 }
 #endif
 
 ////////////////////////////////////////////////////////////////////////////////
 // DocManager protected
 
 bool DocManager::Init() {
-  nsCOMPtr<nsIWebProgress> progress =
-      do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIWebProgress> progress = components::DocLoader::Service();
 
   if (!progress) return false;
 
   progress->AddProgressListener(static_cast<nsIWebProgressListener*>(this),
                                 nsIWebProgress::NOTIFY_STATE_DOCUMENT);
 
   return true;
 }
 
 void DocManager::Shutdown() {
-  nsCOMPtr<nsIWebProgress> progress =
-      do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIWebProgress> progress = components::DocLoader::Service();
 
   if (progress)
     progress->RemoveProgressListener(
         static_cast<nsIWebProgressListener*>(this));
 
   ClearDocCache();
 }
 
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -48,21 +48,21 @@
 #include "nsIWindowWatcher.h"
 #include "nsIConsoleService.h"
 #include "nsIOService.h"
 #include "nsIContent.h"
 #include "nsDOMJSUtils.h"
 #include "nsAboutProtocolUtils.h"
 #include "nsIClassInfo.h"
 #include "nsIURIFixup.h"
-#include "nsCDefaultURIFixup.h"
 #include "nsIChromeRegistry.h"
 #include "nsIResProtocolHandler.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
+#include "mozilla/Components.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/NullPrincipal.h"
 #include <stdint.h>
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/ClearOnShutdown.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/dom/WorkerCommon.h"
@@ -1132,17 +1132,17 @@ nsScriptSecurityManager::CheckLoadURIStr
     // return values.
     return rv;
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Now start testing fixup -- since aTargetURIStr is a string, not
   // an nsIURI, we may well end up fixing it up before loading.
   // Note: This needs to stay in sync with the nsIURIFixup api.
-  nsCOMPtr<nsIURIFixup> fixup = do_GetService(NS_URIFIXUP_CONTRACTID);
+  nsCOMPtr<nsIURIFixup> fixup = components::URIFixup::Service();
   if (!fixup) {
     return rv;
   }
 
   uint32_t flags[] = {nsIURIFixup::FIXUP_FLAG_NONE,
                       nsIURIFixup::FIXUP_FLAG_FIX_SCHEME_TYPOS,
                       nsIURIFixup::FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP,
                       nsIURIFixup::FIXUP_FLAGS_MAKE_ALTERNATE_URI,
--- a/docshell/base/ChildProcessChannelListener.h
+++ b/docshell/base/ChildProcessChannelListener.h
@@ -33,21 +33,12 @@ class ChildProcessChannelListener final
 
  private:
   virtual ~ChildProcessChannelListener();
 
   nsDataHashtable<nsUint64HashKey, Callback> mCallbacks;
   nsDataHashtable<nsUint64HashKey, nsCOMPtr<nsIChildChannel>> mChannels;
 };
 
-#define NS_CHILDPROCESSCHANNELLISTENER_CID           \
-  {                                                  \
-    0x397b43f3, 0x1470, 0x4542, {                    \
-      0x8a, 0x40, 0xc7, 0x18, 0xf7, 0x75, 0x35, 0x63 \
-    }                                                \
-  }
-#define NS_CHILDPROCESSCHANNELLISTENER_CONTRACTID \
-  "@mozilla.org/network/childProcessChannelListener;1"
-
 }  // namespace dom
 }  // namespace mozilla
 
 #endif  // !defined(mozilla_dom_ChildProcessChannelListener_h)
--- a/docshell/base/moz.build
+++ b/docshell/base/moz.build
@@ -31,17 +31,16 @@ with Files('nsILinkHandler.*'):
 with Files('nsIScrollObserver.*'):
     BUG_COMPONENT = ('Core', 'Panning and Zooming')
 
 DIRS += [
     'timeline',
 ]
 
 XPIDL_SOURCES += [
-    'nsCDefaultURIFixup.idl',
     'nsIContentViewer.idl',
     'nsIContentViewerEdit.idl',
     'nsIDocShell.idl',
     'nsIDocShellTreeItem.idl',
     'nsIDocShellTreeOwner.idl',
     'nsIDocumentLoaderFactory.idl',
     'nsILoadContext.idl',
     'nsILoadURIDelegate.idl',
--- a/docshell/base/nsAboutRedirector.h
+++ b/docshell/base/nsAboutRedirector.h
@@ -18,17 +18,9 @@ class nsAboutRedirector : public nsIAbou
   nsAboutRedirector() {}
 
   static nsresult Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
 
  protected:
   virtual ~nsAboutRedirector() {}
 };
 
-/* 56ebedd4-6ccf-48e8-bdae-adc77f044567 */
-#define NS_ABOUT_REDIRECTOR_MODULE_CID               \
-  {                                                  \
-    0x56ebedd4, 0x6ccf, 0x48e8, {                    \
-      0xbd, 0xae, 0xad, 0xc7, 0x7f, 0x04, 0x45, 0x67 \
-    }                                                \
-  }
-
 #endif  // nsAboutRedirector_h__
deleted file mode 100644
--- a/docshell/base/nsCDefaultURIFixup.idl
+++ /dev/null
@@ -1,13 +0,0 @@
-/* -*- Mode: IDL; 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/. */
-
-%{ C++
-// {214C48A0-B57F-11d4-959C-0020183BF181}
-#define NS_DEFAULTURIFIXUP_CID \
-{ 0x214c48a0, 0xb57f, 0x11d4, { 0x95, 0x9c, 0x0, 0x20, 0x18, 0x3b, 0xf1, 0x81 } }
-#define NS_URIFIXUP_CONTRACTID \
-"@mozilla.org/docshell/urifixup;1"
-%}
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -15,16 +15,17 @@
 #  include <unistd.h>  // for getpid()
 #endif
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/Casting.h"
+#include "mozilla/Components.h"
 #include "mozilla/Encoding.h"
 #include "mozilla/EventStateManager.h"
 #include "mozilla/HTMLEditor.h"
 #include "mozilla/LoadInfo.h"
 #include "mozilla/Logging.h"
 #include "mozilla/MediaFeatureChange.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/ResultExtensions.h"
@@ -155,17 +156,16 @@
 #include "IHistory.h"
 #include "IUrlClassifierUITelemetry.h"
 
 #include "mozIThirdPartyUtil.h"
 
 #include "nsArray.h"
 #include "nsArrayUtils.h"
 #include "nsAutoPtr.h"
-#include "nsCDefaultURIFixup.h"
 #include "nsCExternalHandlerService.h"
 #include "nsContentDLF.h"
 #include "nsContentPolicyUtils.h"  // NS_CheckContentLoadPolicy(...)
 #include "nsContentSecurityManager.h"
 #include "nsContentUtils.h"
 #include "nsCURILoader.h"
 #include "nsDocShellCID.h"
 #include "nsDocShellEditorData.h"
@@ -394,17 +394,18 @@ nsDocShell::nsDocShell(BrowsingContext* 
   AssertOriginAttributesMatchPrivateBrowsing();
 
   nsContentUtils::GenerateUUIDInPlace(mHistoryID);
 
   if (gDocShellCount++ == 0) {
     NS_ASSERTION(sURIFixup == nullptr,
                  "Huh, sURIFixup not null in first nsDocShell ctor!");
 
-    CallGetService(NS_URIFIXUP_CONTRACTID, &sURIFixup);
+    nsCOMPtr<nsIURIFixup> uriFixup = components::URIFixup::Service();
+    uriFixup.forget(&sURIFixup);
   }
 
   MOZ_LOG(gDocShellLeakLog, LogLevel::Debug, ("DOCSHELL %p created\n", this));
 
 #ifdef DEBUG
   // We're counting the number of |nsDocShells| to help find leaks
   ++gNumberOfDocShells;
   if (!PR_GetEnv("MOZ_QUIET")) {
@@ -9623,23 +9624,22 @@ nsresult nsDocShell::DoURILoad(nsDocShel
   // Double-check that we're still around to load this URI.
   if (mIsBeingDestroyed) {
     // Return NS_OK despite not doing anything to avoid throwing exceptions
     // from nsLocation::SetHref if the unload handler of the existing page
     // tears us down.
     return NS_OK;
   }
 
+  nsCOMPtr<nsIURILoader> uriLoader = components::URILoader::Service();
+  if (NS_WARN_IF(!uriLoader)) {
+    return NS_ERROR_UNEXPECTED;
+  }
+
   nsresult rv;
-  nsCOMPtr<nsIURILoader> uriLoader =
-      do_GetService(NS_URI_LOADER_CONTRACTID, &rv);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
   if (IsFrame()) {
     MOZ_ASSERT(aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_IFRAME ||
                    aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_FRAME,
                "DoURILoad thinks this is a frame and InternalLoad does not");
 
     if (StaticPrefs::dom_block_external_protocol_in_iframes()) {
       // Only allow URLs able to return data in iframes.
       bool doesNotReturnData = false;
@@ -11262,17 +11262,17 @@ nsresult nsDocShell::AddToSessionHistory
         entry->RemoveChild(child);
       }
       entry->AbandonBFCacheEntry();
     }
   }
 
   // Create a new entry if necessary.
   if (!entry) {
-    entry = do_CreateInstance(NS_SHENTRY_CONTRACTID);
+    entry = components::SHEntry::Create();
 
     if (!entry) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
   }
 
   // Get the post data & referrer
   nsCOMPtr<nsIInputStream> inputStream;
--- a/docshell/base/nsWebNavigationInfo.h
+++ b/docshell/base/nsWebNavigationInfo.h
@@ -8,23 +8,16 @@
 #define nsWebNavigationInfo_h__
 
 #include "nsIWebNavigationInfo.h"
 #include "nsCOMPtr.h"
 #include "nsICategoryManager.h"
 #include "nsStringFwd.h"
 #include "mozilla/Attributes.h"
 
-#define NS_WEBNAVIGATION_INFO_CID                    \
-  {                                                  \
-    0xf30bc0a2, 0x958b, 0x4287, {                    \
-      0xbf, 0x62, 0xce, 0x38, 0xba, 0x0c, 0x81, 0x1e \
-    }                                                \
-  }
-
 class nsWebNavigationInfo final : public nsIWebNavigationInfo {
  public:
   nsWebNavigationInfo() {}
 
   NS_DECL_ISUPPORTS
 
   NS_DECL_NSIWEBNAVIGATIONINFO
 
new file mode 100644
--- /dev/null
+++ b/docshell/build/components.conf
@@ -0,0 +1,176 @@
+# -*- 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/.
+
+about_pages = [
+    'about',
+    'addons',
+    'buildconfig',
+    'checkerboard',
+    'config',
+    'crashcontent',
+    'crashparent',
+    'credits',
+    'license',
+    'logo',
+    'memory',
+    'mozilla',
+    'neterror',
+    'networking',
+    'performance',
+    'plugins',
+    'printpreview',
+    'serviceworkers',
+    'srcdoc',
+    'support',
+    'telemetry',
+    'url-classifier',
+    'webrtc',
+]
+
+if defined('MOZ_CRASHREPORTER'):
+    about_pages.append('crashes')
+if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] != 'android':
+    about_pages.append('profiles')
+
+Headers = ['/docshell/build/nsDocShellModule.h']
+
+InitFunc = 'mozilla::InitDocShellModule'
+UnloadFunc = 'mozilla::UnloadDocShellModule'
+
+Classes = [
+    {
+        'name': 'SHEntry',
+        'cid': '{bfd1a791-ad9f-11d3-bdc7-0050040a9b44}',
+        'contract_ids': ['@mozilla.org/browser/session-history-entry;1'],
+        'type': 'nsSHEntry',
+        'headers': ['/docshell/shistory/nsSHEntry.h'],
+    },
+    {
+        'name': 'DocLoader',
+        'cid': '{057b04d0-0ccf-11d2-beba-00805f8a66dc}',
+        'contract_ids': ['@mozilla.org/docloaderservice;1'],
+        'type': 'nsDocLoader',
+        'headers': ['nsDocLoader.h'],
+        'init_method': 'Init',
+    },
+    {
+        'name': 'URIFixup',
+        'cid': '{214c48a0-b57f-11d4-959c-0020183bf181}',
+        'contract_ids': ['@mozilla.org/docshell/urifixup;1'],
+        'type': 'nsDefaultURIFixup',
+        'headers': ['/docshell/base/nsDefaultURIFixup.h'],
+    },
+    {
+        'cid': '{a7f800e0-4306-11d4-98d0-001083010e9b}',
+        'contract_ids': [
+            '@mozilla.org/mime;1',
+            '@mozilla.org/uriloader/external-helper-app-service;1',
+            '@mozilla.org/uriloader/external-protocol-service;1',
+        ],
+        'type': 'nsOSHelperAppService',
+        'headers': ['nsOSHelperAppService.h'],
+        'init_method': 'Init',
+        'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS,
+    },
+    {
+        'cid': '{397b43f3-1470-4542-8a40-c718f7753563}',
+        'contract_ids': ['@mozilla.org/network/childProcessChannelListener;1'],
+        'singleton': True,
+        'type': 'mozilla::dom::ChildProcessChannelListener',
+        'constructor': 'mozilla::dom::ChildProcessChannelListener::GetSingleton',
+        'headers': ['mozilla/dom/ChildProcessChannelListener.h'],
+        'processes': ProcessSelector.CONTENT_PROCESS_ONLY,
+    },
+    {
+        'cid': '{56ebedd4-6ccf-48e8-bdae-adc77f044567}',
+        'contract_ids': [
+            '@mozilla.org/network/protocol/about;1?what=%s' % path
+            for path in about_pages
+        ],
+        'legacy_constructor': 'nsAboutRedirector::Create',
+        'headers': ['/docshell/base/nsAboutRedirector.h'],
+    },
+    {
+        'cid': '{bd6390c8-fbea-11d4-98f6-001083010e9b}',
+        'contract_ids': ['@mozilla.org/network/protocol;1?name=default'],
+        'type': 'nsExternalProtocolHandler',
+        'headers': ['/uriloader/exthandler/nsExternalProtocolHandler.h'],
+        'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS,
+    },
+    {
+        'name': 'OfflineCacheUpdate',
+        'cid': '{ec06f3fc-70db-4ecd-94e0-a6e91ca44d8a}',
+        'contract_ids': ['@mozilla.org/offlinecacheupdate-service;1'],
+        'singleton': True,
+        'type': 'nsOfflineCacheUpdateService',
+        'headers': ['/uriloader/prefetch/nsOfflineCacheUpdate.h'],
+        'constructor': 'nsOfflineCacheUpdateService::GetInstance',
+    },
+    {
+        'cid': '{95790842-75a0-430d-98bf-f5ce3788ea6d}',
+        'contract_ids': ['@mozilla.org/ospermissionrequest;1'],
+        'type': 'nsOSPermissionRequest',
+        'headers': ['nsOSPermissionRequest.h'],
+        'processes': ProcessSelector.MAIN_PROCESS_ONLY,
+    },
+    {
+        'name': 'Prefetch',
+        'cid': '{6b8bdffc-3394-417d-be83-a81b7c0f63bf}',
+        'contract_ids': ['@mozilla.org/prefetch-service;1'],
+        'type': 'nsPrefetchService',
+        'headers': ['/uriloader/prefetch/nsPrefetchService.h'],
+        'init_method': 'Init',
+    },
+    {
+        'cid': '{c4b6fb7c-bfb1-49dc-a65f-035796524b53}',
+        'contract_ids': ['@mozilla.org/uriloader/handler-service;1'],
+        'type': 'mozilla::dom::ContentHandlerService',
+        'headers': ['ContentHandlerService.h'],
+        'init_method': 'Init',
+        'processes': ProcessSelector.CONTENT_PROCESS_ONLY,
+    },
+    {
+        'cid': '{bc0017e3-2438-47be-a567-41db58f17627}',
+        'contract_ids': ['@mozilla.org/uriloader/local-handler-app;1'],
+        'type': 'PlatformLocalHandlerApp_t',
+        'headers': ['/uriloader/exthandler/nsLocalHandlerApp.h'],
+    },
+    {
+        'name': 'URILoader',
+        'cid': '{9f6d5d40-90e7-11d3-af80-00a024ffc08c}',
+        'contract_ids': ['@mozilla.org/uriloader;1'],
+        'type': 'nsURILoader',
+        'headers': ['nsURILoader.h'],
+    },
+    {
+        'cid': '{f30bc0a2-958b-4287-bf62-ce38ba0c811e}',
+        'contract_ids': ['@mozilla.org/webnavigation-info;1'],
+        'type': 'nsWebNavigationInfo',
+        'headers': ['/docshell/base/nsWebNavigationInfo.h'],
+        'init_method': 'Init',
+    },
+]
+
+if defined('MOZ_ENABLE_DBUS'):
+    Classes += [
+        {
+            'name': 'DBusHandlerApp',
+            'cid': '{6c3c274b-4cbf-4bb5-a635-05ad2cbb6535}',
+            'contract_ids': ['@mozilla.org/uriloader/dbus-handler-app;1'],
+            'type': 'nsDBusHandlerApp',
+            'headers': ['/uriloader/exthandler/nsDBusHandlerApp.h'],
+        },
+    ]
+
+if defined('MOZ_WIDGET_ANDROID'):
+    Classes += [
+        {
+            'cid': '{4bf1f8ef-d947-4ba3-9cd3-8c9a54a63a1c}',
+            'contract_ids': ['@mozilla.org/uriloader/external-url-handler-service;1'],
+            'type': 'nsExternalURLHandlerService',
+            'headers': ['nsExternalURLHandlerService.h'],
+        },
+    ]
--- a/docshell/build/moz.build
+++ b/docshell/build/moz.build
@@ -8,18 +8,18 @@ EXPORTS += [
     'nsDocShellCID.h',
 ]
 
 SOURCES += [
     'nsDocShellModule.cpp',
 ]
 
 LOCAL_INCLUDES += [
-    '/docshell/base',
     '/docshell/shistory',
-    '/uriloader/base',
-    '/uriloader/exthandler',
-    '/uriloader/prefetch',
+]
+
+XPCOM_MANIFESTS += [
+    'components.conf',
 ]
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
--- a/docshell/build/nsDocShellModule.cpp
+++ b/docshell/build/nsDocShellModule.cpp
@@ -1,209 +1,29 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "nsDocShellCID.h"
-
 #include "mozilla/dom/BrowsingContext.h"
-#include "mozilla/dom/ChildProcessChannelListener.h"
-
-#include "nsDocShell.h"
-#include "nsDefaultURIFixup.h"
-#include "nsWebNavigationInfo.h"
-#include "nsAboutRedirector.h"
-#include "nsCDefaultURIFixup.h"
-
-// uriloader
-#include "nsURILoader.h"
-#include "nsDocLoader.h"
-#include "nsOSHelperAppService.h"
-#include "nsOSPermissionRequest.h"
-#include "nsExternalProtocolHandler.h"
-#include "nsPrefetchService.h"
-#include "nsOfflineCacheUpdate.h"
-#include "nsLocalHandlerApp.h"
-#include "ContentHandlerService.h"
-#ifdef MOZ_ENABLE_DBUS
-#  include "nsDBusHandlerApp.h"
-#endif
-#if defined(MOZ_WIDGET_ANDROID)
-#  include "nsExternalURLHandlerService.h"
-#endif
 
 // session history
-#include "nsSHEntry.h"
 #include "nsSHEntryShared.h"
 #include "nsSHistory.h"
 
-using mozilla::dom::ChildProcessChannelListener;
-using mozilla::dom::ContentHandlerService;
-
-static bool gInitialized = false;
+namespace mozilla {
 
 // The one time initialization for this module
-static nsresult Initialize() {
-  MOZ_ASSERT(!gInitialized, "docshell module already initialized");
-  if (gInitialized) {
-    return NS_OK;
-  }
-  gInitialized = true;
-
+nsresult InitDocShellModule() {
   mozilla::dom::BrowsingContext::Init();
   nsresult rv = nsSHistory::Startup();
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
-static void Shutdown() {
+void UnloadDocShellModule() {
   nsSHistory::Shutdown();
   nsSHEntryShared::Shutdown();
-  gInitialized = false;
 }
 
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsDefaultURIFixup)
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsWebNavigationInfo, Init)
-
-// uriloader
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsURILoader)
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDocLoader, Init)
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsOSHelperAppService, Init)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalProtocolHandler)
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrefetchService, Init)
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(
-    nsOfflineCacheUpdateService, nsOfflineCacheUpdateService::GetInstance)
-NS_GENERIC_FACTORY_CONSTRUCTOR(PlatformLocalHandlerApp_t)
-#ifdef MOZ_ENABLE_DBUS
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsDBusHandlerApp)
-#endif
-#if defined(MOZ_WIDGET_ANDROID)
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalURLHandlerService)
-#endif
-NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ContentHandlerService, Init)
-NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(
-    ChildProcessChannelListener, ChildProcessChannelListener::GetSingleton)
-
-// OS access permissions
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsOSPermissionRequest)
-
-// session history
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHEntry)
-
-NS_DEFINE_NAMED_CID(NS_DEFAULTURIFIXUP_CID);
-NS_DEFINE_NAMED_CID(NS_WEBNAVIGATION_INFO_CID);
-NS_DEFINE_NAMED_CID(NS_ABOUT_REDIRECTOR_MODULE_CID);
-NS_DEFINE_NAMED_CID(NS_URI_LOADER_CID);
-NS_DEFINE_NAMED_CID(NS_DOCUMENTLOADER_SERVICE_CID);
-NS_DEFINE_NAMED_CID(NS_EXTERNALHELPERAPPSERVICE_CID);
-NS_DEFINE_NAMED_CID(NS_EXTERNALPROTOCOLHANDLER_CID);
-NS_DEFINE_NAMED_CID(NS_PREFETCHSERVICE_CID);
-NS_DEFINE_NAMED_CID(NS_OFFLINECACHEUPDATESERVICE_CID);
-NS_DEFINE_NAMED_CID(NS_LOCALHANDLERAPP_CID);
-NS_DEFINE_NAMED_CID(NS_OSPERMISSIONREQUEST_CID);
-#ifdef MOZ_ENABLE_DBUS
-NS_DEFINE_NAMED_CID(NS_DBUSHANDLERAPP_CID);
-#endif
-#if defined(MOZ_WIDGET_ANDROID)
-NS_DEFINE_NAMED_CID(NS_EXTERNALURLHANDLERSERVICE_CID);
-#endif
-NS_DEFINE_NAMED_CID(NS_SHENTRY_CID);
-NS_DEFINE_NAMED_CID(NS_CONTENTHANDLERSERVICE_CID);
-NS_DEFINE_NAMED_CID(NS_CHILDPROCESSCHANNELLISTENER_CID);
-
-const mozilla::Module::CIDEntry kDocShellCIDs[] = {
-    // clang-format off
-  { &kNS_DEFAULTURIFIXUP_CID, false, nullptr, nsDefaultURIFixupConstructor },
-  { &kNS_WEBNAVIGATION_INFO_CID, false, nullptr, nsWebNavigationInfoConstructor },
-  { &kNS_ABOUT_REDIRECTOR_MODULE_CID, false, nullptr, nsAboutRedirector::Create },
-  { &kNS_URI_LOADER_CID, false, nullptr, nsURILoaderConstructor },
-  { &kNS_DOCUMENTLOADER_SERVICE_CID, false, nullptr, nsDocLoaderConstructor },
-  { &kNS_EXTERNALHELPERAPPSERVICE_CID, false, nullptr, nsOSHelperAppServiceConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
-  { &kNS_OSPERMISSIONREQUEST_CID, false, nullptr, nsOSPermissionRequestConstructor },
-  { &kNS_CONTENTHANDLERSERVICE_CID, false, nullptr, ContentHandlerServiceConstructor,
-    mozilla::Module::CONTENT_PROCESS_ONLY },
-  { &kNS_EXTERNALPROTOCOLHANDLER_CID, false, nullptr, nsExternalProtocolHandlerConstructor, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
-  { &kNS_PREFETCHSERVICE_CID, false, nullptr, nsPrefetchServiceConstructor },
-  { &kNS_OFFLINECACHEUPDATESERVICE_CID, false, nullptr, nsOfflineCacheUpdateServiceConstructor },
-  { &kNS_LOCALHANDLERAPP_CID, false, nullptr, PlatformLocalHandlerApp_tConstructor },
-#ifdef MOZ_ENABLE_DBUS
-  { &kNS_DBUSHANDLERAPP_CID, false, nullptr, nsDBusHandlerAppConstructor },
-#endif
-#if defined(MOZ_WIDGET_ANDROID)
-  { &kNS_EXTERNALURLHANDLERSERVICE_CID, false, nullptr, nsExternalURLHandlerServiceConstructor },
-#endif
-  { &kNS_SHENTRY_CID, false, nullptr, nsSHEntryConstructor },
-  { &kNS_CHILDPROCESSCHANNELLISTENER_CID, false, nullptr, ChildProcessChannelListenerConstructor },
-  { nullptr }
-    // clang-format on
-};
-
-const mozilla::Module::ContractIDEntry kDocShellContracts[] = {
-    // clang-format off
-  { NS_URIFIXUP_CONTRACTID, &kNS_DEFAULTURIFIXUP_CID },
-  { NS_WEBNAVIGATION_INFO_CONTRACTID, &kNS_WEBNAVIGATION_INFO_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "about", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "addons", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "buildconfig", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "checkerboard", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "config", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-#ifdef MOZ_CRASHREPORTER
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "crashes", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-#endif
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "crashparent", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "crashcontent", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "credits", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "license", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "logo", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "memory", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "mozilla", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "neterror", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "networking", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "performance", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "plugins", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "serviceworkers", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-#ifndef ANDROID
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "profiles", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-#endif
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "srcdoc", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "support", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "telemetry", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "webrtc", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "printpreview", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_ABOUT_MODULE_CONTRACTID_PREFIX "url-classifier", &kNS_ABOUT_REDIRECTOR_MODULE_CID },
-  { NS_URI_LOADER_CONTRACTID, &kNS_URI_LOADER_CID },
-  { NS_DOCUMENTLOADER_SERVICE_CONTRACTID, &kNS_DOCUMENTLOADER_SERVICE_CID },
-  { NS_HANDLERSERVICE_CONTRACTID, &kNS_CONTENTHANDLERSERVICE_CID, mozilla::Module::CONTENT_PROCESS_ONLY },
-  { NS_EXTERNALHELPERAPPSERVICE_CONTRACTID, &kNS_EXTERNALHELPERAPPSERVICE_CID },
-  { NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, &kNS_EXTERNALHELPERAPPSERVICE_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
-  { NS_MIMESERVICE_CONTRACTID, &kNS_EXTERNALHELPERAPPSERVICE_CID },
-  { NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX"default", &kNS_EXTERNALPROTOCOLHANDLER_CID, mozilla::Module::ALLOW_IN_SOCKET_PROCESS },
-  { NS_PREFETCHSERVICE_CONTRACTID, &kNS_PREFETCHSERVICE_CID },
-  { NS_OFFLINECACHEUPDATESERVICE_CONTRACTID, &kNS_OFFLINECACHEUPDATESERVICE_CID },
-  { NS_LOCALHANDLERAPP_CONTRACTID, &kNS_LOCALHANDLERAPP_CID },
-#ifdef MOZ_ENABLE_DBUS
-  { NS_DBUSHANDLERAPP_CONTRACTID, &kNS_DBUSHANDLERAPP_CID },
-#endif
-#if defined(MOZ_WIDGET_ANDROID)
-  { NS_EXTERNALURLHANDLERSERVICE_CONTRACTID, &kNS_EXTERNALURLHANDLERSERVICE_CID },
-#endif
-  { NS_SHENTRY_CONTRACTID, &kNS_SHENTRY_CID },
-  { NS_OSPERMISSIONREQUEST_CONTRACTID, &kNS_OSPERMISSIONREQUEST_CID, mozilla::Module::MAIN_PROCESS_ONLY },
-  { NS_CHILDPROCESSCHANNELLISTENER_CONTRACTID, &kNS_CHILDPROCESSCHANNELLISTENER_CID, mozilla::Module::CONTENT_PROCESS_ONLY },
-  { nullptr }
-    // clang-format on
-};
-
-static const mozilla::Module kDocShellModule = {
-    mozilla::Module::kVersion,
-    kDocShellCIDs,
-    kDocShellContracts,
-    nullptr,
-    nullptr,
-    Initialize,
-    Shutdown,
-    mozilla::Module::ALLOW_IN_SOCKET_PROCESS};
-
-NSMODULE_DEFN(docshell_provider) = &kDocShellModule;
+}  // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/docshell/build/nsDocShellModule.h
@@ -0,0 +1,20 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* 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/. */
+
+#ifndef nsDocShellModule_h
+#define nsDocShellModule_h
+
+#include "nscore.h"
+
+namespace mozilla {
+
+nsresult InitDocShellModule();
+
+void UnloadDocShellModule();
+
+}  // namespace mozilla
+
+#endif
--- a/docshell/shistory/nsISHEntry.idl
+++ b/docshell/shistory/nsISHEntry.idl
@@ -392,17 +392,8 @@ interface nsISHEntry : nsISupports
     /**
      * Replaces a child which is for the same docshell as aNewChild
      * with aNewChild.
      * @throw if nothing was replaced.
      */
     [noscript] void ReplaceChild(in nsISHEntry aNewChild);
 };
 
-%{ C++
-// {BFD1A791-AD9F-11d3-BDC7-0050040A9B44}
-#define NS_SHENTRY_CID \
-{0xbfd1a791, 0xad9f, 0x11d3, {0xbd, 0xc7, 0x0, 0x50, 0x4, 0xa, 0x9b, 0x44}}
-
-#define NS_SHENTRY_CONTRACTID \
-    "@mozilla.org/browser/session-history-entry;1"
-%}
-
--- a/dom/base/Link.cpp
+++ b/dom/base/Link.cpp
@@ -1,30 +1,30 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "Link.h"
 
+#include "mozilla/Components.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/Element.h"
 #if defined(MOZ_PLACES)
 #  include "mozilla/places/History.h"
 #else
 #  include "mozilla/IHistory.h"
 #endif
 #include "nsIURL.h"
 #include "nsIURIMutator.h"
 #include "nsISizeOf.h"
 #include "nsIDocShell.h"
 #include "nsIPrefetchService.h"
-#include "nsCPrefetchService.h"
 #include "nsStyleLinkElement.h"
 
 #include "nsEscape.h"
 #include "nsGkAtoms.h"
 #include "nsHTMLDNSPrefetch.h"
 #include "nsString.h"
 #include "mozAutoDocUpdate.h"
 
@@ -129,17 +129,17 @@ void Link::TryDNSPrefetchOrPreconnectOrP
   }
 
   uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(rel);
 
   if ((linkTypes & nsStyleLinkElement::ePREFETCH) ||
       (linkTypes & nsStyleLinkElement::eNEXT) ||
       (linkTypes & nsStyleLinkElement::ePRELOAD)) {
     nsCOMPtr<nsIPrefetchService> prefetchService(
-        do_GetService(NS_PREFETCHSERVICE_CONTRACTID));
+        components::Prefetch::Service());
     if (prefetchService) {
       nsCOMPtr<nsIURI> uri(GetURI());
       if (uri) {
         if (linkTypes & nsStyleLinkElement::ePRELOAD) {
           nsAttrValue asAttr;
           nsContentPolicyType policyType;
           nsAutoString mimeType;
           nsAutoString media;
@@ -204,18 +204,17 @@ void Link::UpdatePreload(nsAtom *aName, 
   }
 
   uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(rel);
 
   if (!(linkTypes & nsStyleLinkElement::ePRELOAD)) {
     return;
   }
 
-  nsCOMPtr<nsIPrefetchService> prefetchService(
-      do_GetService(NS_PREFETCHSERVICE_CONTRACTID));
+  nsCOMPtr<nsIPrefetchService> prefetchService(components::Prefetch::Service());
   if (!prefetchService) {
     return;
   }
 
   nsCOMPtr<nsIURI> uri(GetURI());
   if (!uri) {
     return;
   }
@@ -305,18 +304,17 @@ void Link::UpdatePreload(nsAtom *aName, 
   if ((policyType != oldPolicyType) ||
       (policyType == nsIContentPolicy::TYPE_INVALID)) {
     prefetchService->PreloadURI(uri, mElement->OwnerDoc()->GetDocumentURI(),
                                 mElement, policyType);
   }
 }
 
 void Link::CancelPrefetchOrPreload() {
-  nsCOMPtr<nsIPrefetchService> prefetchService(
-      do_GetService(NS_PREFETCHSERVICE_CONTRACTID));
+  nsCOMPtr<nsIPrefetchService> prefetchService(components::Prefetch::Service());
   if (prefetchService) {
     nsCOMPtr<nsIURI> uri(GetURI());
     if (uri) {
       prefetchService->CancelPrefetchPreloadURI(uri, mElement);
     }
   }
 }
 
--- a/dom/base/Location.cpp
+++ b/dom/base/Location.cpp
@@ -6,17 +6,16 @@
 
 #include "Location.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScriptContext.h"
 #include "nsIDocShell.h"
 #include "nsDocShellLoadState.h"
 #include "nsIWebNavigation.h"
-#include "nsCDefaultURIFixup.h"
 #include "nsIURIFixup.h"
 #include "nsIURL.h"
 #include "nsIURIMutator.h"
 #include "nsIJARURI.h"
 #include "nsNetUtil.h"
 #include "nsCOMPtr.h"
 #include "nsEscape.h"
 #include "nsIDOMWindow.h"
@@ -26,16 +25,17 @@
 #include "nsError.h"
 #include "nsReadableUtils.h"
 #include "nsITextToSubURI.h"
 #include "nsJSUtils.h"
 #include "nsContentUtils.h"
 #include "nsGlobalWindow.h"
 #include "mozilla/Likely.h"
 #include "nsCycleCollectionParticipant.h"
+#include "mozilla/Components.h"
 #include "mozilla/NullPrincipal.h"
 #include "mozilla/Unused.h"
 #include "mozilla/dom/LocationBinding.h"
 #include "mozilla/dom/ScriptSettings.h"
 
 namespace mozilla {
 namespace dom {
 
@@ -187,18 +187,17 @@ nsresult Location::GetURI(nsIURI** aURI,
     while (jarURI) {
       jarURI->GetJARFile(getter_AddRefs(uri));
       jarURI = do_QueryInterface(uri);
     }
   }
 
   NS_ASSERTION(uri, "nsJARURI screwed up?");
 
-  nsCOMPtr<nsIURIFixup> urifixup(do_GetService(NS_URIFIXUP_CONTRACTID, &rv));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIURIFixup> urifixup(components::URIFixup::Service());
 
   return urifixup->CreateExposableURI(uri, aURI);
 }
 
 void Location::SetURI(nsIURI* aURI, nsIPrincipal& aSubjectPrincipal,
                       ErrorResult& aRv, bool aReplace) {
   nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
   if (docShell) {
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -5,23 +5,24 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Base class for the XML and HTML content sinks, which construct a
  * DOM based on information from the parser.
  */
 
 #include "nsContentSink.h"
+#include "mozilla/Components.h"
 #include "mozilla/dom/Document.h"
 #include "mozilla/css/Loader.h"
 #include "mozilla/dom/SRILogHelper.h"
 #include "nsStyleLinkElement.h"
 #include "nsIDocShell.h"
 #include "nsILoadContext.h"
-#include "nsCPrefetchService.h"
+#include "nsIPrefetchService.h"
 #include "nsIURI.h"
 #include "nsNetUtil.h"
 #include "nsIMIMEHeaderParam.h"
 #include "nsIProtocolHandler.h"
 #include "nsIHttpChannel.h"
 #include "nsIContent.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
@@ -820,18 +821,17 @@ nsresult nsContentSink::ProcessMETATag(n
   return rv;
 }
 
 void nsContentSink::PrefetchPreloadHref(const nsAString& aHref,
                                         nsINode* aSource, uint32_t aLinkTypes,
                                         const nsAString& aAs,
                                         const nsAString& aType,
                                         const nsAString& aMedia) {
-  nsCOMPtr<nsIPrefetchService> prefetchService(
-      do_GetService(NS_PREFETCHSERVICE_CONTRACTID));
+  nsCOMPtr<nsIPrefetchService> prefetchService(components::Prefetch::Service());
   if (prefetchService) {
     // construct URI using document charset
     auto encoding = mDocument->GetDocumentCharacterSet();
     nsCOMPtr<nsIURI> uri;
     NS_NewURI(getter_AddRefs(uri), aHref, encoding, mDocument->GetDocBaseURI());
     if (uri) {
       if (aLinkTypes & nsStyleLinkElement::ePRELOAD) {
         nsAttrValue asAttr;
@@ -1121,17 +1121,17 @@ void nsContentSink::ProcessOfflineManife
     }
   }
 
   switch (action) {
     case CACHE_SELECTION_NONE:
       break;
     case CACHE_SELECTION_UPDATE: {
       nsCOMPtr<nsIOfflineCacheUpdateService> updateService =
-          do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID);
+          components::OfflineCacheUpdate::Service();
 
       if (updateService) {
         updateService->ScheduleOnDocumentStop(
             manifestURI, mDocumentURI, mDocument->NodePrincipal(), mDocument);
       }
       break;
     }
     case CACHE_SELECTION_RELOAD: {
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -35,16 +35,17 @@
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/AutoRestore.h"
 #include "mozilla/AutoTimelineMarker.h"
 #include "mozilla/BackgroundHangMonitor.h"
 #include "mozilla/Base64.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/CheckedInt.h"
+#include "mozilla/Components.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/LoadInfo.h"
 #include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/CustomElementRegistry.h"
 #include "mozilla/dom/Document.h"
 #include "mozilla/dom/MessageBroadcaster.h"
 #include "mozilla/dom/DocumentFragment.h"
@@ -102,17 +103,16 @@
 #include "nsCCUncollectableMarker.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsCOMPtr.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsContentDLF.h"
 #include "nsContentList.h"
 #include "nsContentPolicyUtils.h"
 #include "nsContentSecurityManager.h"
-#include "nsCPrefetchService.h"
 #include "nsCRT.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsCycleCollector.h"
 #include "nsDataHashtable.h"
 #include "nsDocShellCID.h"
 #include "nsDOMCID.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "nsDOMJSUtils.h"
@@ -1783,31 +1783,31 @@ void nsContentUtils::GetOfflineAppManife
 
   nsContentUtils::NewURIWithDocumentCharset(aURI, manifestSpec, aDocument,
                                             aDocument->GetDocBaseURI());
 }
 
 /* static */
 bool nsContentUtils::OfflineAppAllowed(nsIURI* aURI) {
   nsCOMPtr<nsIOfflineCacheUpdateService> updateService =
-      do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID);
+      components::OfflineCacheUpdate::Service();
   if (!updateService) {
     return false;
   }
 
   bool allowed;
   nsresult rv = updateService->OfflineAppAllowedForURI(
       aURI, Preferences::GetRootBranch(), &allowed);
   return NS_SUCCEEDED(rv) && allowed;
 }
 
 /* static */
 bool nsContentUtils::OfflineAppAllowed(nsIPrincipal* aPrincipal) {
   nsCOMPtr<nsIOfflineCacheUpdateService> updateService =
-      do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID);
+      components::OfflineCacheUpdate::Service();
   if (!updateService) {
     return false;
   }
 
   bool allowed;
   nsresult rv = updateService->OfflineAppAllowed(
       aPrincipal, Preferences::GetRootBranch(), &allowed);
   return NS_SUCCEEDED(rv) && allowed;
@@ -1821,17 +1821,17 @@ bool nsContentUtils::MaybeAllowOfflineAp
   bool allowedByDefault;
   rv = Preferences::GetRootBranch()->GetBoolPref(
       "offline-apps.allow_by_default", &allowedByDefault);
   if (NS_FAILED(rv)) return false;
 
   if (!allowedByDefault) return false;
 
   nsCOMPtr<nsIOfflineCacheUpdateService> updateService =
-      do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID);
+      components::OfflineCacheUpdate::Service();
   if (!updateService) {
     return false;
   }
 
   rv = updateService->AllowOfflineApp(aPrincipal);
   return NS_SUCCEEDED(rv);
 }
 
--- a/dom/base/nsGlobalWindowInner.cpp
+++ b/dom/base/nsGlobalWindowInner.cpp
@@ -144,17 +144,16 @@
 #include "nsIScriptError.h"
 #include "nsIControllers.h"
 #include "nsIControllerContext.h"
 #include "nsGlobalWindowCommands.h"
 #include "nsQueryObject.h"
 #include "nsContentUtils.h"
 #include "nsCSSProps.h"
 #include "nsIURIFixup.h"
-#include "nsCDefaultURIFixup.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventStateManager.h"
 #include "nsIObserverService.h"
 #include "nsFocusManager.h"
 #include "nsIXULWindow.h"
 #include "nsITimedChannel.h"
 #include "nsServiceManagerUtils.h"
 #ifdef MOZ_XUL
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -90,16 +90,17 @@
 #include "mozilla/dom/BarProps.h"
 #include "nsContentCID.h"
 #include "nsLayoutStatics.h"
 #include "nsCCUncollectableMarker.h"
 #include "mozilla/dom/WorkerCommon.h"
 #include "mozilla/dom/ToJSValue.h"
 #include "nsJSPrincipals.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/Components.h"
 #include "mozilla/Debug.h"
 #include "mozilla/EventListenerManager.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/MouseEvents.h"
 #include "mozilla/ProcessHangMonitor.h"
 #include "mozilla/StaticPrefs.h"
 #include "mozilla/ThrottledEventQueue.h"
 #include "AudioChannelService.h"
@@ -148,17 +149,16 @@
 #include "nsIControllers.h"
 #include "nsIControllerContext.h"
 #include "nsGlobalWindowCommands.h"
 #include "nsQueryObject.h"
 #include "nsContentUtils.h"
 #include "nsCSSProps.h"
 #include "nsIURIFixup.h"
 #include "nsIURIMutator.h"
-#include "nsCDefaultURIFixup.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventStateManager.h"
 #include "nsIObserverService.h"
 #include "nsFocusManager.h"
 #include "nsIXULWindow.h"
 #include "nsITimedChannel.h"
 #include "nsServiceManagerUtils.h"
 #include "mozilla/dom/CustomEvent.h"
@@ -4552,17 +4552,17 @@ void nsGlobalWindowOuter::MakeScriptDial
   // Try to get a host from the running principal -- this will do the
   // right thing for javascript: and data: documents.
 
   nsCOMPtr<nsIURI> uri;
   nsresult rv = aSubjectPrincipal->GetURI(getter_AddRefs(uri));
   if (NS_SUCCEEDED(rv) && uri) {
     // remove user:pass for privacy and spoof prevention
 
-    nsCOMPtr<nsIURIFixup> fixup(do_GetService(NS_URIFIXUP_CONTRACTID));
+    nsCOMPtr<nsIURIFixup> fixup(components::URIFixup::Service());
     if (fixup) {
       nsCOMPtr<nsIURI> fixedURI;
       rv = fixup->CreateExposableURI(uri, getter_AddRefs(fixedURI));
       if (NS_SUCCEEDED(rv) && fixedURI) {
         nsAutoCString host;
         fixedURI->GetHost(host);
 
         if (!host.IsEmpty()) {
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -69,16 +69,17 @@
 #include "GeckoProfiler.h"
 #include "nsPluginFrame.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsDOMJSUtils.h"
 
 #include "nsWidgetsCID.h"
 #include "nsContentCID.h"
 #include "mozilla/BasicEvents.h"
+#include "mozilla/Components.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/PluginCrashedEvent.h"
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/EventStateManager.h"
@@ -2235,19 +2236,18 @@ nsresult nsObjectLoadingContent::LoadObj
       nsLoadFlags flags = 0;
       mChannel->GetLoadFlags(&flags);
       flags |= nsIChannel::LOAD_DOCUMENT_URI;
       mChannel->SetLoadFlags(flags);
 
       nsCOMPtr<nsIInterfaceRequestor> req(do_QueryInterface(docShell));
       NS_ASSERTION(req, "Docshell must be an ifreq");
 
-      nsCOMPtr<nsIURILoader> uriLoader(
-          do_GetService(NS_URI_LOADER_CONTRACTID, &rv));
-      if (NS_FAILED(rv)) {
+      nsCOMPtr<nsIURILoader> uriLoader(components::URILoader::Service());
+      if (NS_WARN_IF(!uriLoader)) {
         MOZ_ASSERT_UNREACHABLE("Failed to get uriLoader service");
         mFrameLoader->Destroy();
         mFrameLoader = nullptr;
         break;
       }
 
       rv = uriLoader->OpenChannel(mChannel, nsIURILoader::DONT_RETARGET, req,
                                   getter_AddRefs(finalListener));
--- a/dom/html/nsHTMLDNSPrefetch.cpp
+++ b/dom/html/nsHTMLDNSPrefetch.cpp
@@ -15,27 +15,27 @@
 
 #include "nsNetUtil.h"
 #include "nsNetCID.h"
 #include "nsIProtocolHandler.h"
 
 #include "nsIDNSListener.h"
 #include "nsIWebProgressListener.h"
 #include "nsIWebProgress.h"
-#include "nsCURILoader.h"
 #include "nsIDNSRecord.h"
 #include "nsIDNSService.h"
 #include "nsICancelable.h"
 #include "nsGkAtoms.h"
 #include "mozilla/dom/Document.h"
 #include "nsThreadUtils.h"
 #include "nsITimer.h"
 #include "nsIObserverService.h"
 #include "mozilla/dom/Link.h"
 
+#include "mozilla/Components.h"
 #include "mozilla/Preferences.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::net;
 
 static NS_DEFINE_CID(kDNSServiceCID, NS_DNSSERVICE_CID);
 bool sDisablePrefetchHTTPSPref;
@@ -405,18 +405,17 @@ void nsHTMLDNSPrefetch::nsDeferrals::Sub
   if (mTimerArmed) {
     mTimerArmed = false;
     mTimer->Cancel();
   }
 }
 
 void nsHTMLDNSPrefetch::nsDeferrals::Activate() {
   // Register as an observer for the document loader
-  nsCOMPtr<nsIWebProgress> progress =
-      do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIWebProgress> progress = components::DocLoader::Service();
   if (progress)
     progress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_DOCUMENT);
 
   // Register as an observer for xpcom shutdown events so we can drop any
   // element refs
   nsCOMPtr<nsIObserverService> observerService =
       mozilla::services::GetObserverService();
   if (observerService)
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -108,17 +108,16 @@
 #include "mozilla/Telemetry.h"
 #include "mozilla/TelemetryIPC.h"
 #include "mozilla/WebBrowserPersistDocumentParent.h"
 #include "mozilla/widget/ScreenManager.h"
 #include "mozilla/Unused.h"
 #include "mozilla/HangDetails.h"
 #include "nsAnonymousTemporaryFile.h"
 #include "nsAppRunner.h"
-#include "nsCDefaultURIFixup.h"
 #include "nsCExternalHandlerService.h"
 #include "nsCOMPtr.h"
 #include "nsChromeRegistryChrome.h"
 #include "nsConsoleMessage.h"
 #include "nsConsoleService.h"
 #include "nsContentUtils.h"
 #include "nsDebugImpl.h"
 #include "nsDirectoryServiceDefs.h"
@@ -4104,17 +4103,17 @@ PBrowserParent* ContentParent::SendPBrow
 }
 
 mozilla::ipc::IPCResult ContentParent::RecvKeywordToURI(
     const nsCString& aKeyword, nsString* aProviderName,
     RefPtr<nsIInputStream>* aPostData, OptionalURIParams* aURI) {
   *aPostData = nullptr;
   *aURI = void_t();
 
-  nsCOMPtr<nsIURIFixup> fixup = do_GetService(NS_URIFIXUP_CONTRACTID);
+  nsCOMPtr<nsIURIFixup> fixup = components::URIFixup::Service();
   if (!fixup) {
     return IPC_OK();
   }
 
   nsCOMPtr<nsIURIFixupInfo> info;
 
   if (NS_FAILED(fixup->KeywordToURI(aKeyword, getter_AddRefs(*aPostData),
                                     getter_AddRefs(info)))) {
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -77,17 +77,16 @@
 #include "nsIDOMWindow.h"
 #include "nsIDOMWindowUtils.h"
 #include "nsFocusManager.h"
 #include "EventStateManager.h"
 #include "nsIDocShell.h"
 #include "nsIFrame.h"
 #include "nsIURI.h"
 #include "nsIURIFixup.h"
-#include "nsCDefaultURIFixup.h"
 #include "nsIWebBrowser.h"
 #include "nsIWebProgress.h"
 #include "nsIXULRuntime.h"
 #include "nsPIDOMWindow.h"
 #include "nsPIWindowRoot.h"
 #include "nsPointerHashKeys.h"
 #include "nsLayoutUtils.h"
 #include "nsPrintfCString.h"
--- a/dom/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/offline/nsDOMOfflineResourceList.cpp
@@ -2,19 +2,19 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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 "nsDOMOfflineResourceList.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsError.h"
+#include "mozilla/Components.h"
 #include "mozilla/dom/DOMStringList.h"
 #include "nsIPrefetchService.h"
-#include "nsCPrefetchService.h"
 #include "nsMemory.h"
 #include "nsNetUtil.h"
 #include "nsNetCID.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIOfflineCacheUpdate.h"
 #include "nsContentUtils.h"
 #include "nsILoadContext.h"
@@ -115,18 +115,18 @@ nsresult nsDOMOfflineResourceList::Init(
 
   if (!IS_CHILD_PROCESS()) {
     mApplicationCacheService =
         do_GetService(NS_APPLICATIONCACHESERVICE_CONTRACTID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // Check for in-progress cache updates
     nsCOMPtr<nsIOfflineCacheUpdateService> cacheUpdateService =
-        do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID, &rv);
-    NS_ENSURE_SUCCESS(rv, rv);
+        components::OfflineCacheUpdate::Service();
+    NS_ENSURE_TRUE(cacheUpdateService, NS_ERROR_UNEXPECTED);
 
     uint32_t numUpdates;
     rv = cacheUpdateService->GetNumUpdates(&numUpdates);
     NS_ENSURE_SUCCESS(rv, rv);
 
     for (uint32_t i = 0; i < numUpdates; i++) {
       nsCOMPtr<nsIOfflineCacheUpdate> cacheUpdate;
       rv = cacheUpdateService->GetUpdate(i, getter_AddRefs(cacheUpdate));
@@ -492,19 +492,19 @@ void nsDOMOfflineResourceList::Update(Er
   }
 
   if (!nsContentUtils::OfflineAppAllowed(mDocumentURI)) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
   }
 
   nsCOMPtr<nsIOfflineCacheUpdateService> updateService =
-      do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID, &rv);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    aRv.Throw(rv);
+      components::OfflineCacheUpdate::Service();
+  if (NS_WARN_IF(!updateService)) {
+    aRv.Throw(NS_ERROR_UNEXPECTED);
     return;
   }
 
   nsCOMPtr<nsPIDOMWindowInner> window = GetOwner();
 
   nsCOMPtr<nsIOfflineCacheUpdate> update;
   rv = updateService->ScheduleUpdate(mManifestURI, mDocumentURI,
                                      mLoadingPrincipal, window,
--- a/dom/security/nsContentSecurityManager.cpp
+++ b/dom/security/nsContentSecurityManager.cpp
@@ -11,25 +11,25 @@
 #include "nsIHttpChannelInternal.h"
 #include "nsINode.h"
 #include "nsIStreamListener.h"
 #include "nsILoadInfo.h"
 #include "nsIOService.h"
 #include "nsContentUtils.h"
 #include "nsCORSListenerProxy.h"
 #include "nsIStreamListener.h"
-#include "nsCDefaultURIFixup.h"
 #include "nsIURIFixup.h"
 #include "nsIImageLoadingContent.h"
 #include "nsIRedirectHistoryEntry.h"
 
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/nsMixedContentBlocker.h"
 #include "mozilla/dom/TabChild.h"
+#include "mozilla/Components.h"
 #include "mozilla/Logging.h"
 
 NS_IMPL_ISUPPORTS(nsContentSecurityManager, nsIContentSecurityManager,
                   nsIChannelEventSink)
 
 static mozilla::LazyLogModule sCSMLog("CSMLog");
 
 /* static */ bool nsContentSecurityManager::AllowTopLevelNavigationToDataURI(
@@ -375,18 +375,18 @@ static nsresult DoContentSecurityChecks(
   nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (contentPolicyType == nsIContentPolicy::TYPE_DOCUMENT ||
       contentPolicyType == nsIContentPolicy::TYPE_SUBDOCUMENT) {
     // TYPE_DOCUMENT and TYPE_SUBDOCUMENT loads might potentially
     // be wyciwyg:// channels. Let's fix up the URI so we can
     // perform proper security checks.
-    nsCOMPtr<nsIURIFixup> urifixup(do_GetService(NS_URIFIXUP_CONTRACTID, &rv));
-    if (NS_SUCCEEDED(rv) && urifixup) {
+    nsCOMPtr<nsIURIFixup> urifixup(components::URIFixup::Service());
+    if (urifixup) {
       nsCOMPtr<nsIURI> fixedURI;
       rv = urifixup->CreateExposableURI(uri, getter_AddRefs(fixedURI));
       if (NS_SUCCEEDED(rv)) {
         uri = fixedURI;
       }
     }
   }
 
@@ -917,18 +917,18 @@ nsresult nsContentSecurityManager::Check
   nsContentPolicyType contentPolicyType =
       loadInfo->GetExternalContentPolicyType();
 
   if (contentPolicyType == nsIContentPolicy::TYPE_DOCUMENT ||
       contentPolicyType == nsIContentPolicy::TYPE_SUBDOCUMENT) {
     // TYPE_DOCUMENT and TYPE_SUBDOCUMENT loads might potentially
     // be wyciwyg:// channels. Let's fix up the URI so we can
     // perform proper security checks.
-    nsCOMPtr<nsIURIFixup> urifixup(do_GetService(NS_URIFIXUP_CONTRACTID, &rv));
-    if (NS_SUCCEEDED(rv) && urifixup) {
+    nsCOMPtr<nsIURIFixup> urifixup(components::URIFixup::Service());
+    if (urifixup) {
       nsCOMPtr<nsIURI> fixedURI;
       rv = urifixup->CreateExposableURI(uri, getter_AddRefs(fixedURI));
       if (NS_SUCCEEDED(rv)) {
         uri = fixedURI;
       }
     }
   }
 
--- a/dom/system/nsOSPermissionRequestBase.h
+++ b/dom/system/nsOSPermissionRequestBase.h
@@ -5,24 +5,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsOSPermissionRequestBase_h__
 #define nsOSPermissionRequestBase_h__
 
 #include "nsIOSPermissionRequest.h"
 #include "nsWeakReference.h"
 
-#define NS_OSPERMISSIONREQUEST_CID                   \
-  {                                                  \
-    0x95790842, 0x75a0, 0x430d, {                    \
-      0x98, 0xbf, 0xf5, 0xce, 0x37, 0x88, 0xea, 0x6d \
-    }                                                \
-  }
-#define NS_OSPERMISSIONREQUEST_CONTRACTID "@mozilla.org/ospermissionrequest;1"
-
 namespace mozilla {
 namespace dom {
 class Promise;
 }  // namespace dom
 }  // namespace mozilla
 
 using mozilla::dom::Promise;
 
--- a/layout/printing/nsPrintJob.cpp
+++ b/layout/printing/nsPrintJob.cpp
@@ -105,18 +105,18 @@ static const char kPrintingPromptService
 #include "nsILayoutHistoryState.h"
 #include "nsFrameManager.h"
 #include "mozilla/ReflowInput.h"
 #include "nsIContentViewer.h"
 #include "nsIDocumentViewerPrint.h"
 
 #include "nsFocusManager.h"
 #include "nsRange.h"
-#include "nsCDefaultURIFixup.h"
 #include "nsIURIFixup.h"
+#include "mozilla/Components.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/HTMLFrameElement.h"
 #include "nsContentList.h"
 #include "nsIChannel.h"
 #include "xpcpublic.h"
 #include "nsVariant.h"
 #include "mozilla/ServoStyleSet.h"
 
@@ -293,17 +293,17 @@ static void GetDocumentTitleAndURL(Docum
   aTitle.Truncate();
   aURLStr.Truncate();
 
   aDoc->GetTitle(aTitle);
 
   nsIURI* url = aDoc->GetDocumentURI();
   if (!url) return;
 
-  nsCOMPtr<nsIURIFixup> urifixup(do_GetService(NS_URIFIXUP_CONTRACTID));
+  nsCOMPtr<nsIURIFixup> urifixup(components::URIFixup::Service());
   if (!urifixup) return;
 
   nsCOMPtr<nsIURI> exposableURI;
   urifixup->CreateExposableURI(url, getter_AddRefs(exposableURI));
 
   if (!exposableURI) return;
 
   nsAutoCString urlCStr;
--- a/uriloader/base/nsCURILoader.idl
+++ b/uriloader/base/nsCURILoader.idl
@@ -8,29 +8,16 @@
 
 /*
 nsCURILoader implements:
 -------------------------
 nsIURILoader
 */
 
 %{ C++
-//	{9F6D5D40-90E7-11d3-AF93-00A024FFC08C} - 
-#define NS_URI_LOADER_CID \
-{ 0x9f6d5d40, 0x90e7, 0x11d3, { 0xaf, 0x80, 0x00, 0xa0, 0x24, 0xff, 0xc0, 0x8c } }
-#define NS_URI_LOADER_CONTRACTID \
-"@mozilla.org/uriloader;1"
-
-/* 057b04d0-0ccf-11d2-beba-00805f8a66dc */
-#define NS_DOCUMENTLOADER_SERVICE_CID   \
- { 0x057b04d0, 0x0ccf, 0x11d2,{0xbe, 0xba, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc}}
-
-#define NS_DOCUMENTLOADER_SERVICE_CONTRACTID \
-"@mozilla.org/docloaderservice;1"
-
 #define NS_CONTENT_HANDLER_CONTRACTID               "@mozilla.org/uriloader/content-handler;1"
 #define NS_CONTENT_HANDLER_CONTRACTID_PREFIX	     NS_CONTENT_HANDLER_CONTRACTID "?type="
 
 /**
  * A category where content listeners can register. The name of the entry must
  * be the content that this listener wants to handle, the value must be a
  * contract ID for the listener. It will be created using createInstance (not
  * getService).
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -1,20 +1,20 @@
 /* -*- 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 "nspr.h"
 #include "mozilla/dom/Document.h"
+#include "mozilla/Components.h"
 #include "mozilla/Logging.h"
 #include "mozilla/IntegerPrintfMacros.h"
 
 #include "nsDocLoader.h"
-#include "nsCURILoader.h"
 #include "nsNetUtil.h"
 #include "nsIHttpChannel.h"
 #include "nsIWebNavigation.h"
 #include "nsIWebProgressListener2.h"
 
 #include "nsIServiceManager.h"
 #include "nsString.h"
 
@@ -34,16 +34,17 @@
 #include "nsISocketTransport.h"
 #include "nsIDocShell.h"
 #include "mozilla/dom/Document.h"
 #include "nsPresContext.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsILoadURIDelegate.h"
 #include "nsIBrowserDOMWindow.h"
 
+using namespace mozilla;
 using mozilla::DebugOnly;
 using mozilla::LogLevel;
 using mozilla::dom::Document;
 
 //
 // Log module for nsIDocumentLoader logging...
 //
 // To enable logging (see mozilla/Logging.h for full details):
@@ -193,20 +194,19 @@ NS_IMETHODIMP nsDocLoader::GetInterface(
 already_AddRefed<nsDocLoader> nsDocLoader::GetAsDocLoader(
     nsISupports* aSupports) {
   RefPtr<nsDocLoader> ret = do_QueryObject(aSupports);
   return ret.forget();
 }
 
 /* static */
 nsresult nsDocLoader::AddDocLoaderAsChildOfRoot(nsDocLoader* aDocLoader) {
-  nsresult rv;
   nsCOMPtr<nsIDocumentLoader> docLoaderService =
-      do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID, &rv);
-  NS_ENSURE_SUCCESS(rv, rv);
+      components::DocLoader::Service();
+  NS_ENSURE_TRUE(docLoaderService, NS_ERROR_UNEXPECTED);
 
   RefPtr<nsDocLoader> rootDocLoader = GetAsDocLoader(docLoaderService);
   NS_ENSURE_TRUE(rootDocLoader, NS_ERROR_UNEXPECTED);
 
   return rootDocLoader->AddChildLoader(aDocLoader);
 }
 
 NS_IMETHODIMP
--- a/uriloader/base/nsURILoader.cpp
+++ b/uriloader/base/nsURILoader.cpp
@@ -34,17 +34,17 @@
 #include "nsIChildChannel.h"
 
 #include "nsString.h"
 #include "nsThreadUtils.h"
 #include "nsReadableUtils.h"
 #include "nsError.h"
 
 #include "nsICategoryManager.h"
-#include "nsCExternalHandlerService.h"  // contains contractids for the helper app service
+#include "nsCExternalHandlerService.h"
 
 #include "nsIMIMEHeaderParam.h"
 #include "nsNetCID.h"
 
 #include "nsMimeTypes.h"
 
 #include "nsDocLoader.h"
 #include "mozilla/Attributes.h"
--- a/uriloader/exthandler/ContentHandlerService.h
+++ b/uriloader/exthandler/ContentHandlerService.h
@@ -1,24 +1,20 @@
 #ifndef ContentHandlerService_h
 #define ContentHandlerService_h
 
+#include "mozilla/dom/PHandlerService.h"
 #include "nsIHandlerService.h"
 #include "nsClassHashtable.h"
-#include "HandlerServiceChild.h"
 #include "nsIMIMEInfo.h"
 
-#define NS_CONTENTHANDLERSERVICE_CID                 \
-  {                                                  \
-    0xc4b6fb7c, 0xbfb1, 0x49dc, {                    \
-      0xa6, 0x5f, 0x03, 0x57, 0x96, 0x52, 0x4b, 0x53 \
-    }                                                \
-  }
+namespace mozilla {
 
-namespace mozilla {
+class HandlerServiceChild;
+
 namespace dom {
 
 class PHandlerServiceChild;
 
 class ContentHandlerService : public nsIHandlerService {
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIHANDLERSERVICE
--- a/uriloader/exthandler/android/nsExternalURLHandlerService.h
+++ b/uriloader/exthandler/android/nsExternalURLHandlerService.h
@@ -3,24 +3,16 @@
  * 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/. */
 
 #ifndef NSEXTERNALURLHANDLERSERVICE_H
 #define NSEXTERNALURLHANDLERSERVICE_H
 
 #include "nsIExternalURLHandlerService.h"
 
-// {4BF1F8EF-D947-4BA3-9CD3-8C9A54A63A1C}
-#define NS_EXTERNALURLHANDLERSERVICE_CID             \
-  {                                                  \
-    0x4bf1f8ef, 0xd947, 0x4ba3, {                    \
-      0x9c, 0xd3, 0x8c, 0x9a, 0x54, 0xa6, 0x3a, 0x1c \
-    }                                                \
-  }
-
 class nsExternalURLHandlerService final : public nsIExternalURLHandlerService {
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIEXTERNALURLHANDLERSERVICE
 
   nsExternalURLHandlerService();
 
  private:
--- a/uriloader/exthandler/mac/nsOSHelperAppService.h
+++ b/uriloader/exthandler/mac/nsOSHelperAppService.h
@@ -9,19 +9,20 @@
 
 // The OS helper app service is a subclass of nsExternalHelperAppService and is
 // implemented on each platform. It contains platform specific code for finding
 // helper applications for a given mime type in addition to launching those
 // applications. This is the Mac version.
 
 #include "nsExternalHelperAppService.h"
 #include "nsCExternalHandlerService.h"
-#include "nsMIMEInfoImpl.h"
 #include "nsCOMPtr.h"
 
+class nsIMimeInfo;
+
 class nsOSHelperAppService : public nsExternalHelperAppService {
  public:
   virtual ~nsOSHelperAppService();
 
   // override nsIExternalProtocolService methods
   NS_IMETHOD GetApplicationDescription(const nsACString& aScheme,
                                        nsAString& _retval) override;
 
--- a/uriloader/exthandler/moz.build
+++ b/uriloader/exthandler/moz.build
@@ -38,16 +38,20 @@ EXPORTS += [
     'nsExternalHelperAppService.h',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     EXPORTS += [ '%s/%s' % (osdir, f) for f in [
         'nsExternalURLHandlerService.h',
     ]]
 
+EXPORTS += [
+    'nsLocalHandlerApp.h',
+]
+
 EXPORTS.mozilla.dom += [
     'ExternalHelperAppChild.h',
     'ExternalHelperAppParent.h',
 ]
 
 UNIFIED_SOURCES += [
     'ContentHandlerService.cpp',
     'ExternalHelperAppChild.cpp',
--- a/uriloader/exthandler/nsCExternalHandlerService.idl
+++ b/uriloader/exthandler/nsCExternalHandlerService.idl
@@ -9,50 +9,25 @@
 /*
 nsCExternalHelperApp implements:
 -------------------------
 nsIExternalHelperAppService
 */
 
 %{ C++
 
-/* A7F800E0-4306-11d4-98D0-001083010E9B */
-#define NS_EXTERNALHELPERAPPSERVICE_CID   \
- { 0xa7f800e0, 0x4306, 0x11d4, { 0x98, 0xd0, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } }
-
 #define NS_EXTERNALHELPERAPPSERVICE_CONTRACTID \
 "@mozilla.org/uriloader/external-helper-app-service;1"
 
 #define NS_HANDLERSERVICE_CONTRACTID \
 "@mozilla.org/uriloader/handler-service;1"
 
 #define NS_EXTERNALPROTOCOLSERVICE_CONTRACTID \
 "@mozilla.org/uriloader/external-protocol-service;1"
 
 #define NS_MIMESERVICE_CONTRACTID \
 "@mozilla.org/mime;1"
 
-#define NS_EXTERNALPROTOCOLHANDLER_CID	\
-{ 0xbd6390c8, 0xfbea, 0x11d4, {0x98, 0xf6, 0x0, 0x10, 0x83, 0x1, 0xe, 0x9b } }
-
-/* 9fa83ce7-d0ab-4ed3-938e-afafee435670 */
-#define NS_BLOCKEDEXTERNALPROTOCOLHANDLER_CID	\
-{ 0x9fa83ce7, 0xd0ab, 0x4ed3, {0x93, 0x8e, 0xaf, 0xaf, 0xee, 0x43, 0x56, 0x70 } }
-
-/* bc0017e3-2438-47be-a567-41db58f17627 */
-#define NS_LOCALHANDLERAPP_CID \
-{ 0xbc0017e3, 0x2438, 0x47be, {0xa5, 0x67, 0x41, 0xdb, 0x58, 0xf1, 0x76, 0x27 } }
-
-/*6c3c274b-4cbf-4bb5-a635-05ad2cbb6535*/
-#define NS_DBUSHANDLERAPP_CID \
-{ 0x6c3c274b, 0x4cbf, 0x4bb5, {0xa6, 0x35, 0x05, 0xad, 0x2c, 0xbb, 0x65, 0x35 } }
-
-#define NS_DBUSHANDLERAPP_CONTRACTID \
-"@mozilla.org/uriloader/dbus-handler-app;1"
-
 #define NS_LOCALHANDLERAPP_CONTRACTID \
 "@mozilla.org/uriloader/local-handler-app;1"
 
-#define NS_WEBHANDLERAPP_CONTRACTID \
-"@mozilla.org/uriloader/web-handler-app;1"
-
 %}
 
--- a/uriloader/exthandler/nsDBusHandlerApp.cpp
+++ b/uriloader/exthandler/nsDBusHandlerApp.cpp
@@ -1,25 +1,29 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * vim:expandtab:shiftwidth=2:tabstop=2:cin:
  * 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 <dbus/dbus.h>
+#include "mozilla/Components.h"
 #include "mozilla/DBusHelpers.h"
 #include "nsDBusHandlerApp.h"
 #include "nsIURI.h"
 #include "nsIClassInfoImpl.h"
 #include "nsCOMPtr.h"
 #include "nsCExternalHandlerService.h"
 
+using namespace mozilla;
+
 // XXX why does nsMIMEInfoImpl have a threadsafe nsISupports?  do we need one
 // here too?
-NS_IMPL_CLASSINFO(nsDBusHandlerApp, nullptr, 0, NS_DBUSHANDLERAPP_CID)
+NS_IMPL_CLASSINFO(nsDBusHandlerApp, nullptr, 0,
+                  components::DBusHandlerApp::CID())
 NS_IMPL_ISUPPORTS_CI(nsDBusHandlerApp, nsIDBusHandlerApp, nsIHandlerApp)
 
 ////////////////////////////////////////////////////////////////////////////////
 //// nsIHandlerApp
 
 NS_IMETHODIMP nsDBusHandlerApp::GetName(nsAString &aName) {
   aName.Assign(mName);
   return NS_OK;
--- a/uriloader/exthandler/unix/nsOSHelperAppService.h
+++ b/uriloader/exthandler/unix/nsOSHelperAppService.h
@@ -9,20 +9,20 @@
 
 // The OS helper app service is a subclass of nsExternalHelperAppService and is
 // implemented on each platform. It contains platform specific code for finding
 // helper applications for a given mime type in addition to launching those
 // applications.
 
 #include "nsExternalHelperAppService.h"
 #include "nsCExternalHandlerService.h"
-#include "nsMIMEInfoImpl.h"
 #include "nsCOMPtr.h"
 
 class nsILineInputStream;
+class nsMIMEInfoBase;
 
 class nsOSHelperAppService : public nsExternalHelperAppService {
  public:
   virtual ~nsOSHelperAppService();
 
   // method overrides for mime.types and mime.info look up steps
   already_AddRefed<nsIMIMEInfo> GetMIMEInfoFromOS(const nsACString& aMimeType,
                                                   const nsACString& aFileExt,
--- a/uriloader/exthandler/win/nsOSHelperAppService.h
+++ b/uriloader/exthandler/win/nsOSHelperAppService.h
@@ -8,27 +8,27 @@
 
 // The OS helper app service is a subclass of nsExternalHelperAppService and is
 // implemented on each platform. It contains platform specific code for finding
 // helper applications for a given mime type in addition to launching those
 // applications.
 
 #include "nsExternalHelperAppService.h"
 #include "nsCExternalHandlerService.h"
-#include "nsMIMEInfoImpl.h"
 #include "nsCOMPtr.h"
 #include <windows.h>
 
 #ifdef _WIN32_WINNT
 #  undef _WIN32_WINNT
 #endif
 #define _WIN32_WINNT 0x0600
 #include <shlobj.h>
 
 class nsMIMEInfoWin;
+class nsIMIMEInfo;
 
 class nsOSHelperAppService : public nsExternalHelperAppService {
  public:
   nsOSHelperAppService();
   virtual ~nsOSHelperAppService();
 
   // override nsIExternalProtocolService methods
   nsresult OSProtocolHandlerExists(const char* aProtocolScheme,
--- a/uriloader/prefetch/moz.build
+++ b/uriloader/prefetch/moz.build
@@ -9,20 +9,16 @@ with Files("**"):
 
 XPIDL_SOURCES += [
     'nsIOfflineCacheUpdate.idl',
     'nsIPrefetchService.idl',
 ]
 
 XPIDL_MODULE = 'prefetch'
 
-EXPORTS += [
-    'nsCPrefetchService.h',
-]
-
 EXPORTS.mozilla.docshell += [
     'OfflineCacheUpdateChild.h',
     'OfflineCacheUpdateParent.h',
 ]
 
 UNIFIED_SOURCES += [
     'nsOfflineCacheUpdate.cpp',
     'nsOfflineCacheUpdateService.cpp',
deleted file mode 100644
--- a/uriloader/prefetch/nsCPrefetchService.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* 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/. */
-
-#ifndef nsCPrefetchService_h__
-#define nsCPrefetchService_h__
-
-#include "nsIPrefetchService.h"
-
-/**
- * nsPrefetchService : nsIPrefetchService
- */
-#define NS_PREFETCHSERVICE_CONTRACTID "@mozilla.org/prefetch-service;1"
-#define NS_PREFETCHSERVICE_CID                       \
-  { /* 6b8bdffc-3394-417d-be83-a81b7c0f63bf */       \
-    0x6b8bdffc, 0x3394, 0x417d, {                    \
-      0xbe, 0x83, 0xa8, 0x1b, 0x7c, 0x0f, 0x63, 0xbf \
-    }                                                \
-  }
-
-/**
- * nsOfflineCacheUpdateService : nsIOfflineCacheUpdateService
- */
-
-#define NS_OFFLINECACHEUPDATESERVICE_CONTRACTID \
-  "@mozilla.org/offlinecacheupdate-service;1"
-#define NS_OFFLINECACHEUPDATESERVICE_CID             \
-  { /* ec06f3fc-70db-4ecd-94e0-a6e91ca44d8a */       \
-    0xec06f3fc, 0x70db, 0x4ecd, {                    \
-      0x94, 0xe0, 0xa6, 0xe9, 0x1c, 0xa4, 0x4d, 0x8a \
-    }                                                \
-  }
-
-#endif  // !nsCPrefetchService_h__
--- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp
@@ -1,16 +1,15 @@
 /* -*- 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 "nsOfflineCacheUpdate.h"
 
-#include "nsCPrefetchService.h"
 #include "nsCURILoader.h"
 #include "nsIApplicationCacheContainer.h"
 #include "nsIApplicationCacheChannel.h"
 #include "nsIApplicationCacheService.h"
 #include "nsICachingChannel.h"
 #include "nsIContent.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/OfflineResourceListBinding.h"
--- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "OfflineCacheUpdateChild.h"
 #include "OfflineCacheUpdateParent.h"
 #include "nsXULAppAPI.h"
 #include "OfflineCacheUpdateGlue.h"
 #include "nsOfflineCacheUpdate.h"
 
-#include "nsCPrefetchService.h"
 #include "nsCURILoader.h"
 #include "nsIApplicationCacheContainer.h"
 #include "nsIApplicationCacheChannel.h"
 #include "nsIApplicationCacheService.h"
 #include "nsICachingChannel.h"
 #include "nsIContent.h"
 #include "nsIDocShell.h"
 #include "nsIDocumentLoader.h"
@@ -23,22 +22,24 @@
 #include "nsIObserverService.h"
 #include "nsIURL.h"
 #include "nsIWebProgress.h"
 #include "nsIWebNavigation.h"
 #include "nsICryptoHash.h"
 #include "nsIPermissionManager.h"
 #include "nsIPrincipal.h"
 #include "nsNetCID.h"
+#include "nsNetUtil.h"
 #include "nsServiceManagerUtils.h"
 #include "nsStreamUtils.h"
 #include "nsThreadUtils.h"
 #include "nsProxyRelease.h"
 #include "mozilla/Logging.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
+#include "mozilla/Components.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/Unused.h"
 #include "nsIDocShell.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/PermissionMessageUtils.h"
@@ -280,17 +281,18 @@ nsOfflineCacheUpdateService::GetInstance
   return do_AddRef(gOfflineCacheUpdateService);
 }
 
 /* static */
 nsOfflineCacheUpdateService *nsOfflineCacheUpdateService::EnsureService() {
   if (!gOfflineCacheUpdateService) {
     // Make the service manager hold a long-lived reference to the service
     nsCOMPtr<nsIOfflineCacheUpdateService> service =
-        do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID);
+        components::OfflineCacheUpdate::Service();
+    Unused << service;
   }
 
   return gOfflineCacheUpdateService;
 }
 
 nsresult nsOfflineCacheUpdateService::ScheduleUpdate(
     nsOfflineCacheUpdate *aUpdate) {
   LOG(("nsOfflineCacheUpdateService::Schedule [%p, update=%p]", this, aUpdate));
--- a/uriloader/prefetch/nsPrefetchService.cpp
+++ b/uriloader/prefetch/nsPrefetchService.cpp
@@ -3,27 +3,27 @@
  * 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 "nsPrefetchService.h"
 
 #include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/CORSMode.h"
+#include "mozilla/Components.h"
 #include "mozilla/dom/ClientInfo.h"
 #include "mozilla/dom/HTMLLinkElement.h"
 #include "mozilla/dom/ServiceWorkerDescriptor.h"
 #include "mozilla/Preferences.h"
 
 #include "nsICacheEntry.h"
 #include "nsIServiceManager.h"
 #include "nsICategoryManager.h"
 #include "nsIObserverService.h"
 #include "nsIWebProgress.h"
-#include "nsCURILoader.h"
 #include "nsICacheInfoChannel.h"
 #include "nsIHttpChannel.h"
 #include "nsIURL.h"
 #include "nsISimpleEnumerator.h"
 #include "nsISupportsPriority.h"
 #include "nsNetUtil.h"
 #include "nsString.h"
 #include "nsReadableUtils.h"
@@ -476,26 +476,24 @@ void nsPrefetchService::DispatchEvent(ns
 }
 
 //-----------------------------------------------------------------------------
 // nsPrefetchService <private>
 //-----------------------------------------------------------------------------
 
 void nsPrefetchService::AddProgressListener() {
   // Register as an observer for the document loader
-  nsCOMPtr<nsIWebProgress> progress =
-      do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIWebProgress> progress = components::DocLoader::Service();
   if (progress)
     progress->AddProgressListener(this, nsIWebProgress::NOTIFY_STATE_DOCUMENT);
 }
 
 void nsPrefetchService::RemoveProgressListener() {
   // Register as an observer for the document loader
-  nsCOMPtr<nsIWebProgress> progress =
-      do_GetService(NS_DOCUMENTLOADER_SERVICE_CONTRACTID);
+  nsCOMPtr<nsIWebProgress> progress = components::DocLoader::Service();
   if (progress) progress->RemoveProgressListener(this);
 }
 
 nsresult nsPrefetchService::EnqueueURI(nsIURI *aURI, nsIURI *aReferrerURI,
                                        nsINode *aSource,
                                        nsPrefetchNode **aNode) {
   RefPtr<nsPrefetchNode> node = new nsPrefetchNode(
       this, aURI, aReferrerURI, aSource, nsIContentPolicy::TYPE_OTHER, false);
--- a/uriloader/prefetch/nsPrefetchService.h
+++ b/uriloader/prefetch/nsPrefetchService.h
@@ -1,19 +1,19 @@
 /* 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/. */
 
 #ifndef nsPrefetchService_h__
 #define nsPrefetchService_h__
 
-#include "nsCPrefetchService.h"
 #include "nsIObserver.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIChannelEventSink.h"
+#include "nsIPrefetchService.h"
 #include "nsIRedirectResultListener.h"
 #include "nsIWebProgressListener.h"
 #include "nsIStreamListener.h"
 #include "nsIChannel.h"
 #include "nsIURI.h"
 #include "nsWeakReference.h"
 #include "nsCOMPtr.h"
 #include "nsAutoPtr.h"
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -19,17 +19,16 @@
 #include "nsIGeolocationProvider.h"
 #include "nsCacheService.h"
 #include "nsIDOMEventListener.h"
 #include "nsIDOMWakeLockListener.h"
 #include "nsIPowerManagerService.h"
 #include "nsISpeculativeConnect.h"
 #include "nsIURIFixup.h"
 #include "nsCategoryManagerUtils.h"
-#include "nsCDefaultURIFixup.h"
 #include "nsGeoPosition.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Components.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/Services.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Hal.h"
@@ -735,17 +734,17 @@ already_AddRefed<nsIURI> nsAppShell::Res
   nsCOMPtr<nsIIOService> ioServ = do_GetIOService();
   nsCOMPtr<nsIURI> uri;
 
   if (NS_SUCCEEDED(
           ioServ->NewURI(aUriStr, nullptr, nullptr, getter_AddRefs(uri)))) {
     return uri.forget();
   }
 
-  nsCOMPtr<nsIURIFixup> fixup = do_GetService(NS_URIFIXUP_CONTRACTID);
+  nsCOMPtr<nsIURIFixup> fixup = components::URIFixup::Service();
   if (fixup && NS_SUCCEEDED(fixup->CreateFixupURI(aUriStr, 0, nullptr,
                                                   getter_AddRefs(uri)))) {
     return uri.forget();
   }
   return nullptr;
 }
 
 nsresult nsAppShell::AddObserver(const nsAString& aObserverKey,
--- a/xpfe/appshell/nsContentTreeOwner.cpp
+++ b/xpfe/appshell/nsContentTreeOwner.cpp
@@ -19,24 +19,24 @@
 #include "nsIBrowserDOMWindow.h"
 #include "nsIEmbeddingSiteWindow.h"
 #include "nsIPrompt.h"
 #include "nsIAuthPrompt.h"
 #include "nsIWindowMediator.h"
 #include "nsIXULBrowserWindow.h"
 #include "nsIPrincipal.h"
 #include "nsIURIFixup.h"
-#include "nsCDefaultURIFixup.h"
 #include "nsIWebNavigation.h"
 #include "nsDocShellCID.h"
 #include "nsIExternalURLHandlerService.h"
 #include "nsIMIMEInfo.h"
 #include "nsIWidget.h"
 #include "nsWindowWatcher.h"
 #include "mozilla/BrowserElementParent.h"
+#include "mozilla/Components.h"
 #include "mozilla/NullPrincipal.h"
 #include "nsDocShell.h"
 #include "nsDocShellLoadState.h"
 
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIURI.h"
 #include "mozilla/dom/Document.h"
 #if defined(XP_MACOSX)
@@ -655,17 +655,17 @@ NS_IMETHODIMP nsContentTreeOwner::SetTit
         nsCOMPtr<nsIURI> uri;
         nsIPrincipal* principal = doc->GetPrincipal();
         if (principal) {
           principal->GetURI(getter_AddRefs(uri));
           if (uri) {
             //
             // remove any user:pass information
             //
-            nsCOMPtr<nsIURIFixup> fixup(do_GetService(NS_URIFIXUP_CONTRACTID));
+            nsCOMPtr<nsIURIFixup> fixup(components::URIFixup::Service());
             if (fixup) {
               nsCOMPtr<nsIURI> tmpuri;
               nsresult rv =
                   fixup->CreateExposableURI(uri, getter_AddRefs(tmpuri));
               if (NS_SUCCEEDED(rv) && tmpuri) {
                 // (don't bother if there's no host)
                 nsAutoCString host;
                 nsAutoCString prepath;