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
This commit is contained in:
Sean 2024-05-22 17:13:29 +00:00
parent 6bfbc8845c
commit 3cbf13bd8f
57 changed files with 274 additions and 200 deletions

View File

@ -180,6 +180,7 @@ if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] == 'android':
else:
Classes += [
{
'name': 'Mime',
'cid': '{a7f800e0-4306-11d4-98d0-001083010e9b}',
'contract_ids': [
'@mozilla.org/mime;1',

View File

@ -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'],

View File

@ -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'],

View File

@ -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"
@ -195,7 +196,7 @@ BackgroundFileSaver::EnableSha256() {
// Ensure Personal Security Manager is initialized. This is required for
// PK11_* operations to work.
nsresult rv;
nsCOMPtr<nsISupports> nssDummy = do_GetService("@mozilla.org/psm;1", &rv);
mozilla::components::NSSComponent::Service(&rv);
NS_ENSURE_SUCCESS(rv, rv);
MutexAutoLock lock(mLock);
mSha256Enabled = true; // this will be read by the worker thread
@ -220,7 +221,7 @@ BackgroundFileSaver::EnableSignatureInfo() {
"Can't enable signature extraction off the main thread");
// Ensure Personal Security Manager is initialized.
nsresult rv;
nsCOMPtr<nsISupports> nssDummy = do_GetService("@mozilla.org/psm;1", &rv);
mozilla::components::NSSComponent::Service(&rv);
NS_ENSURE_SUCCESS(rv, rv);
MutexAutoLock lock(mLock);
mSignatureInfoEnabled = true;

View File

@ -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)),

View File

@ -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<nsIEventTarget> sts;
nsCOMPtr<nsIIOService> 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);

View File

@ -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<nsINetworkPredictor> predictor =
do_GetService("@mozilla.org/network/predictor;1", &rv);
nsCOMPtr<nsINetworkPredictor> predictor;
predictor = mozilla::components::Predictor::Service(&rv);
NS_ENSURE_SUCCESS(rv, rv);
sPredictor = predictor;
ClearOnShutdown(&sPredictor);

View File

@ -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<nsIX509CertDB> certDB =
do_GetService(NS_X509CERTDB_CONTRACTID, &rv);
nsCOMPtr<nsIX509CertDB> certDB;
certDB = mozilla::components::NSSConstructor::Service(&rv);
if (NS_FAILED(rv)) {
return rv;
}

View File

@ -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<nsIEventTarget> sts;
nsCOMPtr<nsIIOService> 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);
}

View File

@ -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;
}

View File

