From 680bd635809aeae960a3790111644ffe0556339b Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 30 May 2024 21:18:43 +0000 Subject: [PATCH] Bug 1895232 - Convert do_GetService to using components::*::service in netwerk/ r=valentin,cookie-reviewers,places-reviewers Differential Revision: https://phabricator.services.mozilla.com/D209747 --- intl/uconv/components.conf | 1 + layout/build/components.conf | 2 ++ netwerk/base/BackgroundFileSaver.cpp | 9 ++--- netwerk/base/Dashboard.cpp | 10 +++--- netwerk/base/EventTokenBucket.cpp | 5 ++- netwerk/base/Predictor.cpp | 12 +++---- netwerk/base/TLSServerSocket.cpp | 5 +-- netwerk/base/ThrottleQueue.cpp | 3 +- netwerk/base/nsAsyncStreamCopier.cpp | 3 +- netwerk/base/nsIOService.cpp | 19 +++++----- netwerk/base/nsNetUtil.cpp | 35 ++++++++++--------- netwerk/base/nsStreamTransportService.cpp | 5 +-- netwerk/base/nsUDPSocket.cpp | 9 ++--- netwerk/build/components.conf | 10 ++++++ netwerk/cookie/CookieService.cpp | 7 ++-- netwerk/dns/DNSRequestParent.cpp | 7 ++-- netwerk/dns/TRRServiceChild.cpp | 5 +-- netwerk/dns/nsEffectiveTLDService.cpp | 7 ++-- netwerk/ipc/DocumentLoadListener.cpp | 5 +-- netwerk/ipc/NeckoChild.cpp | 13 +++---- netwerk/ipc/NeckoParent.cpp | 13 +++---- netwerk/ipc/ProxyConfigLookup.cpp | 5 +-- netwerk/ipc/SocketProcessBridgeChild.cpp | 5 +-- netwerk/ipc/SocketProcessChild.cpp | 22 ++++++------ netwerk/protocol/about/nsAboutCache.cpp | 6 ++-- netwerk/protocol/file/nsFileChannel.cpp | 8 ++--- netwerk/protocol/http/CachePushChecker.cpp | 5 +-- netwerk/protocol/http/DnsAndConnectSocket.cpp | 8 ++--- netwerk/protocol/http/HttpChannelParent.cpp | 5 +-- netwerk/protocol/http/NullHttpTransaction.cpp | 3 +- .../protocol/http/ParentChannelListener.cpp | 9 ++--- netwerk/protocol/http/nsCORSListenerProxy.cpp | 3 +- netwerk/protocol/http/nsHttpChannel.cpp | 34 +++++++++--------- .../http/nsHttpChannelAuthProvider.cpp | 5 +-- netwerk/protocol/http/nsHttpHandler.cpp | 22 ++++++------ .../protocol/res/ExtensionProtocolHandler.cpp | 5 +-- .../protocol/res/PageThumbProtocolHandler.cpp | 9 ++--- .../protocol/websocket/WebSocketChannel.cpp | 32 ++++++++--------- .../websocket/WebSocketConnection.cpp | 3 +- .../websocket/WebSocketConnectionChild.cpp | 3 +- netwerk/sctp/datachannel/DataChannel.cpp | 7 ++-- netwerk/socket/nsSOCKSIOLayer.cpp | 6 ++-- .../streamconv/converters/nsIndexedToHTML.cpp | 7 ++-- .../converters/nsMultiMixedConv.cpp | 5 +-- .../streamconv/nsStreamConverterService.cpp | 3 +- netwerk/system/mac/nsNetworkLinkService.mm | 13 +++---- .../url-classifier/UrlClassifierCommon.cpp | 8 ++--- .../url-classifier/nsChannelClassifier.cpp | 4 +-- netwerk/wifi/nsWifiMonitor.cpp | 5 +-- security/manager/ssl/components.conf | 5 +++ toolkit/components/places/components.conf | 1 + .../components/prompts/src/components.conf | 1 + toolkit/components/thumbnails/components.conf | 1 + toolkit/xre/components.conf | 1 + xpcom/build/components.conf | 2 ++ xpcom/components/components.conf | 1 + 56 files changed, 259 insertions(+), 188 deletions(-) diff --git a/intl/uconv/components.conf b/intl/uconv/components.conf index 00686f661a92..7476f1293814 100644 --- a/intl/uconv/components.conf +++ b/intl/uconv/components.conf @@ -24,6 +24,7 @@ Classes = [ 'headers': ['/intl/uconv/nsScriptableUConv.h'], }, { + 'name': 'TextToSubURI', 'js_name': 'textToSubURI', 'cid': '{8b042e22-6f87-11d3-b3c8-00805f8a6670}', 'contract_ids': ['@mozilla.org/intl/texttosuburi;1'], diff --git a/layout/build/components.conf b/layout/build/components.conf index eb834a20a171..2df60e3a84da 100644 --- a/layout/build/components.conf +++ b/layout/build/components.conf @@ -112,6 +112,7 @@ Classes = [ 'init_method': 'Init', }, { + 'name': 'ContentSecurityManager', 'cid': '{cdcc1ab8-3cea-4e6c-a294-a651fa35227f}', 'contract_ids': ['@mozilla.org/contentsecuritymanager;1'], 'type': 'nsContentSecurityManager', @@ -363,6 +364,7 @@ Classes = [ 'headers': ['/dom/bindings/nsScriptError.h'], }, { + 'name': 'ScriptSecurityManager', 'js_name': 'scriptSecurityManager', 'cid': '{7ee2a4c0-4b93-17d3-ba18-0060b0f199a2}', 'contract_ids': ['@mozilla.org/scriptsecuritymanager;1'], diff --git a/netwerk/base/BackgroundFileSaver.cpp b/netwerk/base/BackgroundFileSaver.cpp index 3af6b8eb2664..07b34ae8033a 100644 --- a/netwerk/base/BackgroundFileSaver.cpp +++ b/netwerk/base/BackgroundFileSaver.cpp @@ -8,6 +8,7 @@ #include "ScopedNSSTypes.h" #include "mozilla/ArrayAlgorithm.h" +#include "mozilla/Components.h" #include "mozilla/Casting.h" #include "mozilla/Logging.h" #include "mozilla/ScopeExit.h" @@ -194,8 +195,8 @@ BackgroundFileSaver::EnableSha256() { "Can't enable sha256 or initialize NSS off the main thread"); // Ensure Personal Security Manager is initialized. This is required for // PK11_* operations to work. - nsresult rv; - nsCOMPtr nssDummy = do_GetService("@mozilla.org/psm;1", &rv); + nsresult rv = NS_OK; + mozilla::components::NSSComponent::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); MutexAutoLock lock(mLock); mSha256Enabled = true; // this will be read by the worker thread @@ -219,8 +220,8 @@ BackgroundFileSaver::EnableSignatureInfo() { MOZ_ASSERT(NS_IsMainThread(), "Can't enable signature extraction off the main thread"); // Ensure Personal Security Manager is initialized. - nsresult rv; - nsCOMPtr nssDummy = do_GetService("@mozilla.org/psm;1", &rv); + nsresult rv = NS_OK; + mozilla::components::NSSComponent::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); MutexAutoLock lock(mLock); mSignatureInfoEnabled = true; diff --git a/netwerk/base/Dashboard.cpp b/netwerk/base/Dashboard.cpp index bc1619ee6095..f69d355327d6 100644 --- a/netwerk/base/Dashboard.cpp +++ b/netwerk/base/Dashboard.cpp @@ -4,6 +4,7 @@ #include "mozilla/dom/NetDashboardBinding.h" #include "mozilla/dom/ToJSValue.h" +#include "mozilla/Components.h" #include "mozilla/ErrorNames.h" #include "mozilla/net/Dashboard.h" #include "mozilla/net/HttpInfo.h" @@ -821,7 +822,7 @@ Dashboard::RequestDNSInfo(nsINetDashboardCallback* aCallback) { dnsData->mEventTarget = GetCurrentSerialEventTarget(); if (!mDnsService) { - mDnsService = do_GetService("@mozilla.org/network/dns-service;1", &rv); + mDnsService = mozilla::components::DNS::Service(&rv); if (NS_FAILED(rv)) { return rv; } @@ -931,7 +932,7 @@ Dashboard::RequestDNSLookup(const nsACString& aHost, nsresult rv; if (!mDnsService) { - mDnsService = do_GetService("@mozilla.org/network/dns-service;1", &rv); + mDnsService = mozilla::components::DNS::Service(&rv); if (NS_FAILED(rv)) { return rv; } @@ -955,7 +956,7 @@ Dashboard::RequestDNSHTTPSRRLookup(const nsACString& aHost, nsresult rv; if (!mDnsService) { - mDnsService = do_GetService("@mozilla.org/network/dns-service;1", &rv); + mDnsService = mozilla::components::DNS::Service(&rv); if (NS_FAILED(rv)) { return rv; } @@ -1150,8 +1151,7 @@ using ErrorEntry = struct { }; #undef ERROR -#define ERROR(key, val) \ - { key, #key } +#define ERROR(key, val) {key, #key} ErrorEntry socketTransportStatuses[] = { ERROR(NS_NET_STATUS_RESOLVING_HOST, FAILURE(3)), diff --git a/netwerk/base/EventTokenBucket.cpp b/netwerk/base/EventTokenBucket.cpp index 87179d6732db..bcace902cf79 100644 --- a/netwerk/base/EventTokenBucket.cpp +++ b/netwerk/base/EventTokenBucket.cpp @@ -12,6 +12,9 @@ #include "nsNetUtil.h" #include "nsServiceManagerUtils.h" #include "nsSocketTransportService2.h" + +#include "mozilla/Components.h" + #ifdef DEBUG # include "MainThreadUtils.h" #endif @@ -91,7 +94,7 @@ EventTokenBucket::EventTokenBucket(uint32_t eventsPerSecond, uint32_t burstSize) nsCOMPtr sts; nsCOMPtr ioService = do_GetIOService(&rv); if (NS_SUCCEEDED(rv)) { - sts = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv); + sts = mozilla::components::SocketTransport::Service(&rv); } if (NS_SUCCEEDED(rv)) mTimer = NS_NewTimer(sts); SetRate(eventsPerSecond, burstSize); diff --git a/netwerk/base/Predictor.cpp b/netwerk/base/Predictor.cpp index be1c55ee7cef..f005565c761b 100644 --- a/netwerk/base/Predictor.cpp +++ b/netwerk/base/Predictor.cpp @@ -33,6 +33,7 @@ #include "nsThreadUtils.h" #include "mozilla/Logging.h" +#include "mozilla/Components.h" #include "mozilla/OriginAttributes.h" #include "mozilla/Preferences.h" #include "mozilla/SchedulerGroup.h" @@ -365,17 +366,16 @@ nsresult Predictor::Init() { mDNSListener = new DNSListener(); } - mCacheStorageService = - do_GetService("@mozilla.org/netwerk/cache-storage-service;1", &rv); + mCacheStorageService = mozilla::components::CacheStorage::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); - mSpeculativeService = do_GetService("@mozilla.org/network/io-service;1", &rv); + mSpeculativeService = mozilla::components::IO::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); rv = NS_NewURI(getter_AddRefs(mStartupURI), "predictor://startup"); NS_ENSURE_SUCCESS(rv, rv); - mDnsService = do_GetService("@mozilla.org/network/dns-service;1", &rv); + mDnsService = mozilla::components::DNS::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); mInitialized = true; @@ -1923,8 +1923,8 @@ static nsresult EnsureGlobalPredictor(nsINetworkPredictor** aPredictor) { if (!sPredictor) { nsresult rv; - nsCOMPtr predictor = - do_GetService("@mozilla.org/network/predictor;1", &rv); + nsCOMPtr predictor; + predictor = mozilla::components::Predictor::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); sPredictor = predictor; ClearOnShutdown(&sPredictor); diff --git a/netwerk/base/TLSServerSocket.cpp b/netwerk/base/TLSServerSocket.cpp index 131ea50573b3..8887a8090d04 100644 --- a/netwerk/base/TLSServerSocket.cpp +++ b/netwerk/base/TLSServerSocket.cpp @@ -6,6 +6,7 @@ #include "TLSServerSocket.h" #include "mozilla/net/DNS.h" +#include "mozilla/Components.h" #include "nsComponentManagerUtils.h" #include "nsDependentSubstring.h" #include "nsIServerSocket.h" @@ -391,8 +392,8 @@ nsresult TLSServerConnectionInfo::HandshakeCallback(PRFileDesc* aFD) { UniqueCERTCertificate clientCert(SSL_PeerCertificate(aFD)); if (clientCert) { - nsCOMPtr certDB = - do_GetService(NS_X509CERTDB_CONTRACTID, &rv); + nsCOMPtr certDB; + certDB = mozilla::components::NSSCertificateDB::Service(&rv); if (NS_FAILED(rv)) { return rv; } diff --git a/netwerk/base/ThrottleQueue.cpp b/netwerk/base/ThrottleQueue.cpp index 4313a6ecb3a2..83ab30efbe85 100644 --- a/netwerk/base/ThrottleQueue.cpp +++ b/netwerk/base/ThrottleQueue.cpp @@ -5,6 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "ThrottleQueue.h" +#include "mozilla/Components.h" #include "mozilla/net/InputChannelThrottleQueueParent.h" #include "nsISeekableStream.h" #include "nsIAsyncInputStream.h" @@ -251,7 +252,7 @@ ThrottleQueue::ThrottleQueue() nsCOMPtr sts; nsCOMPtr ioService = do_GetIOService(&rv); if (NS_SUCCEEDED(rv)) { - sts = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv); + sts = mozilla::components::SocketTransport::Service(&rv); } if (NS_SUCCEEDED(rv)) mTimer = NS_NewTimer(sts); } diff --git a/netwerk/base/nsAsyncStreamCopier.cpp b/netwerk/base/nsAsyncStreamCopier.cpp index de8363d17df6..ffcfafc9da9c 100644 --- a/netwerk/base/nsAsyncStreamCopier.cpp +++ b/netwerk/base/nsAsyncStreamCopier.cpp @@ -12,6 +12,7 @@ #include "nsNetCID.h" #include "nsIBufferedStreams.h" #include "nsIRequestObserver.h" +#include "mozilla/Components.h" #include "mozilla/Logging.h" using namespace mozilla; @@ -251,7 +252,7 @@ nsresult nsAsyncStreamCopier::InitInternal( mTarget = target; } else { nsresult rv; - mTarget = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv); + mTarget = mozilla::components::StreamTransport::Service(&rv); if (NS_FAILED(rv)) { return rv; } diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index f11435f81bb4..fdb11f500ac1 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -41,6 +41,7 @@ #include "nsThreadUtils.h" #include "WebTransportSessionProxy.h" #include "mozilla/AppShutdown.h" +#include "mozilla/Components.h" #include "mozilla/LoadInfo.h" #include "mozilla/net/NeckoCommon.h" #include "mozilla/Services.h" @@ -452,7 +453,7 @@ nsresult nsIOService::InitializeCaptivePortalService() { return NS_OK; } - mCaptivePortalService = do_GetService(NS_CAPTIVEPORTAL_CID); + mCaptivePortalService = mozilla::components::CaptivePortal::Service(); if (mCaptivePortalService) { static_cast(mCaptivePortalService.get()) ->Initialize(); @@ -477,7 +478,7 @@ nsresult nsIOService::InitializeSocketTransportService() { if (!mSocketTransportService) { mSocketTransportService = - do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv); + mozilla::components::SocketTransport::Service(&rv); if (NS_FAILED(rv)) { NS_WARNING("failed to get socket transport service"); } @@ -524,7 +525,7 @@ nsresult nsIOService::InitializeProtocolProxyService() { if (XRE_IsParentProcess()) { // for early-initialization - Unused << do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv); + Unused << mozilla::components::ProtocolProxy::Service(&rv); } return rv; @@ -853,8 +854,8 @@ nsresult nsIOService::AsyncOnChannelRedirect( // This is silly. I wish there was a simpler way to get at the global // reference of the contentSecurityManager. But it lives in the XPCOM // service registry. - nsCOMPtr sink = - do_GetService(NS_CONTENTSECURITYMANAGER_CONTRACTID); + nsCOMPtr sink; + sink = mozilla::components::ContentSecurityManager::Service(); if (sink) { nsresult rv = helper->DelegateOnChannelRedirect(sink, oldChan, newChan, flags); @@ -1190,8 +1191,8 @@ nsresult nsIOService::NewChannelFromURIWithProxyFlagsInternal( if (!gHasWarnedUploadChannel2 && scheme.EqualsLiteral("http")) { nsCOMPtr uploadChannel2 = do_QueryInterface(channel); if (!uploadChannel2) { - nsCOMPtr consoleService = - do_GetService(NS_CONSOLESERVICE_CONTRACTID); + nsCOMPtr consoleService; + consoleService = mozilla::components::Console::Service(); if (consoleService) { consoleService->LogStringMessage( u"Http channel implementation " @@ -2051,8 +2052,8 @@ nsresult nsIOService::SpeculativeConnectInternal( // speculative connect should not be performed because the potential // reward is slim with tcp peers closely located to the browser. nsresult rv; - nsCOMPtr pps = - do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv); + nsCOMPtr pps; + pps = mozilla::components::ProtocolProxy::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr loadingPrincipal = aPrincipal; diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp index 413fbd3ed659..b700c7e0dd31 100644 --- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -128,7 +128,8 @@ using mozilla::dom::ServiceWorkerDescriptor; #define MAX_RECURSION_COUNT 50 already_AddRefed do_GetIOService(nsresult* error /* = 0 */) { - nsCOMPtr io = mozilla::components::IO::Service(); + nsCOMPtr io; + io = mozilla::components::IO::Service(); if (error) *error = io ? NS_OK : NS_ERROR_FAILURE; return io.forget(); } @@ -1132,8 +1133,8 @@ nsresult NS_CheckPortSafety(nsIURI* uri) { nsresult NS_NewProxyInfo(const nsACString& type, const nsACString& host, int32_t port, uint32_t flags, nsIProxyInfo** result) { nsresult rv; - nsCOMPtr pps = - do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv); + nsCOMPtr pps; + pps = mozilla::components::ProtocolProxy::Service(&rv); if (NS_SUCCEEDED(rv)) { rv = pps->NewProxyInfo(type, host, port, ""_ns, ""_ns, flags, UINT32_MAX, nullptr, result); @@ -1222,8 +1223,10 @@ void NS_GetReferrerFromChannel(nsIChannel* channel, nsIURI** referrer) { } already_AddRefed do_GetNetUtil(nsresult* error /* = 0 */) { - nsCOMPtr io = mozilla::components::IO::Service(); + nsCOMPtr io; nsCOMPtr util; + + io = mozilla::components::IO::Service(); if (io) util = do_QueryInterface(io); if (error) *error = !!util ? NS_OK : NS_ERROR_FAILURE; @@ -1556,8 +1559,8 @@ class BufferWriter final : public nsIInputStreamCallback { NS_ASSERT_OWNINGTHREAD(BufferWriter); if (!mTaskQueue) { - nsCOMPtr target = - do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID); + nsCOMPtr target; + target = mozilla::components::StreamTransport::Service(); if (!target) { return NS_ERROR_FAILURE; } @@ -2216,8 +2219,8 @@ bool NS_IsSafeMethodNav(nsIChannel* aChannel) { void NS_WrapAuthPrompt(nsIAuthPrompt* aAuthPrompt, nsIAuthPrompt2** aAuthPrompt2) { - nsCOMPtr factory = - do_GetService(NS_AUTHPROMPT_ADAPTER_FACTORY_CONTRACTID); + nsCOMPtr factory; + factory = mozilla::components::AuthPromptAdapter::Service(); if (!factory) return; NS_WARNING("Using deprecated nsIAuthPrompt"); @@ -2719,8 +2722,8 @@ uint32_t NS_GetContentDispositionFromToken(const nsAString& aDispToken) { uint32_t NS_GetContentDispositionFromHeader(const nsACString& aHeader, nsIChannel* aChan /* = nullptr */) { nsresult rv; - nsCOMPtr mimehdrpar = - do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv); + nsCOMPtr mimehdrpar; + mimehdrpar = mozilla::components::MimeHeaderParam::Service(&rv); if (NS_FAILED(rv)) return nsIChannel::DISPOSITION_ATTACHMENT; nsAutoString dispToken; @@ -2743,8 +2746,8 @@ nsresult NS_GetFilenameFromDisposition(nsAString& aFilename, aFilename.Truncate(); nsresult rv; - nsCOMPtr mimehdrpar = - do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv); + nsCOMPtr mimehdrpar; + mimehdrpar = mozilla::components::MimeHeaderParam::Service(&rv); if (NS_FAILED(rv)) return rv; // Get the value of 'filename' parameter @@ -2760,8 +2763,8 @@ nsresult NS_GetFilenameFromDisposition(nsAString& aFilename, // Filename may still be percent-encoded. Fix: if (aFilename.FindChar('%') != -1) { - nsCOMPtr textToSubURI = - do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv); + nsCOMPtr textToSubURI; + textToSubURI = mozilla::components::TextToSubURI::Service(&rv); if (NS_SUCCEEDED(rv)) { nsAutoString unescaped; textToSubURI->UnEscapeURIForUI(NS_ConvertUTF16toUTF8(aFilename), @@ -3511,8 +3514,8 @@ already_AddRefed TryChangeProtocol(nsIURI* aURI, // passed value alone) static bool Decode5987Format(nsAString& aEncoded) { nsresult rv; - nsCOMPtr mimehdrpar = - do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv); + nsCOMPtr mimehdrpar; + mimehdrpar = mozilla::components::MimeHeaderParam::Service(&rv); if (NS_FAILED(rv)) return false; nsAutoCString asciiValue; diff --git a/netwerk/base/nsStreamTransportService.cpp b/netwerk/base/nsStreamTransportService.cpp index 19776b2ac2d8..37e56ceb63c9 100644 --- a/netwerk/base/nsStreamTransportService.cpp +++ b/netwerk/base/nsStreamTransportService.cpp @@ -17,6 +17,7 @@ #include "nsITransport.h" #include "nsIObserverService.h" #include "nsThreadPool.h" +#include "mozilla/Components.h" #include "mozilla/Services.h" namespace mozilla { @@ -91,8 +92,8 @@ nsInputStreamTransport::OpenInputStream(uint32_t flags, uint32_t segsize, NS_ENSURE_TRUE(!mInProgress, NS_ERROR_IN_PROGRESS); nsresult rv; - nsCOMPtr target = - do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv); + nsCOMPtr target; + target = mozilla::components::StreamTransport::Service(&rv); if (NS_FAILED(rv)) return rv; // XXX if the caller requests an unbuffered stream, then perhaps diff --git a/netwerk/base/nsUDPSocket.cpp b/netwerk/base/nsUDPSocket.cpp index 70177f289e08..e4f1efc9456e 100644 --- a/netwerk/base/nsUDPSocket.cpp +++ b/netwerk/base/nsUDPSocket.cpp @@ -3,7 +3,9 @@ * 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 "Predictor.h" #include "mozilla/Attributes.h" +#include "mozilla/Components.h" #include "mozilla/EndianUtils.h" #include "mozilla/dom/TypedArray.h" #include "mozilla/HoldDropJSObjects.h" @@ -60,8 +62,8 @@ static nsresult ResolveHost(const nsACString& host, nsIDNSListener* listener) { nsresult rv; - nsCOMPtr dns = - do_GetService("@mozilla.org/network/dns-service;1", &rv); + nsCOMPtr dns; + dns = mozilla::components::DNS::Service(&rv); if (NS_FAILED(rv)) { return rv; } @@ -245,8 +247,7 @@ nsUDPSocket::nsUDPSocket() { // constructed yet. the STS constructor sets gSocketTransportService. if (!gSocketTransportService) { // This call can fail if we're offline, for example. - nsCOMPtr sts = - do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID); + mozilla::components::SocketTransport::Service(); } mSts = gSocketTransportService; diff --git a/netwerk/build/components.conf b/netwerk/build/components.conf index bebf9695e4a0..2e7cbbd2e9a4 100644 --- a/netwerk/build/components.conf +++ b/netwerk/build/components.conf @@ -100,6 +100,7 @@ Classes = [ 'headers': ['/netwerk/base/nsBufferedStreams.h'], }, { + 'name': 'CaptivePortal', 'cid': '{bdbe0555-fc3d-4f7b-9205-c309ceb2d641}', 'contract_ids': ['@mozilla.org/network/captive-portal-service;1'], 'singleton': True, @@ -108,6 +109,7 @@ Classes = [ 'headers': ['mozilla/net/CaptivePortalService.h'], }, { + 'name': 'Dashboard', 'cid': '{c79eb3c6-091a-45a6-8544-5a8d1ab79537}', 'contract_ids': ['@mozilla.org/network/dashboard;1'], 'type': 'mozilla::net::Dashboard', @@ -141,6 +143,7 @@ Classes = [ 'headers': ['/netwerk/base/nsDownloader.h'], }, { + 'name': 'EffectiveTLD', 'js_name': 'eTLD', 'cid': '{cb9abbae-66b6-4609-8594-5c4ff300888e}', 'contract_ids': ['@mozilla.org/network/effective-tld-service;1'], @@ -184,6 +187,7 @@ Classes = [ 'init_method': 'Init', }, { + 'name': 'IDN', 'cid': '{62b778a6-bce3-456b-8c31-2865fbb68c91}', 'contract_ids': ['@mozilla.org/network/idn-service;1'], 'type': 'nsIDNService', @@ -235,6 +239,7 @@ Classes = [ 'legacy_constructor': 'nsLoadGroupConstructor', }, { + 'name': 'MimeHeaderParam', 'cid': '{1f4dbcf7-245c-4c8c-943d-8a1da0495e8a}', 'contract_ids': ['@mozilla.org/network/mime-hdrparam;1'], 'type': 'nsMIMEHeaderParamImpl', @@ -255,6 +260,7 @@ Classes = [ 'headers': ['mozilla/net/NetworkConnectivityService.h'], }, { + 'name': 'Predictor', 'cid': '{969adfdf-7221-4419-aecf-05f8faf00c9b}', 'contract_ids': ['@mozilla.org/network/predictor;1'], 'singleton': True, @@ -262,6 +268,7 @@ Classes = [ 'headers': ['mozilla/net/Predictor.h'], }, { + 'name': 'ProtocolProxy', 'cid': '{e9b301c0-e0e4-11d3-a1a8-0050041caf44}', 'contract_ids': ['@mozilla.org/network/protocol-proxy-service;1'], 'singleton': True, @@ -324,6 +331,7 @@ Classes = [ }, }, { + 'name': 'FileProtocolHandler', 'cid': '{fbc81170-1f69-11d3-9344-00104ba0fd40}', 'contract_ids': ['@mozilla.org/network/protocol;1?name=file'], 'singleton': True, @@ -341,6 +349,7 @@ Classes = [ }, }, { + 'name': 'HttpHandler', 'cid': '{4f47e42e-4d23-4dd3-bfda-eb29255e9ea3}', 'contract_ids': ['@mozilla.org/network/protocol;1?name=http'], 'singleton': True, @@ -621,6 +630,7 @@ Classes = [ 'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS, }, { + 'name': 'StreamConverter', 'cid': '{892ffeb0-3f80-11d3-a16c-0050041caf44}', 'contract_ids': ['@mozilla.org/streamConverters;1'], 'legacy_constructor': 'CreateNewStreamConvServiceFactory', diff --git a/netwerk/cookie/CookieService.cpp b/netwerk/cookie/CookieService.cpp index b85cf0524612..bef82e2caf65 100644 --- a/netwerk/cookie/CookieService.cpp +++ b/netwerk/cookie/CookieService.cpp @@ -8,6 +8,7 @@ #include "CookieLogging.h" #include "mozilla/AppShutdown.h" #include "mozilla/ClearOnShutdown.h" +#include "mozilla/Components.h" #include "mozilla/ContentBlockingNotifier.h" #include "mozilla/RefPtr.h" #include "mozilla/dom/Document.h" @@ -268,13 +269,13 @@ CookieService::CookieService() = default; nsresult CookieService::Init() { nsresult rv; - mTLDService = do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID, &rv); + mTLDService = mozilla::components::EffectiveTLD::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); - mIDNService = do_GetService(NS_IDNSERVICE_CONTRACTID, &rv); + mIDNService = mozilla::components::IDN::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); - mThirdPartyUtil = do_GetService(THIRDPARTYUTIL_CONTRACTID); + mThirdPartyUtil = mozilla::components::ThirdPartyUtil::Service(); NS_ENSURE_SUCCESS(rv, rv); // Init our default, and possibly private CookieStorages. diff --git a/netwerk/dns/DNSRequestParent.cpp b/netwerk/dns/DNSRequestParent.cpp index 09213b59ba74..eefd05f44660 100644 --- a/netwerk/dns/DNSRequestParent.cpp +++ b/netwerk/dns/DNSRequestParent.cpp @@ -12,6 +12,7 @@ #include "nsICancelable.h" #include "nsIDNSRecord.h" #include "nsHostResolver.h" +#include "mozilla/Components.h" #include "mozilla/Unused.h" #include "DNSAdditionalInfo.h" #include "nsServiceManagerUtils.h" @@ -43,7 +44,8 @@ void DNSRequestHandler::DoAsyncResolve(const nsACString& hostname, nsIDNSService::DNSFlags flags) { nsresult rv; mFlags = flags; - nsCOMPtr dns = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv); + nsCOMPtr dns; + dns = mozilla::components::DNS::Service(&rv); if (NS_SUCCEEDED(rv)) { nsCOMPtr main = GetMainThreadSerialEventTarget(); nsCOMPtr unused; @@ -66,7 +68,8 @@ void DNSRequestHandler::OnRecvCancelDNSRequest( const uint16_t& type, const OriginAttributes& originAttributes, const nsIDNSService::DNSFlags& flags, const nsresult& reason) { nsresult rv; - nsCOMPtr dns = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv); + nsCOMPtr dns; + dns = mozilla::components::DNS::Service(&rv); if (NS_SUCCEEDED(rv)) { RefPtr info; if (!aTrrServer.IsEmpty() || port != -1) { diff --git a/netwerk/dns/TRRServiceChild.cpp b/netwerk/dns/TRRServiceChild.cpp index 37be446f8f77..8e04116120ef 100644 --- a/netwerk/dns/TRRServiceChild.cpp +++ b/netwerk/dns/TRRServiceChild.cpp @@ -6,6 +6,7 @@ #include "mozilla/net/TRRServiceChild.h" #include "mozilla/Atomics.h" +#include "mozilla/Components.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/Services.h" #include "mozilla/StaticPtr.h" @@ -42,8 +43,8 @@ TRRServiceChild* TRRServiceChild::GetSingleton() { void TRRServiceChild::Init(const bool& aCaptiveIsPassed, const bool& aParentalControlEnabled, nsTArray&& aDNSSuffixList) { - nsCOMPtr dns = - do_GetService("@mozilla.org/network/dns-service;1"); + nsCOMPtr dns; + dns = mozilla::components::DNS::Service(); sDNSService = dns; ClearOnShutdown(&sDNSService); MOZ_ASSERT(sDNSService); diff --git a/netwerk/dns/nsEffectiveTLDService.cpp b/netwerk/dns/nsEffectiveTLDService.cpp index fc9e8c069209..d831b382b1f1 100644 --- a/netwerk/dns/nsEffectiveTLDService.cpp +++ b/netwerk/dns/nsEffectiveTLDService.cpp @@ -9,6 +9,7 @@ // http://wiki.mozilla.org/Gecko:Effective_TLD_Service #include "mozilla/ArrayUtils.h" +#include "mozilla/Components.h" #include "mozilla/HashFunctions.h" #include "mozilla/MemoryReporting.h" #include "mozilla/ResultExtensions.h" @@ -59,7 +60,7 @@ nsresult nsEffectiveTLDService::Init() { } nsresult rv; - mIDNService = do_GetService(NS_IDNSERVICE_CONTRACTID, &rv); + mIDNService = mozilla::components::IDN::Service(&rv); if (NS_FAILED(rv)) { return rv; } @@ -116,8 +117,8 @@ nsEffectiveTLDService* nsEffectiveTLDService::GetInstance() { if (gService) { return gService; } - nsCOMPtr tldService = - do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID); + nsCOMPtr tldService; + tldService = mozilla::components::EffectiveTLD::Service(); if (!tldService) { return nullptr; } diff --git a/netwerk/ipc/DocumentLoadListener.cpp b/netwerk/ipc/DocumentLoadListener.cpp index 754633d4a618..dd162b82902c 100644 --- a/netwerk/ipc/DocumentLoadListener.cpp +++ b/netwerk/ipc/DocumentLoadListener.cpp @@ -10,6 +10,7 @@ #include "NeckoCommon.h" #include "mozilla/AntiTrackingUtils.h" #include "mozilla/DebugOnly.h" +#include "mozilla/Components.h" #include "mozilla/LoadInfo.h" #include "mozilla/NullPrincipal.h" #include "mozilla/RefPtr.h" @@ -261,9 +262,9 @@ class ParentProcessDocumentOpenInfo final : public nsDocumentOpenInfo, } nsresult rv; - nsCOMPtr streamConvService = - do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv); + nsCOMPtr streamConvService; nsAutoCString str; + streamConvService = mozilla::components::StreamConverter::Service(&rv); rv = streamConvService->ConvertedType(mContentType, aChannel, str); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/ipc/NeckoChild.cpp b/netwerk/ipc/NeckoChild.cpp index fe2b3df0bff8..ee94a94fb68b 100644 --- a/netwerk/ipc/NeckoChild.cpp +++ b/netwerk/ipc/NeckoChild.cpp @@ -39,6 +39,7 @@ #include "nsINetworkLinkService.h" #include "nsQueryObject.h" #include "mozilla/ipc/URIUtils.h" +#include "mozilla/Components.h" #include "nsNetUtil.h" #include "SimpleChannel.h" @@ -263,8 +264,8 @@ mozilla::ipc::IPCResult NeckoChild::RecvPredOnPredictPrefetch( // Get the current predictor nsresult rv = NS_OK; - nsCOMPtr predictor = - do_GetService("@mozilla.org/network/predictor;1", &rv); + nsCOMPtr predictor; + predictor = mozilla::components::Predictor::Service(&rv); NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this)); predictor->OnPredictPrefetch(aURI, aHttpStatus); @@ -280,8 +281,8 @@ mozilla::ipc::IPCResult NeckoChild::RecvPredOnPredictPreconnect(nsIURI* aURI) { } // Get the current predictor nsresult rv = NS_OK; - nsCOMPtr predictor = - do_GetService("@mozilla.org/network/predictor;1", &rv); + nsCOMPtr predictor; + predictor = mozilla::components::Predictor::Service(&rv); NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this)); predictor->OnPredictPreconnect(aURI); @@ -297,8 +298,8 @@ mozilla::ipc::IPCResult NeckoChild::RecvPredOnPredictDNS(nsIURI* aURI) { } // Get the current predictor nsresult rv = NS_OK; - nsCOMPtr predictor = - do_GetService("@mozilla.org/network/predictor;1", &rv); + nsCOMPtr predictor; + predictor = mozilla::components::Predictor::Service(&rv); NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this)); predictor->OnPredictDNS(aURI); diff --git a/netwerk/ipc/NeckoParent.cpp b/netwerk/ipc/NeckoParent.cpp index 727aea4660fb..3d842c8b1bba 100644 --- a/netwerk/ipc/NeckoParent.cpp +++ b/netwerk/ipc/NeckoParent.cpp @@ -7,6 +7,7 @@ #include "nsHttp.h" #include "mozilla/BasePrincipal.h" +#include "mozilla/Components.h" #include "mozilla/ContentPrincipal.h" #include "mozilla/ipc/IPCStreamUtils.h" #include "mozilla/net/ExtensionProtocolHandler.h" @@ -572,8 +573,8 @@ mozilla::ipc::IPCResult NeckoParent::RecvPredPredict( const OriginAttributes& aOriginAttributes, const bool& hasVerifier) { // Get the current predictor nsresult rv = NS_OK; - nsCOMPtr predictor = - do_GetService("@mozilla.org/network/predictor;1", &rv); + nsCOMPtr predictor; + predictor = mozilla::components::Predictor::Service(&rv); NS_ENSURE_SUCCESS(rv, IPC_OK()); nsCOMPtr verifier; @@ -590,8 +591,8 @@ mozilla::ipc::IPCResult NeckoParent::RecvPredLearn( const OriginAttributes& aOriginAttributes) { // Get the current predictor nsresult rv = NS_OK; - nsCOMPtr predictor = - do_GetService("@mozilla.org/network/predictor;1", &rv); + nsCOMPtr predictor; + predictor = mozilla::components::Predictor::Service(&rv); NS_ENSURE_SUCCESS(rv, IPC_OK()); predictor->LearnNative(aTargetURI, aSourceURI, aReason, aOriginAttributes); @@ -601,8 +602,8 @@ mozilla::ipc::IPCResult NeckoParent::RecvPredLearn( mozilla::ipc::IPCResult NeckoParent::RecvPredReset() { // Get the current predictor nsresult rv = NS_OK; - nsCOMPtr predictor = - do_GetService("@mozilla.org/network/predictor;1", &rv); + nsCOMPtr predictor; + predictor = mozilla::components::Predictor::Service(&rv); NS_ENSURE_SUCCESS(rv, IPC_OK()); predictor->Reset(); diff --git a/netwerk/ipc/ProxyConfigLookup.cpp b/netwerk/ipc/ProxyConfigLookup.cpp index 29ce74091ded..1aa586456091 100644 --- a/netwerk/ipc/ProxyConfigLookup.cpp +++ b/netwerk/ipc/ProxyConfigLookup.cpp @@ -6,6 +6,7 @@ #include "ProxyConfigLookup.h" #include "ProxyConfigLookupChild.h" +#include "mozilla/Components.h" #include "mozilla/Unused.h" #include "nsContentUtils.h" #include "nsICancelable.h" @@ -59,8 +60,8 @@ nsresult ProxyConfigLookup::DoProxyResolve(nsICancelable** aLookupCancellable) { return rv; } - nsCOMPtr pps = - do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv); + nsCOMPtr pps; + pps = mozilla::components::ProtocolProxy::Service(&rv); if (NS_FAILED(rv)) { return rv; } diff --git a/netwerk/ipc/SocketProcessBridgeChild.cpp b/netwerk/ipc/SocketProcessBridgeChild.cpp index 798ce37bf149..df4ee0e1775f 100644 --- a/netwerk/ipc/SocketProcessBridgeChild.cpp +++ b/netwerk/ipc/SocketProcessBridgeChild.cpp @@ -7,6 +7,7 @@ #include "SocketProcessLogging.h" #include "mozilla/AppShutdown.h" +#include "mozilla/Components.h" #include "mozilla/dom/ContentChild.h" #include "mozilla/ipc/BackgroundChild.h" #include "mozilla/ipc/Endpoint.h" @@ -144,8 +145,8 @@ void SocketProcessBridgeChild::ActorDestroy(ActorDestroyReason aWhy) { } nsresult res; - nsCOMPtr mSTSThread = - do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &res); + nsCOMPtr mSTSThread; + mSTSThread = mozilla::components::SocketTransport::Service(&res); if (NS_SUCCEEDED(res) && mSTSThread) { // This must be called off the main thread. If we don't make this call // ipc::BackgroundChild::GetOrCreateSocketActorForCurrentThread() will diff --git a/netwerk/ipc/SocketProcessChild.cpp b/netwerk/ipc/SocketProcessChild.cpp index 000ebde2fd30..943094f790c9 100644 --- a/netwerk/ipc/SocketProcessChild.cpp +++ b/netwerk/ipc/SocketProcessChild.cpp @@ -194,8 +194,7 @@ bool SocketProcessChild::Init(mozilla::ipc::UntypedEndpoint&& aEndpoint, } // Initialize DNS Service here, since it needs to be done in main thread. - nsCOMPtr dns = - do_GetService("@mozilla.org/network/dns-service;1", &rv); + mozilla::components::DNS::Service(&rv); if (NS_FAILED(rv)) { return false; } @@ -210,7 +209,7 @@ bool SocketProcessChild::Init(mozilla::ipc::UntypedEndpoint&& aEndpoint, Unused << obs->AddObserver(observer, "profile-change-net-teardown", false); } - mSocketThread = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID); + mSocketThread = mozilla::components::SocketTransport::Service(); if (!mSocketThread) { return false; } @@ -440,8 +439,9 @@ mozilla::ipc::IPCResult SocketProcessChild::RecvUpdateDeviceModelId( mozilla::ipc::IPCResult SocketProcessChild::RecvOnHttpActivityDistributorActivated( const bool& aIsActivated) { - if (nsCOMPtr distributor = - components::HttpActivityDistributor::Service()) { + nsCOMPtr distributor; + distributor = mozilla::components::HttpActivityDistributor::Service(); + if (distributor) { distributor->SetIsActive(aIsActivated); } return IPC_OK(); @@ -450,8 +450,8 @@ SocketProcessChild::RecvOnHttpActivityDistributorActivated( mozilla::ipc::IPCResult SocketProcessChild::RecvOnHttpActivityDistributorObserveProxyResponse( const bool& aIsEnabled) { - nsCOMPtr distributor = - do_GetService("@mozilla.org/network/http-activity-distributor;1"); + nsCOMPtr distributor; + distributor = mozilla::components::HttpActivityDistributor::Service(); if (distributor) { Unused << distributor->SetObserveProxyResponse(aIsEnabled); } @@ -461,8 +461,8 @@ SocketProcessChild::RecvOnHttpActivityDistributorObserveProxyResponse( mozilla::ipc::IPCResult SocketProcessChild::RecvOnHttpActivityDistributorObserveConnection( const bool& aIsEnabled) { - nsCOMPtr distributor = - do_GetService("@mozilla.org/network/http-activity-distributor;1"); + nsCOMPtr distributor; + distributor = mozilla::components::HttpActivityDistributor::Service(); if (distributor) { Unused << distributor->SetObserveConnection(aIsEnabled); } @@ -641,8 +641,8 @@ mozilla::ipc::IPCResult SocketProcessChild::RecvGetSocketData( mozilla::ipc::IPCResult SocketProcessChild::RecvGetDNSCacheEntries( GetDNSCacheEntriesResolver&& aResolve) { nsresult rv = NS_OK; - nsCOMPtr dns = - do_GetService("@mozilla.org/network/dns-service;1", &rv); + nsCOMPtr dns; + dns = mozilla::components::DNS::Service(&rv); if (NS_FAILED(rv)) { aResolve(nsTArray()); return IPC_OK(); diff --git a/netwerk/protocol/about/nsAboutCache.cpp b/netwerk/protocol/about/nsAboutCache.cpp index 214b18418925..9dde979e9f46 100644 --- a/netwerk/protocol/about/nsAboutCache.cpp +++ b/netwerk/protocol/about/nsAboutCache.cpp @@ -21,6 +21,8 @@ #include "nsThreadUtils.h" +#include "mozilla/Components.h" + using namespace mozilla::net; NS_IMPL_ISUPPORTS(nsAboutCache, nsIAboutModule) @@ -213,8 +215,8 @@ nsresult nsAboutCache::GetStorage(nsACString const& storageName, nsICacheStorage** storage) { nsresult rv; - nsCOMPtr cacheService = - do_GetService("@mozilla.org/netwerk/cache-storage-service;1", &rv); + nsCOMPtr cacheService; + cacheService = mozilla::components::CacheStorage::Service(&rv); if (NS_FAILED(rv)) return rv; nsCOMPtr cacheStorage; diff --git a/netwerk/protocol/file/nsFileChannel.cpp b/netwerk/protocol/file/nsFileChannel.cpp index 096f8807ba40..f6a4d0b79d7e 100644 --- a/netwerk/protocol/file/nsFileChannel.cpp +++ b/netwerk/protocol/file/nsFileChannel.cpp @@ -30,6 +30,7 @@ #include "prio.h" #include +#include "mozilla/Components.h" #include "mozilla/TaskQueue.h" #include "mozilla/Unused.h" @@ -149,8 +150,8 @@ nsresult nsFileCopyEvent::Dispatch(nsIRunnable* callback, if (NS_FAILED(rv)) return rv; // Dispatch ourselves to I/O thread pool... - nsCOMPtr pool = - do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv); + nsCOMPtr pool; + pool = mozilla::components::StreamTransport::Service(&rv); if (NS_FAILED(rv)) return rv; return pool->Dispatch(this, NS_DISPATCH_NORMAL); @@ -427,8 +428,7 @@ nsresult nsFileChannel::ListenerBlockingPromise(BlockingPromise** aPromise) { return NS_OK; } - nsCOMPtr sts( - do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID)); + nsCOMPtr sts(mozilla::components::StreamTransport::Service()); if (!sts) { return FixupContentLength(true); } diff --git a/netwerk/protocol/http/CachePushChecker.cpp b/netwerk/protocol/http/CachePushChecker.cpp index 9f48aa7eda07..fc6ebcbd6e81 100644 --- a/netwerk/protocol/http/CachePushChecker.cpp +++ b/netwerk/protocol/http/CachePushChecker.cpp @@ -7,6 +7,7 @@ #include "CachePushChecker.h" #include "LoadContextInfo.h" +#include "mozilla/Components.h" #include "mozilla/ScopeExit.h" #include "mozilla/net/SocketProcessChild.h" #include "nsICacheEntry.h" @@ -54,8 +55,8 @@ nsresult CachePushChecker::DoCheck() { } nsresult rv; - nsCOMPtr css = - do_GetService("@mozilla.org/netwerk/cache-storage-service;1", &rv); + nsCOMPtr css; + css = mozilla::components::CacheStorage::Service(&rv); if (NS_FAILED(rv)) { return rv; } diff --git a/netwerk/protocol/http/DnsAndConnectSocket.cpp b/netwerk/protocol/http/DnsAndConnectSocket.cpp index 8895ac97e186..95d39930b0a8 100644 --- a/netwerk/protocol/http/DnsAndConnectSocket.cpp +++ b/netwerk/protocol/http/DnsAndConnectSocket.cpp @@ -209,8 +209,8 @@ nsresult DnsAndConnectSocket::SetupDnsFlags(ConnectionEntry* ent) { if (ent->mConnInfo->HasIPHintAddress()) { nsresult rv; - nsCOMPtr dns = - do_GetService("@mozilla.org/network/dns-service;1", &rv); + nsCOMPtr dns; + dns = mozilla::components::DNS::Service(&rv); if (NS_FAILED(rv)) { return rv; } @@ -1206,8 +1206,8 @@ nsresult DnsAndConnectSocket::TransportSetup::SetupStreams( } if (ci->HasIPHintAddress()) { - nsCOMPtr dns = - do_GetService("@mozilla.org/network/dns-service;1", &rv); + nsCOMPtr dns; + dns = mozilla::components::DNS::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); // The spec says: "If A and AAAA records for TargetName are locally diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index b8634512cea6..3fda98ca0e55 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -21,6 +21,7 @@ #include "mozilla/dom/WindowGlobalParent.h" #include "mozilla/net/NeckoParent.h" #include "mozilla/net/CookieServiceParent.h" +#include "mozilla/Components.h" #include "mozilla/InputStreamLengthHelper.h" #include "mozilla/IntegerPrintfMacros.h" #include "mozilla/Preferences.h" @@ -325,8 +326,8 @@ HttpChannelParent::GetInterface(const nsIID& aIID, void** result) { if (!mBrowserParent && (aIID.Equals(NS_GET_IID(nsIAuthPrompt)) || aIID.Equals(NS_GET_IID(nsIAuthPrompt2)))) { nsresult rv; - nsCOMPtr wwatch = - do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv); + nsCOMPtr wwatch; + wwatch = mozilla::components::WindowWatcher::Service(&rv); NS_ENSURE_SUCCESS(rv, NS_ERROR_NO_INTERFACE); bool hasWindowCreator = false; diff --git a/netwerk/protocol/http/NullHttpTransaction.cpp b/netwerk/protocol/http/NullHttpTransaction.cpp index f27eb16138e5..3ca3d2f75d16 100644 --- a/netwerk/protocol/http/NullHttpTransaction.cpp +++ b/netwerk/protocol/http/NullHttpTransaction.cpp @@ -8,6 +8,7 @@ #include "HttpLog.h" #include "mozilla/net/NeckoChannelParams.h" // For HttpActivityArgs. +#include "mozilla/Components.h" #include "nsHttp.h" #include "NullHttpTransaction.h" #include "nsHttpHandler.h" @@ -34,7 +35,7 @@ NullHttpTransaction::NullHttpTransaction(nsHttpConnectionInfo* ci, mConnectionInfo(ci) { nsresult rv; mActivityDistributor = - do_GetService(NS_HTTPACTIVITYDISTRIBUTOR_CONTRACTID, &rv); + mozilla::components::HttpActivityDistributor::Service(&rv); if (NS_FAILED(rv)) { return; } diff --git a/netwerk/protocol/http/ParentChannelListener.cpp b/netwerk/protocol/http/ParentChannelListener.cpp index d35a0a9a1292..12d71a14ab6e 100644 --- a/netwerk/protocol/http/ParentChannelListener.cpp +++ b/netwerk/protocol/http/ParentChannelListener.cpp @@ -14,6 +14,7 @@ #include "mozilla/dom/ServiceWorkerUtils.h" #include "mozilla/net/HttpChannelParent.h" #include "mozilla/net/RedirectChannelRegistrar.h" +#include "mozilla/Components.h" #include "mozilla/SchedulerGroup.h" #include "nsIHttpHeaderVisitor.h" #include "nsIPrompt.h" @@ -165,8 +166,8 @@ ParentChannelListener::GetInterface(const nsIID& aIID, void** result) { NS_ENSURE_TRUE(win, NS_ERROR_NO_INTERFACE); nsresult rv; - nsCOMPtr wwatch = - do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv); + nsCOMPtr wwatch; + wwatch = mozilla::components::WindowWatcher::Service(&rv); if (NS_WARN_IF(!NS_SUCCEEDED(rv))) { return NS_ERROR_NO_INTERFACE; @@ -248,8 +249,8 @@ ParentChannelListener::GetAuthPrompt(uint32_t aPromptReason, const nsIID& iid, } // we're either allowing auth, or it's a proxy request nsresult rv; - nsCOMPtr wwatch = - do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv); + nsCOMPtr wwatch; + wwatch = mozilla::components::WindowWatcher::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr window; diff --git a/netwerk/protocol/http/nsCORSListenerProxy.cpp b/netwerk/protocol/http/nsCORSListenerProxy.cpp index a58f8b7b7ae1..6400f8640352 100644 --- a/netwerk/protocol/http/nsCORSListenerProxy.cpp +++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp @@ -7,6 +7,7 @@ #include "nsIThreadRetargetableStreamListener.h" #include "nsString.h" #include "mozilla/Assertions.h" +#include "mozilla/Components.h" #include "mozilla/LinkedList.h" #include "mozilla/StaticPrefs_content.h" #include "mozilla/StoragePrincipalHelper.h" @@ -1721,7 +1722,7 @@ void nsCORSListenerProxy::LogBlockedCORSRequest( // Build the error object and log it to the console nsCOMPtr console( - do_GetService(NS_CONSOLESERVICE_CONTRACTID, &rv)); + mozilla::components::Console::Service(&rv)); if (NS_FAILED(rv)) { NS_WARNING("Failed to log blocked cross-site request (no console)"); return; diff --git a/netwerk/protocol/http/nsHttpChannel.cpp b/netwerk/protocol/http/nsHttpChannel.cpp index b48e2ecc15d5..a9a0746c2987 100644 --- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -1818,7 +1818,7 @@ nsresult nsHttpChannel::CallOnStartRequest() { if (contentType.Equals("multipart/x-mixed-replace"_ns)) { nsCOMPtr convServ( - do_GetService("@mozilla.org/streamConverters;1", &rv)); + mozilla::components::StreamConverter::Service(&rv)); if (NS_SUCCEEDED(rv)) { nsCOMPtr toListener(mListener); nsCOMPtr fromListener; @@ -2866,8 +2866,8 @@ nsresult nsHttpChannel::PromptTempRedirect() { return NS_OK; } nsresult rv; - nsCOMPtr bundleService = - do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); + nsCOMPtr bundleService; + bundleService = mozilla::components::StringBundle::Service(&rv); if (NS_FAILED(rv)) return rv; nsCOMPtr stringBundle; @@ -2896,8 +2896,8 @@ nsresult nsHttpChannel::ProxyFailover() { nsresult rv; - nsCOMPtr pps = - do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv); + nsCOMPtr pps; + pps = mozilla::components::ProtocolProxy::Service(&rv); if (NS_FAILED(rv)) return rv; nsCOMPtr pi; @@ -3283,8 +3283,8 @@ nsresult nsHttpChannel::ResolveProxy() { nsresult rv; - nsCOMPtr pps = - do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv); + nsCOMPtr pps; + pps = mozilla::components::ProtocolProxy::Service(&rv); if (NS_FAILED(rv)) return rv; // using the nsIProtocolProxyService2 allows a minor performance @@ -5500,8 +5500,9 @@ nsresult nsHttpChannel::AsyncProcessRedirection(uint32_t redirectType) { if (!isRedirectURIInAllowList) { nsCOMPtr strippedURI; - nsCOMPtr queryStripper = - components::URLQueryStringStripper::Service(&rv); + nsCOMPtr queryStripper; + queryStripper = + mozilla::components::URLQueryStringStripper::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); uint32_t numStripped; @@ -6564,8 +6565,8 @@ nsresult nsHttpChannel::BeginConnect() { MOZ_ASSERT(NS_SUCCEEDED(rv)); } - nsCOMPtr consoleService = - do_GetService(NS_CONSOLESERVICE_CONTRACTID); + nsCOMPtr consoleService; + consoleService = mozilla::components::Console::Service(); if (consoleService && !host.Equals(mapping->AlternateHost())) { nsAutoString message(u"Alternate Service Mapping found: "_ns); AppendASCIItoUTF16(scheme, message); @@ -7752,8 +7753,7 @@ static nsLiteralCString ContentTypeToTelemetryLabel(nsHttpChannel* aChannel) { } nsresult nsHttpChannel::LogConsoleError(const char* aTag) { - nsCOMPtr console( - do_GetService(NS_CONSOLESERVICE_CONTRACTID)); + nsCOMPtr console(mozilla::components::Console::Service()); NS_ENSURE_TRUE(console, NS_ERROR_OUT_OF_MEMORY); nsCOMPtr loadInfo = LoadInfo(); @@ -8528,8 +8528,8 @@ nsHttpChannel::OnDataAvailable(nsIRequest* request, nsIInputStream* input, count = delta; NS_WARNING("Listener OnDataAvailable contract violation"); - nsCOMPtr consoleService = - do_GetService(NS_CONSOLESERVICE_CONTRACTID); + nsCOMPtr consoleService; + consoleService = mozilla::components::Console::Service(); nsAutoString message(nsLiteralString( u"http channel Listener OnDataAvailable contract violation")); if (consoleService) { @@ -10019,8 +10019,8 @@ nsresult nsHttpChannel::TriggerNetwork() { void nsHttpChannel::MaybeRaceCacheWithNetwork() { nsresult rv; - nsCOMPtr netLinkSvc = - do_GetService(NS_NETWORK_LINK_SERVICE_CONTRACTID, &rv); + nsCOMPtr netLinkSvc; + netLinkSvc = do_GetService(NS_NETWORK_LINK_SERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) { return; } diff --git a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp index 28428f9eab29..df3bed7920f1 100644 --- a/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp +++ b/netwerk/protocol/http/nsHttpChannelAuthProvider.cpp @@ -8,6 +8,7 @@ #include "HttpLog.h" #include "mozilla/BasePrincipal.h" +#include "mozilla/Components.h" #include "mozilla/StoragePrincipalHelper.h" #include "mozilla/Tokenizer.h" #include "MockHttpAuth.h" @@ -1690,8 +1691,8 @@ bool nsHttpChannelAuthProvider::ConfirmAuth(const char* bundleKey, // assume the user said ok. this is done to keep things working in // embedded builds, where the string bundle might not be present, etc. - nsCOMPtr bundleService = - do_GetService(NS_STRINGBUNDLE_CONTRACTID); + nsCOMPtr bundleService; + bundleService = mozilla::components::StringBundle::Service(); if (!bundleService) return true; nsCOMPtr bundle; diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 068926844af7..c6ae8efe6912 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -144,8 +144,8 @@ static nsCString GetDeviceModelId() { // Assumed to be running on the main thread // We need the device property in either case nsAutoCString deviceModelId; - nsCOMPtr infoService = - do_GetService("@mozilla.org/system-info;1"); + nsCOMPtr infoService; + infoService = mozilla::components::SystemInfo::Service(); MOZ_ASSERT(infoService, "Could not find a system info service"); nsAutoString androidDevice; nsresult rv = infoService->GetPropertyAsAString(u"device"_ns, androidDevice); @@ -266,7 +266,8 @@ nsHttpHandler::nsHttpHandler() MOZ_ASSERT(!gHttpHandler, "HTTP handler already created!"); - nsCOMPtr runtime = do_GetService("@mozilla.org/xre/runtime;1"); + nsCOMPtr runtime; + runtime = mozilla::components::XULRuntime::Service(); if (runtime) { runtime->GetProcessID(&mProcessId); } @@ -327,7 +328,8 @@ nsresult nsHttpHandler::Init() { rv = nsHttp::CreateAtomTable(); if (NS_FAILED(rv)) return rv; - nsCOMPtr service = do_GetService(NS_IOSERVICE_CONTRACTID, &rv); + nsCOMPtr service; + service = mozilla::components::IO::Service(&rv); if (NS_FAILED(rv)) { NS_WARNING("unable to continue without io service"); return rv; @@ -387,8 +389,8 @@ nsresult nsHttpHandler::Init() { mCompatFirefox.AssignLiteral("Firefox/" MOZILLA_UAVERSION); - nsCOMPtr appInfo = - do_GetService("@mozilla.org/xre/app-info;1"); + nsCOMPtr appInfo; + appInfo = mozilla::components::XULRuntime::Service(); mAppName.AssignLiteral(MOZ_APP_UA_NAME); if (mAppName.Length() == 0 && appInfo) { @@ -666,8 +668,8 @@ bool nsHttpHandler::IsAcceptableEncoding(const char* enc, bool isSecure) { nsISiteSecurityService* nsHttpHandler::GetSSService() { if (!mSSService) { - nsCOMPtr service = - do_GetService(NS_SSSERVICE_CONTRACTID); + nsCOMPtr service; + service = mozilla::components::SiteSecurity::Service(); mSSService = new nsMainThreadPtrHolder( "nsHttpHandler::mSSService", service); } @@ -889,8 +891,8 @@ void nsHttpHandler::InitUserAgentComponents() { #endif #ifdef ANDROID - nsCOMPtr infoService = - do_GetService("@mozilla.org/system-info;1"); + nsCOMPtr infoService; + infoService = mozilla::components::SystemInfo::Service(); MOZ_ASSERT(infoService, "Could not find a system info service"); nsresult rv; diff --git a/netwerk/protocol/res/ExtensionProtocolHandler.cpp b/netwerk/protocol/res/ExtensionProtocolHandler.cpp index d3b1a3916452..a61a2203a352 100644 --- a/netwerk/protocol/res/ExtensionProtocolHandler.cpp +++ b/netwerk/protocol/res/ExtensionProtocolHandler.cpp @@ -7,6 +7,7 @@ #include "ExtensionProtocolHandler.h" #include "mozilla/BinarySearch.h" +#include "mozilla/Components.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise-inl.h" @@ -551,8 +552,8 @@ nsresult ExtensionProtocolHandler::SubstituteChannel(nsIURI* aURI, nsIChannel* channel, nsIChannel* origChannel) -> nsresult { nsresult rv; - nsCOMPtr convService = - do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv); + nsCOMPtr convService; + convService = mozilla::components::StreamConverter::Service(&rv); MOZ_TRY(rv); nsCOMPtr uri; diff --git a/netwerk/protocol/res/PageThumbProtocolHandler.cpp b/netwerk/protocol/res/PageThumbProtocolHandler.cpp index ece55aa54c4b..7a5567515636 100644 --- a/netwerk/protocol/res/PageThumbProtocolHandler.cpp +++ b/netwerk/protocol/res/PageThumbProtocolHandler.cpp @@ -7,6 +7,7 @@ #include "PageThumbProtocolHandler.h" #include "mozilla/ClearOnShutdown.h" +#include "mozilla/Components.h" #include "mozilla/ipc/URIParams.h" #include "mozilla/ipc/URIUtils.h" #include "mozilla/net/NeckoChild.h" @@ -313,8 +314,8 @@ nsresult PageThumbProtocolHandler::GetThumbnailPath(const nsACString& aPath, nsresult rv; if (aHost.EqualsLiteral(PAGE_THUMB_HOST)) { - nsCOMPtr pageThumbsStorage = - do_GetService("@mozilla.org/thumbnails/pagethumbs-service;1", &rv); + nsCOMPtr pageThumbsStorage; + pageThumbsStorage = mozilla::components::PageThumbsStorage::Service(&rv); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -324,8 +325,8 @@ nsresult PageThumbProtocolHandler::GetThumbnailPath(const nsACString& aPath, aThumbnailPath); #ifdef MOZ_PLACES } else if (aHost.EqualsLiteral(PLACES_PREVIEWS_HOST)) { - nsCOMPtr helper = - do_GetService("@mozilla.org/places/previews-helper;1", &rv); + nsCOMPtr helper; + helper = mozilla::components::PlacesPreviewsHelper::Service(&rv); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } diff --git a/netwerk/protocol/websocket/WebSocketChannel.cpp b/netwerk/protocol/websocket/WebSocketChannel.cpp index a1ebf85d8ee7..d996d9689a91 100644 --- a/netwerk/protocol/websocket/WebSocketChannel.cpp +++ b/netwerk/protocol/websocket/WebSocketChannel.cpp @@ -14,6 +14,7 @@ #include "mozilla/Atomics.h" #include "mozilla/Attributes.h" #include "mozilla/Base64.h" +#include "mozilla/Components.h" #include "mozilla/EndianUtils.h" #include "mozilla/MathAlgorithms.h" #include "mozilla/ScopeExit.h" @@ -176,8 +177,8 @@ class FailDelayManager { mDelaysDisabled = false; - nsCOMPtr prefService = - do_GetService(NS_PREFSERVICE_CONTRACTID); + nsCOMPtr prefService; + prefService = mozilla::components::Preferences::Service(); if (!prefService) { return; } @@ -1224,8 +1225,7 @@ WebSocketChannel::WebSocketChannel() mFramePtr = mBuffer = static_cast(moz_xmalloc(mBufferSize)); nsresult rv; - mConnectionLogService = - do_GetService("@mozilla.org/network/dashboard;1", &rv); + mConnectionLogService = mozilla::components::Dashboard::Service(&rv); if (NS_FAILED(rv)) LOG(("Failed to initiate dashboard service.")); mService = WebSocketEventService::GetOrCreate(); @@ -2743,8 +2743,8 @@ void ProcessServerWebSocketExtensions(const nsACString& aExtensions, nsACString& aNegotiatedExtensions) { aNegotiatedExtensions.Truncate(); - nsCOMPtr prefService = - do_GetService(NS_PREFSERVICE_CONTRACTID); + nsCOMPtr prefService; + prefService = mozilla::components::Preferences::Service(); if (prefService) { bool boolpref; nsresult rv = prefService->GetBoolPref( @@ -2895,7 +2895,8 @@ nsresult WebSocketChannel::DoAdmissionDNS() { rv = mURI->GetPort(&mPort); NS_ENSURE_SUCCESS(rv, rv); if (mPort == -1) mPort = (mEncrypted ? kDefaultWSSPort : kDefaultWSPort); - nsCOMPtr dns = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv); + nsCOMPtr dns; + dns = mozilla::components::DNS::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr main = GetMainThreadSerialEventTarget(); nsCOMPtr cancelable; @@ -2920,8 +2921,8 @@ nsresult WebSocketChannel::ApplyForAdmission() { // CONNECTING state per server IP address (not hostname) // Check to see if a proxy is being used before making DNS call - nsCOMPtr pps = - do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID); + nsCOMPtr pps; + pps = mozilla::components::ProtocolProxy::Service(); if (!pps) { // go straight to DNS @@ -3450,14 +3451,14 @@ WebSocketChannel::AsyncOpenNative(nsIURI* aURI, const nsACString& aOrigin, } } - mIOThread = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv); + mIOThread = mozilla::components::SocketTransport::Service(&rv); if (NS_FAILED(rv)) { NS_WARNING("unable to continue without socket transport service"); return rv; } nsCOMPtr prefService; - prefService = do_GetService(NS_PREFSERVICE_CONTRACTID); + prefService = mozilla::components::Preferences::Service(); if (prefService) { int32_t intpref; @@ -3530,8 +3531,7 @@ WebSocketChannel::AsyncOpenNative(nsIURI* aURI, const nsACString& aOrigin, mURI->GetHostPort(mHost); - mRandomGenerator = - do_GetService("@mozilla.org/security/random-generator;1", &rv); + mRandomGenerator = mozilla::components::RandomGenerator::Service(&rv); if (NS_FAILED(rv)) { NS_WARNING("unable to continue without random number generator"); return rv; @@ -3546,7 +3546,7 @@ WebSocketChannel::AsyncOpenNative(nsIURI* aURI, const nsACString& aOrigin, NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr ioService; - ioService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv); + ioService = mozilla::components::IO::Service(&rv); if (NS_FAILED(rv)) { NS_WARNING("unable to continue without io service"); return rv; @@ -3926,8 +3926,8 @@ WebSocketChannel::OnStartRequest(nsIRequest* aRequest) { // NS_ERROR_WEBSOCKET_CONNECTION_REFUSED. if (NS_SUCCEEDED(mHttpChannel->GetStatus(&httpStatus))) { uint32_t errorClass; - nsCOMPtr errSvc = - do_GetService("@mozilla.org/nss_errors_service;1"); + nsCOMPtr errSvc; + errSvc = mozilla::components::NSSErrors::Service(); // If GetErrorClass succeeds httpStatus is TLS related failure. if (errSvc && NS_SUCCEEDED(errSvc->GetErrorClass(httpStatus, &errorClass))) { diff --git a/netwerk/protocol/websocket/WebSocketConnection.cpp b/netwerk/protocol/websocket/WebSocketConnection.cpp index b57f4fc115e5..422cd7fd3105 100644 --- a/netwerk/protocol/websocket/WebSocketConnection.cpp +++ b/netwerk/protocol/websocket/WebSocketConnection.cpp @@ -9,6 +9,7 @@ #include "WebSocketLog.h" #include "mozilla/net/WebSocketConnectionListener.h" +#include "mozilla/Components.h" #include "nsIOService.h" #include "nsITLSSocketControl.h" #include "nsISocketTransport.h" @@ -38,7 +39,7 @@ nsresult WebSocketConnection::Init(WebSocketConnectionListener* aListener) { mListener = aListener; nsresult rv; - mSocketThread = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv); + mSocketThread = mozilla::components::SocketTransport::Service(&rv); if (NS_FAILED(rv)) { return rv; } diff --git a/netwerk/protocol/websocket/WebSocketConnectionChild.cpp b/netwerk/protocol/websocket/WebSocketConnectionChild.cpp index 045c3763b7ce..8f12933b113f 100644 --- a/netwerk/protocol/websocket/WebSocketConnectionChild.cpp +++ b/netwerk/protocol/websocket/WebSocketConnectionChild.cpp @@ -10,6 +10,7 @@ #include "WebSocketConnection.h" #include "mozilla/ipc/Endpoint.h" #include "mozilla/net/SocketProcessBackgroundChild.h" +#include "mozilla/Components.h" #include "nsISerializable.h" #include "nsITLSSocketControl.h" #include "nsITransportSecurityInfo.h" @@ -35,7 +36,7 @@ void WebSocketConnectionChild::Init(uint32_t aListenerId) { MOZ_ASSERT(NS_IsMainThread()); nsresult rv; - mSocketThread = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv); + mSocketThread = mozilla::components::SocketTransport::Service(&rv); MOZ_ASSERT(NS_SUCCEEDED(rv)); if (!mSocketThread) { return; diff --git a/netwerk/sctp/datachannel/DataChannel.cpp b/netwerk/sctp/datachannel/DataChannel.cpp index 81f54e775d01..f2e4c862a823 100644 --- a/netwerk/sctp/datachannel/DataChannel.cpp +++ b/netwerk/sctp/datachannel/DataChannel.cpp @@ -41,6 +41,7 @@ #include "nsThreadUtils.h" #include "nsNetUtil.h" #include "nsNetCID.h" +#include "mozilla/Components.h" #include "mozilla/RandomNum.h" #include "mozilla/StaticMutex.h" #include "mozilla/UniquePtrExtensions.h" @@ -547,7 +548,7 @@ bool DataChannelConnection::Init(const uint16_t aLocalPort, // XXX FIX! make this a global we get once // Find the STS thread nsresult rv; - mSTS = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv); + mSTS = mozilla::components::SocketTransport::Service(&rv); MOZ_ASSERT(NS_SUCCEEDED(rv)); // Open sctp with a callback @@ -701,8 +702,8 @@ void DataChannelConnection::SetMaxMessageSize(bool aMaxMessageSizeSet, mMaxMessageSize = aMaxMessageSize; nsresult rv; - nsCOMPtr prefs = - do_GetService("@mozilla.org/preferences-service;1", &rv); + nsCOMPtr prefs; + prefs = mozilla::components::Preferences::Service(&rv); if (!NS_WARN_IF(NS_FAILED(rv))) { nsCOMPtr branch = do_QueryInterface(prefs); diff --git a/netwerk/socket/nsSOCKSIOLayer.cpp b/netwerk/socket/nsSOCKSIOLayer.cpp index b92de4e87abc..138c6c8dc15b 100644 --- a/netwerk/socket/nsSOCKSIOLayer.cpp +++ b/netwerk/socket/nsSOCKSIOLayer.cpp @@ -20,6 +20,7 @@ #include "nsThreadUtils.h" #include "nsIFile.h" #include "nsIFileProtocolHandler.h" +#include "mozilla/Components.h" #include "mozilla/Logging.h" #include "mozilla/net/DNS.h" #include "mozilla/Unused.h" @@ -127,7 +128,7 @@ class nsSOCKSSocketInfo : public nsIDNSListener { MOZ_ASSERT(aProxyAddr); nsCOMPtr protocolHandler( - do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "file", &rv)); + mozilla::components::FileProtocolHandler::Service(&rv)); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -408,7 +409,8 @@ PRStatus nsSOCKSSocketInfo::StartDNS(PRFileDesc* fd) { MOZ_ASSERT(!mDnsRec && mState == SOCKS_INITIAL, "Must be in initial state to make DNS Lookup"); - nsCOMPtr dns = do_GetService(NS_DNSSERVICE_CONTRACTID); + nsCOMPtr dns; + dns = mozilla::components::DNS::Service(); if (!dns) return PR_FAILURE; nsCString proxyHost; diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.cpp b/netwerk/streamconv/converters/nsIndexedToHTML.cpp index 40650d9fce3c..b72cbf8621c5 100644 --- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp +++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp @@ -5,6 +5,7 @@ #include "nsIndexedToHTML.h" +#include "mozilla/Components.h" #include "mozilla/Encoding.h" #include "mozilla/intl/AppDateTimeFormat.h" #include "mozilla/intl/LocaleService.h" @@ -67,8 +68,8 @@ nsresult nsIndexedToHTML::Init(nsIStreamListener* aListener) { mListener = aListener; - nsCOMPtr sbs = - do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv); + nsCOMPtr sbs; + sbs = mozilla::components::StringBundle::Service(&rv); if (NS_FAILED(rv)) return rv; rv = sbs->CreateBundle(NECKO_MSGS_URL, getter_AddRefs(mBundle)); @@ -476,7 +477,7 @@ nsresult nsIndexedToHTML::DoOnStartRequest(nsIRequest* request, // otherwise we end up linking to file:///foo/dirfile if (!mTextToSubURI) { - mTextToSubURI = do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv); + mTextToSubURI = mozilla::components::TextToSubURI::Service(&rv); if (NS_FAILED(rv)) return rv; } diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.cpp b/netwerk/streamconv/converters/nsMultiMixedConv.cpp index df7294acf9ed..e1ccfda303cc 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp +++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ -20,6 +20,7 @@ #include "nsIURI.h" #include "nsHttpHeaderArray.h" #include "mozilla/AutoRestore.h" +#include "mozilla/Components.h" #include "mozilla/Tokenizer.h" #include "nsComponentManagerUtils.h" #include "mozilla/StaticPrefs_network.h" @@ -812,8 +813,8 @@ nsresult nsMultiMixedConv::SendStart() { nsCOMPtr partListener(mFinalListener); if (mContentType.IsEmpty()) { mContentType.AssignLiteral(UNKNOWN_CONTENT_TYPE); - nsCOMPtr serv = - do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv); + nsCOMPtr serv; + serv = mozilla::components::StreamConverter::Service(&rv); if (NS_SUCCEEDED(rv)) { nsCOMPtr converter; rv = serv->AsyncConvertData(UNKNOWN_CONTENT_TYPE, "*/*", mFinalListener, diff --git a/netwerk/streamconv/nsStreamConverterService.cpp b/netwerk/streamconv/nsStreamConverterService.cpp index ce95bb0404f7..22703ada58af 100644 --- a/netwerk/streamconv/nsStreamConverterService.cpp +++ b/netwerk/streamconv/nsStreamConverterService.cpp @@ -18,6 +18,7 @@ #include "nsTArray.h" #include "nsServiceManagerUtils.h" #include "nsISimpleEnumerator.h" +#include "mozilla/Components.h" #include "mozilla/UniquePtr.h" /////////////////////////////////////////////////////////////////// @@ -65,7 +66,7 @@ nsresult nsStreamConverterService::BuildGraph() { nsresult rv; nsCOMPtr catmgr( - do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv)); + mozilla::components::CategoryManager::Service(&rv)); if (NS_FAILED(rv)) return rv; nsCOMPtr entries; diff --git a/netwerk/system/mac/nsNetworkLinkService.mm b/netwerk/system/mac/nsNetworkLinkService.mm index 83271c07126f..331a82475ae5 100644 --- a/netwerk/system/mac/nsNetworkLinkService.mm +++ b/netwerk/system/mac/nsNetworkLinkService.mm @@ -26,6 +26,7 @@ #include "nsCRT.h" #include "nsNetCID.h" #include "nsThreadUtils.h" +#include "mozilla/Components.h" #include "mozilla/Logging.h" #include "mozilla/StaticPrefs_network.h" #include "mozilla/SHA1.h" @@ -595,8 +596,8 @@ void nsNetworkLinkService::calculateNetworkIdWithDelay(uint32_t aDelay) { return; } - nsCOMPtr target = - do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID); + nsCOMPtr target; + target = mozilla::components::StreamTransport::Service(); if (!target) { return; } @@ -723,8 +724,8 @@ void nsNetworkLinkService::NetworkConfigChanged(SCDynamicStoreRef aStoreREf, void nsNetworkLinkService::DNSConfigChanged(uint32_t aDelayMs) { LOG(("nsNetworkLinkService::DNSConfigChanged")); - nsCOMPtr target = - do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID); + nsCOMPtr target; + target = mozilla::components::StreamTransport::Service(); if (!target) { return; } @@ -752,8 +753,8 @@ void nsNetworkLinkService::DNSConfigChanged(uint32_t aDelayMs) { nsresult nsNetworkLinkService::Init(void) { nsresult rv; - nsCOMPtr observerService = - do_GetService("@mozilla.org/observer-service;1", &rv); + nsCOMPtr observerService; + observerService = mozilla::components::Observer::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); rv = observerService->AddObserver(this, "xpcom-shutdown", false); diff --git a/netwerk/url-classifier/UrlClassifierCommon.cpp b/netwerk/url-classifier/UrlClassifierCommon.cpp index 21589cef9467..151adc93cc8d 100644 --- a/netwerk/url-classifier/UrlClassifierCommon.cpp +++ b/netwerk/url-classifier/UrlClassifierCommon.cpp @@ -222,8 +222,8 @@ nsresult UrlClassifierCommon::SetBlockedContent(nsIChannel* channel, // to correct top-level window), we need to do this in the parent process // instead (find the top-level window in the parent and send an IPC to child // processes to report console). - nsCOMPtr thirdPartyUtil = - components::ThirdPartyUtil::Service(); + nsCOMPtr thirdPartyUtil; + thirdPartyUtil = mozilla::components::ThirdPartyUtil::Service(); if (NS_WARN_IF(!thirdPartyUtil)) { return NS_OK; } @@ -366,8 +366,8 @@ nsresult UrlClassifierCommon::CreatePairwiseEntityListURI(nsIChannel* aChannel, return NS_OK; } - nsCOMPtr securityManager = - do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); + nsCOMPtr securityManager; + securityManager = mozilla::components::ScriptSecurityManager::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr chanPrincipal; rv = securityManager->GetChannelURIPrincipal(aChannel, diff --git a/netwerk/url-classifier/nsChannelClassifier.cpp b/netwerk/url-classifier/nsChannelClassifier.cpp index b9bdb3a050d4..76aabeabfbe4 100644 --- a/netwerk/url-classifier/nsChannelClassifier.cpp +++ b/netwerk/url-classifier/nsChannelClassifier.cpp @@ -186,7 +186,7 @@ nsresult nsChannelClassifier::StartInternal() { } nsCOMPtr uriClassifier = - do_GetService(NS_URICLASSIFIERSERVICE_CONTRACTID, &rv); + mozilla::components::UrlClassifierDB::Service(&rv); if (rv == NS_ERROR_FACTORY_NOT_REGISTERED || rv == NS_ERROR_NOT_AVAILABLE) { // no URI classifier, ignore this failure. return NS_ERROR_NOT_AVAILABLE; @@ -194,7 +194,7 @@ nsresult nsChannelClassifier::StartInternal() { NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr securityManager = - do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv); + mozilla::components::ScriptSecurityManager::Service(&rv); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr principal; diff --git a/netwerk/wifi/nsWifiMonitor.cpp b/netwerk/wifi/nsWifiMonitor.cpp index f437dec4bd08..ccab3cae4bf9 100644 --- a/netwerk/wifi/nsWifiMonitor.cpp +++ b/netwerk/wifi/nsWifiMonitor.cpp @@ -18,6 +18,7 @@ #include "nsNetCID.h" #include "nsComponentManagerUtils.h" +#include "mozilla/Components.h" #include "mozilla/DelayedRunnable.h" #include "mozilla/IntegerPrintfMacros.h" #include "mozilla/StaticPrefs_network.h" @@ -95,8 +96,8 @@ nsWifiMonitor::nsWifiMonitor(UniquePtr&& aScanner) } nsresult rv; - nsCOMPtr nls = - do_GetService(NS_NETWORK_LINK_SERVICE_CONTRACTID, &rv); + nsCOMPtr nls; + nls = do_GetService(NS_NETWORK_LINK_SERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv) && nls) { uint32_t linkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN; rv = nls->GetLinkType(&linkType); diff --git a/security/manager/ssl/components.conf b/security/manager/ssl/components.conf index 7bdcae356ab1..788527eb03d5 100644 --- a/security/manager/ssl/components.conf +++ b/security/manager/ssl/components.conf @@ -10,6 +10,7 @@ Headers = [ Classes = [ { + 'name': 'NSSComponent', 'cid': '{4cb64dfd-ca98-4e24-befd-0d9285a33bcb}', 'contract_ids': ['@mozilla.org/psm;1'], 'type': 'nsNSSComponent', @@ -17,6 +18,7 @@ Classes = [ 'init_method': 'Init', }, { + 'name': 'NSSErrors', 'cid': '{9ef18451-a157-4d17-8132-47afef213689}', 'contract_ids': ['@mozilla.org/nss_errors_service;1'], 'type': 'mozilla::psm::NSSErrorsService', @@ -54,6 +56,7 @@ Classes = [ 'headers': ['nsNSSCertificate.h'], }, { + 'name': 'NSSCertificateDB', 'cid': '{fb0bbc5c-452e-4783-b32c-80124693d871}', 'contract_ids': ['@mozilla.org/security/x509certdb;1'], 'type': 'nsNSSCertificateDB', @@ -86,6 +89,7 @@ Classes = [ 'init_method': 'Init', }, { + 'name': 'RandomGenerator', 'cid': '{be65e2b7-fe46-4e0f-88e0-4b385db4d68a}', 'contract_ids': ['@mozilla.org/security/random-generator;1'], 'type': 'nsRandomGenerator', @@ -97,6 +101,7 @@ Classes = [ 'type': 'mozilla::psm::TransportSecurityInfo', }, { + 'name': 'SiteSecurity', 'cid': '{16955eee-6c48-4152-9309-c42a465138a1}', 'contract_ids': ['@mozilla.org/ssservice;1'], 'type': 'nsSiteSecurityService', diff --git a/toolkit/components/places/components.conf b/toolkit/components/places/components.conf index af18830a2991..a9a89c4e9d18 100644 --- a/toolkit/components/places/components.conf +++ b/toolkit/components/places/components.conf @@ -112,6 +112,7 @@ Classes = [ }, { + 'name': 'PlacesPreviewsHelper', 'cid': '{bd0a4d3b-ff26-4d4d-9a62-a513e1c1bf92}', 'contract_ids': ['@mozilla.org/places/previews-helper;1'], 'esModule': 'resource://gre/modules/PlacesPreviews.sys.mjs', diff --git a/toolkit/components/prompts/src/components.conf b/toolkit/components/prompts/src/components.conf index 32a6df21a2df..318bf72a58c0 100644 --- a/toolkit/components/prompts/src/components.conf +++ b/toolkit/components/prompts/src/components.conf @@ -6,6 +6,7 @@ Classes = [ { + 'name': 'AuthPromptAdapter', 'cid': '{6e134924-6c3a-4d86-81ac-69432dd971dc}', 'contract_ids': ['@mozilla.org/network/authprompt-adapter-factory;1'], 'esModule': 'resource://gre/modules/Prompter.sys.mjs', diff --git a/toolkit/components/thumbnails/components.conf b/toolkit/components/thumbnails/components.conf index d472b23bed37..6d9ba4e369a4 100644 --- a/toolkit/components/thumbnails/components.conf +++ b/toolkit/components/thumbnails/components.conf @@ -6,6 +6,7 @@ Classes = [ { + 'name': 'PageThumbsStorage', 'cid': '{97943eec-0e48-49ef-b7b7-cf4aa0109bb6}', 'contract_ids': ['@mozilla.org/thumbnails/pagethumbs-service;1'], 'esModule': 'resource://gre/modules/PageThumbsStorageService.sys.mjs', diff --git a/toolkit/xre/components.conf b/toolkit/xre/components.conf index b59964e79445..41fbdb00b993 100644 --- a/toolkit/xre/components.conf +++ b/toolkit/xre/components.conf @@ -37,6 +37,7 @@ Classes = [ 'headers': ['/dom/webbrowserpersist/nsWebBrowserPersist.h'], }, { + 'name': 'WindowWatcher', 'js_name': 'ww', 'cid': '{a21bfa01-f349-4394-a84c-8de5cf0737d0}', 'contract_ids': ['@mozilla.org/embedcomp/window-watcher;1'], diff --git a/xpcom/build/components.conf b/xpcom/build/components.conf index a34076a525b7..7cb61da93c30 100644 --- a/xpcom/build/components.conf +++ b/xpcom/build/components.conf @@ -42,6 +42,7 @@ Classes = [ 'constructor': 'nsChromeRegistry::GetSingleton', }, { + 'name': 'Console', 'js_name': 'console', 'cid': '{7e3ff85c-1dd2-11b2-8d4b-eb452cb0ff40}', 'contract_ids': ['@mozilla.org/consoleservice;1'], @@ -196,6 +197,7 @@ Classes = [ 'headers': ['nsSupportsPrimitives.h'], }, { + 'name': 'SystemInfo', 'js_name': 'sysinfo', 'cid': '{d962398a-99e5-49b2-857a-c159049c7f6c}', 'contract_ids': ['@mozilla.org/system-info;1'], diff --git a/xpcom/components/components.conf b/xpcom/components/components.conf index 9938fb104f81..2bfadb199243 100644 --- a/xpcom/components/components.conf +++ b/xpcom/components/components.conf @@ -6,6 +6,7 @@ Classes = [ { + 'name': 'CategoryManager', 'js_name': 'catMan', 'cid': '{16d222a6-1dd2-11b2-b693-f38b02c021b2}', 'contract_ids': ['@mozilla.org/categorymanager;1'],