@ -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<CaptivePortalService*>(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");
}
@ -507,7 +508,7 @@ nsresult nsIOService::InitializeNetworkLinkService() {
return NS_ERROR_NOT_AVAILABLE;
}
mNetworkLinkService = do_GetService(NS_NETWORK_LINK_SERVICE_CONTRACTID, &rv);
mNetworkLinkService = mozilla::components::NetworkLink::Service(&rv);
if (mNetworkLinkService) {
mNetworkLinkServiceInitialized = true;
@ -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<nsIChannelEventSink> sink =
do_GetService(NS_CONTENTSECURITYMANAGER_CONTRACTID);
nsCOMPtr<nsIChannelEventSink> 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<nsIUploadChannel2> uploadChannel2 = do_QueryInterface(channel);
if (!uploadChannel2) {
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
nsCOMPtr<nsIConsoleService> consoleService;
consoleService = mozilla::components::Console::Service();
if (consoleService) {
consoleService->LogStringMessage(
u"Http channel implementation "
@ -1706,8 +1707,7 @@ nsIOService::Observe(nsISupports* subject, const char* topic,
// Bug 870460 - Read cookie database at an early-as-possible time
// off main thread. Hence, we have more chance to finish db query
// before something calls into the cookie service.
nsCOMPtr<nsISupports> cookieServ =
do_GetService(NS_COOKIESERVICE_CONTRACTID);
mozilla::components::Cookies::Service();
}
} else if (!strcmp(topic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)) {
// Remember we passed XPCOM shutdown notification to prevent any
@ -2051,8 +2051,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<nsIProtocolProxyService> pps =
do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIProtocolProxyService> pps;
pps = mozilla::components::ProtocolProxy::Service(&rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> loadingPrincipal = aPrincipal;

View File

@ -128,7 +128,8 @@ using mozilla::dom::ServiceWorkerDescriptor;
#define MAX_RECURSION_COUNT 50
already_AddRefed<nsIIOService> do_GetIOService(nsresult* error /* = 0 */) {
nsCOMPtr<nsIIOService> io = mozilla::components::IO::Service();
nsCOMPtr<nsIIOService> 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<nsIProtocolProxyService> pps =
do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIProtocolProxyService> 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<nsINetUtil> do_GetNetUtil(nsresult* error /* = 0 */) {
nsCOMPtr<nsIIOService> io = mozilla::components::IO::Service();
nsCOMPtr<nsIIOService> io;
nsCOMPtr<nsINetUtil> 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<nsIEventTarget> target =
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
nsCOMPtr<nsIEventTarget> 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<nsIAuthPromptAdapterFactory> factory =
do_GetService(NS_AUTHPROMPT_ADAPTER_FACTORY_CONTRACTID);
nsCOMPtr<nsIAuthPromptAdapterFactory> 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<nsIMIMEHeaderParam> mimehdrpar =
do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv);
nsCOMPtr<nsIMIMEHeaderParam> 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<nsIMIMEHeaderParam> mimehdrpar =
do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv);
nsCOMPtr<nsIMIMEHeaderParam> 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<nsITextToSubURI> textToSubURI =
do_GetService(NS_ITEXTTOSUBURI_CONTRACTID, &rv);
nsCOMPtr<nsITextToSubURI> textToSubURI;
textToSubURI = mozilla::components::TextToSubURI::Service(&rv);
if (NS_SUCCEEDED(rv)) {
nsAutoString unescaped;
textToSubURI->UnEscapeURIForUI(NS_ConvertUTF16toUTF8(aFilename),
@ -3511,8 +3514,8 @@ already_AddRefed<nsIURI> TryChangeProtocol(nsIURI* aURI,
// passed value alone)
static bool Decode5987Format(nsAString& aEncoded) {
nsresult rv;
nsCOMPtr<nsIMIMEHeaderParam> mimehdrpar =
do_GetService(NS_MIMEHEADERPARAM_CONTRACTID, &rv);
nsCOMPtr<nsIMIMEHeaderParam> mimehdrpar;
mimehdrpar = mozilla::components::MimeHeaderParam::Service(&rv);
if (NS_FAILED(rv)) return false;
nsAutoCString asciiValue;

View File

@ -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<nsIEventTarget> target =
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIEventTarget> target;
target = mozilla::components::StreamTransport::Service(&rv);
if (NS_FAILED(rv)) return rv;
// XXX if the caller requests an unbuffered stream, then perhaps

View File

@ -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<nsIDNSService> dns =
do_GetService("@mozilla.org/network/dns-service;1", &rv);
nsCOMPtr<nsIDNSService> 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<nsISocketTransportService> sts =
do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID);
mozilla::components::SocketTransport::Service();
}
mSts = gSocketTransportService;

View File

@ -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',
@ -723,6 +733,7 @@ Classes = [
'processes': ProcessSelector.ALLOW_IN_SOCKET_PROCESS,
},
{
'name': 'Cookies',
'js_name': 'cookies',
'cid': '{c375fa80-150f-11d6-a618-0010a401eb10}',
'contract_ids': [
@ -792,6 +803,7 @@ elif buildconfig.substs['OS_ARCH'] == 'Linux':
if link_service:
Classes += [
dict({
'name': 'NetworkLink',
'cid': '{75a500a2-0030-40f7-86f8-63f225b940ae}',
'contract_ids': ['@mozilla.org/network/network-link-service;1'],
'singleton': True,

View File

@ -254,13 +254,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.

View File

@ -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<nsIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIDNSService> dns;
dns = mozilla::components::DNS::Service(&rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIEventTarget> main = GetMainThreadSerialEventTarget();
nsCOMPtr<nsICancelable> 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<nsIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIDNSService> dns;
dns = mozilla::components::DNS::Service(&rv);
if (NS_SUCCEEDED(rv)) {
RefPtr<DNSAdditionalInfo> info;
if (!aTrrServer.IsEmpty() || port != -1) {

View File

@ -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<nsCString>&& aDNSSuffixList) {
nsCOMPtr<nsIDNSService> dns =
do_GetService("@mozilla.org/network/dns-service;1");
nsCOMPtr<nsIDNSService> dns;
dns = mozilla::components::DNS::Service();
sDNSService = dns;
ClearOnShutdown(&sDNSService);
MOZ_ASSERT(sDNSService);

View File

@ -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<nsIEffectiveTLDService> tldService =
do_GetService(NS_EFFECTIVETLDSERVICE_CONTRACTID);
nsCOMPtr<nsIEffectiveTLDService> tldService;
tldService = mozilla::components::EffectiveTLD::Service();
if (!tldService) {
return nullptr;
}

View File

@ -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<nsIStreamConverterService> streamConvService =
do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIStreamConverterService> streamConvService;
nsAutoCString str;
streamConvService = mozilla::components::StreamConverter::Service(&rv);
rv = streamConvService->ConvertedType(mContentType, aChannel, str);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -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<nsINetworkPredictorVerifier> predictor =
do_GetService("@mozilla.org/network/predictor;1", &rv);
nsCOMPtr<nsINetworkPredictorVerifier> 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<nsINetworkPredictorVerifier> predictor =
do_GetService("@mozilla.org/network/predictor;1", &rv);
nsCOMPtr<nsINetworkPredictorVerifier> 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<nsINetworkPredictorVerifier> predictor =
do_GetService("@mozilla.org/network/predictor;1", &rv);
nsCOMPtr<nsINetworkPredictorVerifier> predictor;
predictor = mozilla::components::Predictor::Service(&rv);
NS_ENSURE_SUCCESS(rv, IPC_FAIL_NO_REASON(this));
predictor->OnPredictDNS(aURI);

View File

@ -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"
@ -78,8 +79,7 @@ NeckoParent::NeckoParent() : mSocketProcessBridgeInited(false) {
// Init HTTP protocol handler now since we need atomTable up and running very
// early (IPDL argument handling for PHttpChannel constructor needs it) so
// normal init (during 1st Http channel request) isn't early enough.
nsCOMPtr<nsIProtocolHandler> proto =
do_GetService("@mozilla.org/network/protocol;1?name=http");
mozilla::components::HttpHandler::Service();
}
static PBOverrideStatus PBOverrideStatusFromLoadContext(
@ -572,8 +572,8 @@ mozilla::ipc::IPCResult NeckoParent::RecvPredPredict(
const OriginAttributes& aOriginAttributes, const bool& hasVerifier) {
// Get the current predictor
nsresult rv = NS_OK;
nsCOMPtr<nsINetworkPredictor> predictor =
do_GetService("@mozilla.org/network/predictor;1", &rv);
nsCOMPtr<nsINetworkPredictor> predictor;
predictor = mozilla::components::Predictor::Service(&rv);
NS_ENSURE_SUCCESS(rv, IPC_OK());
nsCOMPtr<nsINetworkPredictorVerifier> verifier;
@ -590,8 +590,8 @@ mozilla::ipc::IPCResult NeckoParent::RecvPredLearn(
const OriginAttributes& aOriginAttributes) {
// Get the current predictor
nsresult rv = NS_OK;
nsCOMPtr<nsINetworkPredictor> predictor =
do_GetService("@mozilla.org/network/predictor;1", &rv);
nsCOMPtr<nsINetworkPredictor> predictor;
predictor = mozilla::components::Predictor::Service(&rv);
NS_ENSURE_SUCCESS(rv, IPC_OK());
predictor->LearnNative(aTargetURI, aSourceURI, aReason, aOriginAttributes);
@ -601,8 +601,8 @@ mozilla::ipc::IPCResult NeckoParent::RecvPredLearn(
mozilla::ipc::IPCResult NeckoParent::RecvPredReset() {
// Get the current predictor
nsresult rv = NS_OK;
nsCOMPtr<nsINetworkPredictor> predictor =
do_GetService("@mozilla.org/network/predictor;1", &rv);
nsCOMPtr<nsINetworkPredictor> predictor;
predictor = mozilla::components::Predictor::Service(&rv);
NS_ENSURE_SUCCESS(rv, IPC_OK());
predictor->Reset();

View File

@ -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<nsIProtocolProxyService> pps =
do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIProtocolProxyService> pps;
pps = mozilla::components::ProtocolProxy::Service(&rv);
if (NS_FAILED(rv)) {
return rv;
}

View File

@ -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<nsISerialEventTarget> mSTSThread =
do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &res);
nsCOMPtr<nsISerialEventTarget> 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

View File

@ -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<nsIDNSService> 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<nsIHttpActivityObserver> distributor =
components::HttpActivityDistributor::Service()) {
nsCOMPtr<nsIHttpActivityObserver> 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<nsIHttpActivityDistributor> distributor =
do_GetService("@mozilla.org/network/http-activity-distributor;1");
nsCOMPtr<nsIHttpActivityDistributor> 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<nsIHttpActivityDistributor> distributor =
do_GetService("@mozilla.org/network/http-activity-distributor;1");
nsCOMPtr<nsIHttpActivityDistributor> 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<nsIDNSService> dns =
do_GetService("@mozilla.org/network/dns-service;1", &rv);
nsCOMPtr<nsIDNSService> dns;
dns = mozilla::components::DNS::Service(&rv);
if (NS_FAILED(rv)) {
aResolve(nsTArray<DNSCacheEntries>());
return IPC_OK();

View File

@ -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<nsICacheStorageService> cacheService =
do_GetService("@mozilla.org/netwerk/cache-storage-service;1", &rv);
nsCOMPtr<nsICacheStorageService> cacheService;
cacheService = mozilla::components::CacheStorage::Service(&rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsICacheStorage> cacheStorage;

View File

@ -30,6 +30,7 @@
#include "prio.h"
#include <algorithm>
#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<nsIEventTarget> pool =
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIEventTarget> pool;
pool = mozilla::components::StreamTransport::Service(&rv);
if (NS_FAILED(rv)) return rv;
return pool->Dispatch(this, NS_DISPATCH_NORMAL);
@ -320,7 +321,8 @@ nsresult nsFileChannel::MakeFileInputStream(nsIFile* file,
async ? nsIFileInputStream::DEFER_OPEN : 0);
if (NS_SUCCEEDED(rv) && !HasContentTypeHint()) {
// Use file extension to infer content type
nsCOMPtr<nsIMIMEService> mime = do_GetService("@mozilla.org/mime;1", &rv);
nsCOMPtr<nsIMIMEService> mime;
mime = mozilla::components::Mime::Service(&rv);
if (NS_SUCCEEDED(rv)) {
mime->GetTypeFromFile(file, contentType);
}
@ -427,8 +429,7 @@ nsresult nsFileChannel::ListenerBlockingPromise(BlockingPromise** aPromise) {
return NS_OK;
}
nsCOMPtr<nsIEventTarget> sts(
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID));
nsCOMPtr<nsIEventTarget> sts(mozilla::components::StreamTransport::Service());
if (!sts) {
return FixupContentLength(true);
}

View File

@ -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<nsICacheStorageService> css =
do_GetService("@mozilla.org/netwerk/cache-storage-service;1", &rv);
nsCOMPtr<nsICacheStorageService> css;
css = mozilla::components::CacheStorage::Service(&rv);
if (NS_FAILED(rv)) {
return rv;
}

View File

@ -209,8 +209,8 @@ nsresult DnsAndConnectSocket::SetupDnsFlags(ConnectionEntry* ent) {
if (ent->mConnInfo->HasIPHintAddress()) {
nsresult rv;
nsCOMPtr<nsIDNSService> dns =
do_GetService("@mozilla.org/network/dns-service;1", &rv);
nsCOMPtr<nsIDNSService> 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<nsIDNSService> dns =
do_GetService("@mozilla.org/network/dns-service;1", &rv);
nsCOMPtr<nsIDNSService> dns;
dns = mozilla::components::DNS::Service(&rv);
NS_ENSURE_SUCCESS(rv, rv);
// The spec says: "If A and AAAA records for TargetName are locally

View File

@ -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"
@ -119,8 +120,7 @@ HttpChannelParent::HttpChannelParent(dom::BrowserParent* iframeEmbedding,
LOG(("Creating HttpChannelParent [this=%p]\n", this));
// Ensure gHttpHandler is initialized: we need the atom table up and running.
nsCOMPtr<nsIHttpProtocolHandler> dummyInitializer =
do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http");
mozilla::components::HttpHandler::Service();
MOZ_ASSERT(gHttpHandler);
mHttpHandler = gHttpHandler;
@ -325,8 +325,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<nsIWindowWatcher> wwatch =
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
nsCOMPtr<nsIWindowWatcher> wwatch;
wwatch = mozilla::components::WindowWatcher::Service(&rv);
NS_ENSURE_SUCCESS(rv, NS_ERROR_NO_INTERFACE);
bool hasWindowCreator = false;

View File

@ -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;
}

View File

@ -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<nsIWindowWatcher> wwatch =
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
nsCOMPtr<nsIWindowWatcher> 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<nsIPromptFactory> wwatch =
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
nsCOMPtr<nsIPromptFactory> wwatch;
wwatch = mozilla::components::WindowWatcher::Service(&rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsPIDOMWindowOuter> window;

View File

@ -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<nsIConsoleService> 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;

View File

@ -1809,7 +1809,7 @@ nsresult nsHttpChannel::CallOnStartRequest() {
if (contentType.Equals("multipart/x-mixed-replace"_ns)) {
nsCOMPtr<nsIStreamConverterService> convServ(
do_GetService("@mozilla.org/streamConverters;1", &rv));
mozilla::components::StreamConverter::Service(&rv));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIStreamListener> toListener(mListener);
nsCOMPtr<nsIStreamListener> fromListener;
@ -2897,8 +2897,8 @@ nsresult nsHttpChannel::PromptTempRedirect() {
return NS_OK;
}
nsresult rv;
nsCOMPtr<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
nsCOMPtr<nsIStringBundleService> bundleService;
bundleService = mozilla::components::StringBundle::Service(&rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStringBundle> stringBundle;
@ -2927,8 +2927,8 @@ nsresult nsHttpChannel::ProxyFailover() {
nsresult rv;
nsCOMPtr<nsIProtocolProxyService> pps =
do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIProtocolProxyService> pps;
pps = mozilla::components::ProtocolProxy::Service(&rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIProxyInfo> pi;
@ -3314,8 +3314,8 @@ nsresult nsHttpChannel::ResolveProxy() {
nsresult rv;
nsCOMPtr<nsIProtocolProxyService> pps =
do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIProtocolProxyService> pps;
pps = mozilla::components::ProtocolProxy::Service(&rv);
if (NS_FAILED(rv)) return rv;
// using the nsIProtocolProxyService2 allows a minor performance
@ -5531,8 +5531,9 @@ nsresult nsHttpChannel::AsyncProcessRedirection(uint32_t redirectType) {
if (!isRedirectURIInAllowList) {
nsCOMPtr<nsIURI> strippedURI;
nsCOMPtr<nsIURLQueryStringStripper> queryStripper =
components::URLQueryStringStripper::Service(&rv);
nsCOMPtr<nsIURLQueryStringStripper> queryStripper;
queryStripper =
mozilla::components::URLQueryStringStripper::Service(&rv);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t numStripped;
@ -6595,8 +6596,8 @@ nsresult nsHttpChannel::BeginConnect() {
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
nsCOMPtr<nsIConsoleService> consoleService;
consoleService = mozilla::components::Console::Service();
if (consoleService && !host.Equals(mapping->AlternateHost())) {
nsAutoString message(u"Alternate Service Mapping found: "_ns);
AppendASCIItoUTF16(scheme, message);
@ -7778,8 +7779,7 @@ static nsLiteralCString ContentTypeToTelemetryLabel(nsHttpChannel* aChannel) {
}
nsresult nsHttpChannel::LogConsoleError(const char* aTag) {
nsCOMPtr<nsIConsoleService> console(
do_GetService(NS_CONSOLESERVICE_CONTRACTID));
nsCOMPtr<nsIConsoleService> console(mozilla::components::Console::Service());
NS_ENSURE_TRUE(console, NS_ERROR_OUT_OF_MEMORY);
nsCOMPtr<nsILoadInfo> loadInfo = LoadInfo();
@ -8554,8 +8554,8 @@ nsHttpChannel::OnDataAvailable(nsIRequest* request, nsIInputStream* input,
count = delta;
NS_WARNING("Listener OnDataAvailable contract violation");
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
nsCOMPtr<nsIConsoleService> consoleService;
consoleService = mozilla::components::Console::Service();
nsAutoString message(nsLiteralString(
u"http channel Listener OnDataAvailable contract violation"));
if (consoleService) {
@ -10045,8 +10045,8 @@ nsresult nsHttpChannel::TriggerNetwork() {
void nsHttpChannel::MaybeRaceCacheWithNetwork() {
nsresult rv;
nsCOMPtr<nsINetworkLinkService> netLinkSvc =
do_GetService(NS_NETWORK_LINK_SERVICE_CONTRACTID, &rv);
nsCOMPtr<nsINetworkLinkService> netLinkSvc;
netLinkSvc = mozilla::components::NetworkLink::Service(&rv);
if (NS_FAILED(rv)) {
return;
}

View File

@ -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<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
nsCOMPtr<nsIStringBundleService> bundleService;
bundleService = mozilla::components::StringBundle::Service();
if (!bundleService) return true;
nsCOMPtr<nsIStringBundle> bundle;
@ -1748,8 +1749,8 @@ bool nsHttpChannelAuthProvider::ConfirmAuth(const char* bundleKey,
rv = mAuthChannel->GetLoadGroup(getter_AddRefs(loadGroup));
if (NS_FAILED(rv)) return true;
nsCOMPtr<nsIPromptService> promptSvc =
do_GetService("@mozilla.org/prompter;1", &rv);
nsCOMPtr<nsIPromptService> promptSvc;
promptSvc = mozilla::components::Prompt::Service(&rv);
if (NS_FAILED(rv) || !promptSvc) {
return true;
}

View File

@ -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<nsIPropertyBag2> infoService =
do_GetService("@mozilla.org/system-info;1");
nsCOMPtr<nsIPropertyBag2> 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<nsIXULRuntime> runtime = do_GetService("@mozilla.org/xre/runtime;1");
nsCOMPtr<nsIXULRuntime> 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<nsIIOService> service = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIIOService> 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<nsIXULAppInfo> appInfo =
do_GetService("@mozilla.org/xre/app-info;1");
nsCOMPtr<nsIXULAppInfo> 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<nsISiteSecurityService> service =
do_GetService(NS_SSSERVICE_CONTRACTID);
nsCOMPtr<nsISiteSecurityService> service;
service = mozilla::components::SiteSecurity::Service();
mSSService = new nsMainThreadPtrHolder<nsISiteSecurityService>(
"nsHttpHandler::mSSService", service);
}
@ -677,7 +679,7 @@ nsISiteSecurityService* nsHttpHandler::GetSSService() {
nsICookieService* nsHttpHandler::GetCookieService() {
if (!mCookieService) {
nsCOMPtr<nsICookieService> service =
do_GetService(NS_COOKIESERVICE_CONTRACTID);
mozilla::components::Cookies::Service();
mCookieService = new nsMainThreadPtrHolder<nsICookieService>(
"nsHttpHandler::mCookieService", service);
}
@ -889,8 +891,8 @@ void nsHttpHandler::InitUserAgentComponents() {
#endif
#ifdef ANDROID
nsCOMPtr<nsIPropertyBag2> infoService =
do_GetService("@mozilla.org/system-info;1");
nsCOMPtr<nsIPropertyBag2> infoService;
infoService = mozilla::components::SystemInfo::Service();
MOZ_ASSERT(infoService, "Could not find a system info service");
nsresult rv;
@ -2382,7 +2384,7 @@ NS_IMPL_ISUPPORTS(nsHttpsHandler, nsIHttpProtocolHandler,
nsresult nsHttpsHandler::Init() {
nsCOMPtr<nsIProtocolHandler> httpHandler(
do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http"));
mozilla::components::HttpHandler::Service());
MOZ_ASSERT(httpHandler.get() != nullptr);
return NS_OK;
}

View File

@ -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<nsIStreamConverterService> convService =
do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIStreamConverterService> convService;
convService = mozilla::components::StreamConverter::Service(&rv);
MOZ_TRY(rv);
nsCOMPtr<nsIURI> uri;
@ -901,7 +902,8 @@ Result<Ok, nsresult> ExtensionProtocolHandler::NewFD(
void ExtensionProtocolHandler::SetContentType(nsIURI* aURI,
nsIChannel* aChannel) {
nsresult rv;
nsCOMPtr<nsIMIMEService> mime = do_GetService("@mozilla.org/mime;1", &rv);
nsCOMPtr<nsIMIMEService> mime;
mime = mozilla::components::Mime::Service(&rv);
if (NS_SUCCEEDED(rv)) {
nsAutoCString contentType;
rv = mime->GetTypeFromURI(aURI, contentType);

View File

@ -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"
@ -151,7 +152,8 @@ RefPtr<RemoteStreamPromise> PageThumbProtocolHandler::NewStream(
auto promiseHolder = MakeUnique<MozPromiseHolder<RemoteStreamPromise>>();
RefPtr<RemoteStreamPromise> promise = promiseHolder->Ensure(__func__);
nsCOMPtr<nsIMIMEService> mime = do_GetService("@mozilla.org/mime;1", &rv);
nsCOMPtr<nsIMIMEService> mime;
mime = mozilla::components::Mime::Service(&rv);
if (NS_FAILED(rv)) {
return RemoteStreamPromise::CreateAndReject(rv, __func__);
}
@ -313,8 +315,8 @@ nsresult PageThumbProtocolHandler::GetThumbnailPath(const nsACString& aPath,
nsresult rv;
if (aHost.EqualsLiteral(PAGE_THUMB_HOST)) {
nsCOMPtr<nsIPageThumbsStorageService> pageThumbsStorage =
do_GetService("@mozilla.org/thumbnails/pagethumbs-service;1", &rv);
nsCOMPtr<nsIPageThumbsStorageService> pageThumbsStorage;
pageThumbsStorage = mozilla::components::PageThumbsStorage::Service(&rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
@ -324,8 +326,8 @@ nsresult PageThumbProtocolHandler::GetThumbnailPath(const nsACString& aPath,
aThumbnailPath);
#ifdef MOZ_PLACES
} else if (aHost.EqualsLiteral(PLACES_PREVIEWS_HOST)) {
nsCOMPtr<nsIPlacesPreviewsHelperService> helper =
do_GetService("@mozilla.org/places/previews-helper;1", &rv);
nsCOMPtr<nsIPlacesPreviewsHelperService> helper;
helper = mozilla::components::PlacesPreviewsHelper::Service(&rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}

View File

@ -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<nsIPrefBranch> prefService =
do_GetService(NS_PREFSERVICE_CONTRACTID);
nsCOMPtr<nsIPrefBranch> prefService;
prefService = mozilla::components::Preferences::Service();
if (!prefService) {
return;
}
@ -1224,8 +1225,7 @@ WebSocketChannel::WebSocketChannel()
mFramePtr = mBuffer = static_cast<uint8_t*>(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<nsIPrefBranch> prefService =
do_GetService(NS_PREFSERVICE_CONTRACTID);
nsCOMPtr<nsIPrefBranch> 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<nsIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIDNSService> dns;
dns = mozilla::components::DNS::Service(&rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIEventTarget> main = GetMainThreadSerialEventTarget();
nsCOMPtr<nsICancelable> 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<nsIProtocolProxyService> pps =
do_GetService(NS_PROTOCOLPROXYSERVICE_CONTRACTID);
nsCOMPtr<nsIProtocolProxyService> 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<nsIPrefBranch> 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<nsIIOService> 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<nsINSSErrorsService> errSvc =
do_GetService("@mozilla.org/nss_errors_service;1");
nsCOMPtr<nsINSSErrorsService> errSvc;
errSvc = mozilla::components::NSSErrors::Service();
// If GetErrorClass succeeds httpStatus is TLS related failure.
if (errSvc &&
NS_SUCCEEDED(errSvc->GetErrorClass(httpStatus, &errorClass))) {

View File

@ -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;
}

View File

@ -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;

View File

@ -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<nsIPrefService> prefs =
do_GetService("@mozilla.org/preferences-service;1", &rv);
nsCOMPtr<nsIPrefService> prefs;
prefs = mozilla::components::Preferences::Service(&rv);
if (!NS_WARN_IF(NS_FAILED(rv))) {
nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(prefs);

View File

@ -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<nsIProtocolHandler> 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<nsIDNSService> dns = do_GetService(NS_DNSSERVICE_CONTRACTID);
nsCOMPtr<nsIDNSService> dns;
dns = mozilla::components::DNS::Service();
if (!dns) return PR_FAILURE;
nsCString proxyHost;

View File

@ -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<nsIStringBundleService> sbs =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
nsCOMPtr<nsIStringBundleService> 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;
}

View File

@ -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<nsIStreamListener> partListener(mFinalListener);
if (mContentType.IsEmpty()) {
mContentType.AssignLiteral(UNKNOWN_CONTENT_TYPE);
nsCOMPtr<nsIStreamConverterService> serv =
do_GetService(NS_STREAMCONVERTERSERVICE_CONTRACTID, &rv);
nsCOMPtr<nsIStreamConverterService> serv;
serv = mozilla::components::StreamConverter::Service(&rv);
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIStreamListener> converter;
rv = serv->AsyncConvertData(UNKNOWN_CONTENT_TYPE, "*/*", mFinalListener,

View File

@ -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<nsICategoryManager> catmgr(
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
mozilla::components::CategoryManager::Service(&rv));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISimpleEnumerator> entries;

View File

@ -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<nsIEventTarget> target =
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
nsCOMPtr<nsIEventTarget> 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<nsIEventTarget> target =
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
nsCOMPtr<nsIEventTarget> 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<nsIObserverService> observerService =
do_GetService("@mozilla.org/observer-service;1", &rv);
nsCOMPtr<nsIObserverService> observerService;
observerService = mozilla::components::Observer::Service(&rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = observerService->AddObserver(this, "xpcom-shutdown", false);

View File

@ -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<mozIThirdPartyUtil> thirdPartyUtil =
components::ThirdPartyUtil::Service();
nsCOMPtr<mozIThirdPartyUtil> 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<nsIScriptSecurityManager> securityManager =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
nsCOMPtr<nsIScriptSecurityManager> securityManager;
securityManager = mozilla::components::ScriptSecurityManager::Service(&rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> chanPrincipal;
rv = securityManager->GetChannelURIPrincipal(aChannel,

View File

@ -186,7 +186,7 @@ nsresult nsChannelClassifier::StartInternal() {
}
nsCOMPtr<nsIURIClassifier> 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<nsIScriptSecurityManager> securityManager =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
mozilla::components::ScriptSecurityManager::Service(&rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> principal;

View File

@ -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<mozilla::WifiScanner>&& aScanner)
}
nsresult rv;
nsCOMPtr<nsINetworkLinkService> nls =
do_GetService(NS_NETWORK_LINK_SERVICE_CONTRACTID, &rv);
nsCOMPtr<nsINetworkLinkService> nls;
nls = mozilla::components::NetworkLink::Service(&rv);
if (NS_SUCCEEDED(rv) && nls) {
uint32_t linkType = nsINetworkLinkService::LINK_TYPE_UNKNOWN;
rv = nls->GetLinkType(&linkType);

View File

@ -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': 'NSSConstructor',
'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',

View File

@ -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',

View File

@ -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',
@ -16,6 +17,7 @@ Classes = [
if buildconfig.substs['MOZ_WIDGET_TOOLKIT'] not in ('android', 'uikit'):
Classes += [
{
'name': 'Prompt',
'js_name': 'prompt',
'cid': '{1c978d25-b37f-43a8-a2d6-0c7a239ead87}',
'contract_ids': ['@mozilla.org/prompter;1'],

View File

@ -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',

View File

@ -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'],

View File

@ -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'],

View File

@ -6,6 +6,7 @@
Classes = [
{
'name': 'CategoryManager',
'js_name': 'catMan',
'cid': '{16d222a6-1dd2-11b2-b693-f38b02c021b2}',
'contract_ids': ['@mozilla.org/categorymanager;1'],