From 54b8e4e5e4f4550db64bb6127d00b1c04ea87c41 Mon Sep 17 00:00:00 2001 From: Christoph Kerschbaumer Date: Sun, 11 Jan 2015 20:26:40 -0800 Subject: [PATCH] Bug 1110469 - Remove NS_OpenURI (r=sworkman) --- dom/plugins/base/nsPluginHost.cpp | 3 +- dom/xul/XULDocument.cpp | 8 +- editor/libeditor/nsHTMLDataTransfer.cpp | 13 +- intl/hyphenation/hnjstdio.cpp | 17 +- intl/strres/nsStringBundle.cpp | 1 - intl/strres/nsStringBundleTextOverride.cpp | 19 +- js/xpconnect/loader/mozJSSubScriptLoader.cpp | 4 +- layout/style/Loader.cpp | 52 ++--- modules/libjar/nsJARChannel.cpp | 42 ++-- netwerk/base/public/nsNetUtil.h | 217 ++----------------- netwerk/test/TestOpen.cpp | 17 +- rdf/base/nsRDFXMLDataSource.cpp | 21 +- 12 files changed, 122 insertions(+), 292 deletions(-) diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index b16313650a6f7..0fd634003cb0e 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -580,8 +580,7 @@ nsresult nsPluginHost::PostURL(nsISupports* pluginInst, } } - // if we don't have a target, just create a stream. This does - // NS_OpenURI()! + // if we don't have a target, just create a stream. if (streamListener) rv = NewPluginURLStream(NS_ConvertUTF8toUTF16(url), instance, streamListener, diff --git a/dom/xul/XULDocument.cpp b/dom/xul/XULDocument.cpp index bf6d0283acca0..a514d26e14a5b 100644 --- a/dom/xul/XULDocument.cpp +++ b/dom/xul/XULDocument.cpp @@ -2711,11 +2711,9 @@ XULDocument::LoadOverlayInternal(nsIURI* aURI, bool aIsDynamic, // OnStopRequest, so it needs a Terminate. parser->Terminate(); - // Just move on to the next overlay. NS_OpenURI could fail - // just because a channel could not be opened, which can happen - // if a file or chrome package does not exist. + // Just move on to the next overlay. ReportMissingOverlay(aURI); - + // XXX the error could indicate an internal error as well... *aFailureFromContent = true; return rv; @@ -2723,7 +2721,7 @@ XULDocument::LoadOverlayInternal(nsIURI* aURI, bool aIsDynamic, // If it's a 'chrome:' prototype document, then put it into // the prototype cache; other XUL documents will be reloaded - // each time. We must do this after NS_OpenURI and AsyncOpen, + // each time. We must do this after AsyncOpen, // or chrome code will wrongly create a cached chrome channel // instead of a real one. Prototypes are only cached when the // document to be overlayed is chrome to avoid caching overlay diff --git a/editor/libeditor/nsHTMLDataTransfer.cpp b/editor/libeditor/nsHTMLDataTransfer.cpp index 6a0de997af48e..48b3909e3f272 100644 --- a/editor/libeditor/nsHTMLDataTransfer.cpp +++ b/editor/libeditor/nsHTMLDataTransfer.cpp @@ -1083,12 +1083,15 @@ nsresult nsHTMLEditor::InsertObject(const char* aType, nsISupports* aObject, boo nsCOMPtr imageStream; if (insertAsImage) { NS_ASSERTION(fileURI, "The file URI should be retrieved earlier"); - rv = NS_OpenURI(getter_AddRefs(imageStream), - fileURI, - nsContentUtils::GetSystemPrincipal(), - nsILoadInfo::SEC_NORMAL, - nsIContentPolicy::TYPE_OTHER); + nsCOMPtr channel; + rv = NS_NewChannel(getter_AddRefs(channel), + fileURI, + nsContentUtils::GetSystemPrincipal(), + nsILoadInfo::SEC_NORMAL, + nsIContentPolicy::TYPE_OTHER); + NS_ENSURE_SUCCESS(rv, rv); + rv = channel->Open(getter_AddRefs(imageStream)); NS_ENSURE_SUCCESS(rv, rv); } else { imageStream = do_QueryInterface(aObject); diff --git a/intl/hyphenation/hnjstdio.cpp b/intl/hyphenation/hnjstdio.cpp index 103802970b17c..9b6c37a2d3304 100644 --- a/intl/hyphenation/hnjstdio.cpp +++ b/intl/hyphenation/hnjstdio.cpp @@ -36,13 +36,18 @@ hnjFopen(const char* aURISpec, const char* aMode) return nullptr; } - nsCOMPtr instream; - rv = NS_OpenURI(getter_AddRefs(instream), - uri, - nsContentUtils::GetSystemPrincipal(), - nsILoadInfo::SEC_NORMAL, - nsIContentPolicy::TYPE_OTHER); + nsCOMPtr channel; + rv = NS_NewChannel(getter_AddRefs(channel), + uri, + nsContentUtils::GetSystemPrincipal(), + nsILoadInfo::SEC_NORMAL, + nsIContentPolicy::TYPE_OTHER); + if (NS_FAILED(rv)) { + return nullptr; + } + nsCOMPtr instream; + rv = channel->Open(getter_AddRefs(instream)); if (NS_FAILED(rv)) { return nullptr; } diff --git a/intl/strres/nsStringBundle.cpp b/intl/strres/nsStringBundle.cpp index 95deee8de172b..e9299ddaf51c3 100644 --- a/intl/strres/nsStringBundle.cpp +++ b/intl/strres/nsStringBundle.cpp @@ -69,7 +69,6 @@ nsStringBundle::LoadProperties() rv = NS_NewURI(getter_AddRefs(uri), mPropertiesURL); if (NS_FAILED(rv)) return rv; - // We don't use NS_OpenURI because we want to tweak the channel nsCOMPtr channel; rv = NS_NewChannel(getter_AddRefs(channel), uri, diff --git a/intl/strres/nsStringBundleTextOverride.cpp b/intl/strres/nsStringBundleTextOverride.cpp index b9bf15f60559e..49306f52102c0 100644 --- a/intl/strres/nsStringBundleTextOverride.cpp +++ b/intl/strres/nsStringBundleTextOverride.cpp @@ -146,16 +146,19 @@ nsStringBundleTextOverride::Init() nsCOMPtr uri; rv = NS_NewURI(getter_AddRefs(uri), customStringsURLSpec); - if (NS_FAILED(rv)) return rv; + NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr in; - rv = NS_OpenURI(getter_AddRefs(in), - uri, - nsContentUtils::GetSystemPrincipal(), - nsILoadInfo::SEC_NORMAL, - nsIContentPolicy::TYPE_OTHER); + nsCOMPtr channel; + rv = NS_NewChannel(getter_AddRefs(channel), + uri, + nsContentUtils::GetSystemPrincipal(), + nsILoadInfo::SEC_NORMAL, + nsIContentPolicy::TYPE_OTHER); - if (NS_FAILED(rv)) return rv; + NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr in; + rv = channel->Open(getter_AddRefs(in)); + NS_ENSURE_SUCCESS(rv, rv); static NS_DEFINE_CID(kPersistentPropertiesCID, NS_IPERSISTENTPROPERTIES_CID); mValues = do_CreateInstance(kPersistentPropertiesCID, &rv); diff --git a/js/xpconnect/loader/mozJSSubScriptLoader.cpp b/js/xpconnect/loader/mozJSSubScriptLoader.cpp index ab9e4e0024c85..12399660ab66b 100644 --- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp +++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp @@ -136,8 +136,8 @@ mozJSSubScriptLoader::ReadScript(nsIURI *uri, JSContext *cx, JSObject *targetObj script.set(nullptr); function.set(nullptr); - // Instead of calling NS_OpenURI, we create the channel ourselves and call - // SetContentType, to avoid expensive MIME type lookups (bug 632490). + // We create a channel and call SetContentType, to avoid expensive MIME type + // lookups (bug 632490). nsCOMPtr chan; nsCOMPtr instream; nsresult rv; diff --git a/layout/style/Loader.cpp b/layout/style/Loader.cpp index 357f9d5ca5b3e..7dc0655ed31eb 100644 --- a/layout/style/Loader.cpp +++ b/layout/style/Loader.cpp @@ -1464,24 +1464,19 @@ Loader::LoadSheet(SheetLoadData* aLoadData, StyleSheetState aSheetState) } // Just load it - nsCOMPtr stream; nsCOMPtr channel; - // Note that we are calling NS_OpenURIInternal() with both a node and a - // principal. This is because of a case where the node is the document - // being styled and the principal is the stylesheet (perhaps from a - // different origin) that is applying the styles. + // Note that we are calling NS_NewChannelWithTriggeringPrincipal() with both + // a node and a principal. + // This is because of a case where the node is the document being styled and + // the principal is the stylesheet (perhaps from a different origin) that is + // applying the styles. if (aLoadData->mRequestingNode) { - rv = NS_OpenURIWithTriggeringPrincipal(getter_AddRefs(stream), - aLoadData->mURI, - aLoadData->mRequestingNode, - triggeringPrincipal, - nsILoadInfo::SEC_NORMAL, - nsIContentPolicy::TYPE_OTHER, - nullptr, // aLoadGroup - nullptr, // aCallbacks - nsIRequest::LOAD_NORMAL, - nullptr, // aIoService - getter_AddRefs(channel)); + rv = NS_NewChannelWithTriggeringPrincipal(getter_AddRefs(channel), + aLoadData->mURI, + aLoadData->mRequestingNode, + triggeringPrincipal, + nsILoadInfo::SEC_NORMAL, + nsIContentPolicy::TYPE_OTHER); } else { // either we are loading something inside a document, in which case @@ -1489,17 +1484,16 @@ Loader::LoadSheet(SheetLoadData* aLoadData, StyleSheetState aSheetState) // outside a document, in which case the triggeringPrincipal // should always be the systemPrincipal. MOZ_ASSERT(nsContentUtils::IsSystemPrincipal(triggeringPrincipal)); - rv = NS_OpenURI(getter_AddRefs(stream), - aLoadData->mURI, - triggeringPrincipal, - nsILoadInfo::SEC_NORMAL, - nsIContentPolicy::TYPE_OTHER, - nullptr, // aLoadGroup - nullptr, // aCallbacks - nsIRequest::LOAD_NORMAL, - nullptr, // aIoService - getter_AddRefs(channel)); + rv = NS_NewChannel(getter_AddRefs(channel), + aLoadData->mURI, + triggeringPrincipal, + nsILoadInfo::SEC_NORMAL, + nsIContentPolicy::TYPE_OTHER); } + NS_ENSURE_SUCCESS(rv, rv); + + nsCOMPtr stream; + rv = channel->Open(getter_AddRefs(stream)); if (NS_FAILED(rv)) { LOG_ERROR((" Failed to open URI synchronously")); @@ -1507,15 +1501,13 @@ Loader::LoadSheet(SheetLoadData* aLoadData, StyleSheetState aSheetState) return rv; } - NS_ASSERTION(channel, "NS_OpenURI lied?"); - // Force UA sheets to be UTF-8. // XXX this is only necessary because the default in // SheetLoadData::OnDetermineCharset is wrong (bug 521039). channel->SetContentCharset(NS_LITERAL_CSTRING("UTF-8")); - // Manually feed the streamloader the contents of the stream we - // got from NS_OpenURI. This will call back into OnStreamComplete + // Manually feed the streamloader the contents of the stream. + // This will call back into OnStreamComplete // and thence to ParseSheet. Regardless of whether this fails, // SheetComplete has been called. return nsSyncLoadService::PushSyncStreamToListener(stream, diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index 5f82a14e7db50..67f5b2262d795 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -862,6 +862,8 @@ nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx) mListenerContext = ctx; mIsPending = true; + nsCOMPtr channel; + if (!mJarFile) { // Not a local file... // kick off an async download of the base URI... @@ -869,26 +871,32 @@ nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx) if (NS_SUCCEEDED(rv)) { // Since we might not have a loadinfo on all channels yet // we have to provide default arguments in case mLoadInfo is null; + uint32_t loadFlags = + mLoadFlags & ~(LOAD_DOCUMENT_URI | LOAD_CALL_CONTENT_SNIFFERS); if (mLoadInfo) { - rv = NS_OpenURIInternal(mDownloader, - nullptr, // aContext - mJarBaseURI, - mLoadInfo, - mLoadGroup, - mCallbacks, - mLoadFlags & ~(LOAD_DOCUMENT_URI | LOAD_CALL_CONTENT_SNIFFERS)); + rv = NS_NewChannelInternal(getter_AddRefs(channel), + mJarBaseURI, + mLoadInfo, + mLoadGroup, + mCallbacks, + loadFlags); + } else { + rv = NS_NewChannel(getter_AddRefs(channel), + mJarBaseURI, + nsContentUtils::GetSystemPrincipal(), + nsILoadInfo::SEC_NORMAL, + nsIContentPolicy::TYPE_OTHER, + mLoadGroup, + mCallbacks, + loadFlags); } - else { - rv = NS_OpenURI(mDownloader, - nullptr, // aContext - mJarBaseURI, - nsContentUtils::GetSystemPrincipal(), - nsILoadInfo::SEC_NORMAL, - nsIContentPolicy::TYPE_OTHER, - mLoadGroup, - mCallbacks, - mLoadFlags & ~(LOAD_DOCUMENT_URI | LOAD_CALL_CONTENT_SNIFFERS)); + if (NS_FAILED(rv)) { + mIsPending = false; + mListenerContext = nullptr; + mListener = nullptr; + return rv; } + channel->AsyncOpen(mDownloader, nullptr); } } else if (mOpeningRemote) { // nothing to do: already asked parent to open file. diff --git a/netwerk/base/public/nsNetUtil.h b/netwerk/base/public/nsNetUtil.h index eeb6b0bd4a141..5656cb5d2988f 100644 --- a/netwerk/base/public/nsNetUtil.h +++ b/netwerk/base/public/nsNetUtil.h @@ -189,7 +189,7 @@ NS_NewFileURI(nsIURI* *result, /* * How to create a new Channel, using NS_NewChannel, -* NS_NewChannelWithTriggeringPrincipal, NS_OpenURI, +* NS_NewChannelWithTriggeringPrincipal, * NS_NewInputStreamChannel, NS_NewChannelInternal * and it's variations: * @@ -449,189 +449,6 @@ NS_NewChannel(nsIChannel** outChannel, aIoService); } -// Use this function with CAUTION. It creates a stream that blocks when you -// Read() from it and blocking the UI thread is a bad idea. If you don't want -// to implement a full blown asynchronous consumer (via nsIStreamListener) look -// at nsIStreamLoader instead. -inline nsresult -NS_OpenURIInternal(nsIInputStream** outStream, - nsIURI* aUri, - nsINode* aLoadingNode, - nsIPrincipal* aLoadingPrincipal, - nsIPrincipal* aTriggeringPrincipal, - nsSecurityFlags aSecurityFlags, - nsContentPolicyType aContentPolicyType, - nsILoadGroup* aLoadGroup = nullptr, - nsIInterfaceRequestor* aCallbacks = nullptr, - nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, - nsIIOService* aIoService = nullptr, // pass in nsIIOService to optimize callers - nsIChannel** outChannel = nullptr) -{ - NS_ASSERTION(aLoadingPrincipal, "Can not create channel without a loading Principal!"); - - nsCOMPtr channel; - nsresult rv = NS_NewChannelInternal(getter_AddRefs(channel), - aUri, - aLoadingNode, - aLoadingPrincipal, - aTriggeringPrincipal, - aSecurityFlags, - aContentPolicyType, - aLoadGroup, - aCallbacks, - aLoadFlags, - aIoService); - - NS_ENSURE_SUCCESS(rv, rv); - nsIInputStream *stream; - rv = channel->Open(&stream); - NS_ENSURE_SUCCESS(rv, rv); - *outStream = stream; - if (outChannel) { - *outChannel = nullptr; - channel.swap(*outChannel); - } - return NS_OK; -} - -inline nsresult /* NS_OpenURIprincipal */ -NS_OpenURI(nsIInputStream** outStream, - nsIURI* aUri, - nsIPrincipal* aLoadingPrincipal, - nsSecurityFlags aSecurityFlags, - nsContentPolicyType aContentPolicyType, - nsILoadGroup* aLoadGroup = nullptr, - nsIInterfaceRequestor* aCallbacks = nullptr, - nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, - nsIIOService* aIoService = nullptr, - nsIChannel** outChannel = nullptr) -{ - return NS_OpenURIInternal(outStream, - aUri, - nullptr, // aLoadingNode - aLoadingPrincipal, - nullptr, // aTriggeringPrincipal - aSecurityFlags, - aContentPolicyType, - aLoadGroup, - aCallbacks, - aLoadFlags, - aIoService, - outChannel); -} - -inline nsresult /* NS_OpenURIWithTriggeringPrincipalAndNode */ -NS_OpenURIWithTriggeringPrincipal(nsIInputStream** outStream, - nsIURI* aUri, - nsINode* aLoadingNode, - nsIPrincipal* aTriggeringPrincipal, - nsSecurityFlags aSecurityFlags, - nsContentPolicyType aContentPolicyType, - nsILoadGroup* aLoadGroup = nullptr, - nsIInterfaceRequestor* aCallbacks = nullptr, - nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, - nsIIOService* aIoService = nullptr, - nsIChannel** outChannel = nullptr) -{ - MOZ_ASSERT(aLoadingNode); - NS_ASSERTION(aTriggeringPrincipal, "Can not open uri without a triggering Principal!"); - return NS_OpenURIInternal(outStream, - aUri, - aLoadingNode, - aLoadingNode->NodePrincipal(), - aTriggeringPrincipal, - aSecurityFlags, - aContentPolicyType, - aLoadGroup, - aCallbacks, - aLoadFlags, - aIoService, - outChannel); -} - -inline nsresult -NS_OpenURIInternal(nsIStreamListener* aListener, - nsISupports* aContext, - nsIURI* aUri, - nsILoadInfo* aLoadInfo, - nsILoadGroup* aLoadGroup = nullptr, - nsIInterfaceRequestor* aCallbacks = nullptr, - nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, - nsIIOService* aIoService = nullptr) -{ - nsCOMPtr channel; - nsresult rv = NS_NewChannelInternal(getter_AddRefs(channel), - aUri, - aLoadInfo, - aLoadGroup, - aCallbacks, - aLoadFlags, - aIoService); - NS_ENSURE_SUCCESS(rv, rv); - return channel->AsyncOpen(aListener, aContext); -} - -inline nsresult -NS_OpenURIInternal(nsIStreamListener* aListener, - nsISupports* aContext, - nsIURI* aUri, - nsINode* aLoadingNode, - nsIPrincipal* aLoadingPrincipal, - nsIPrincipal* aTriggeringPrincipal, - nsSecurityFlags aSecurityFlags, - nsContentPolicyType aContentPolicyType, - nsILoadGroup* aLoadGroup = nullptr, - nsIInterfaceRequestor* aCallbacks = nullptr, - nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, - nsIIOService* aIoService = nullptr) -{ - NS_ASSERTION(aLoadingPrincipal, "Can not create channel without a loading Principal!"); - - nsCOMPtr loadInfo = - new mozilla::LoadInfo(aLoadingPrincipal, - aTriggeringPrincipal, - aLoadingNode, - aSecurityFlags, - aContentPolicyType); - if (!loadInfo) { - return NS_ERROR_UNEXPECTED; - } - return NS_OpenURIInternal(aListener, - aContext, - aUri, - loadInfo, - aLoadGroup, - aCallbacks, - aLoadFlags, - aIoService); -} - -inline nsresult -NS_OpenURI(nsIStreamListener* aListener, - nsISupports* aContext, - nsIURI* aUri, - nsIPrincipal* aLoadingPrincipal, - nsSecurityFlags aSecurityFlags, - nsContentPolicyType aContentPolicyType, - nsILoadGroup* aLoadGroup = nullptr, - nsIInterfaceRequestor* aCallbacks = nullptr, - nsLoadFlags aLoadFlags = nsIRequest::LOAD_NORMAL, - nsIIOService* aIoService = nullptr) -{ - return NS_OpenURIInternal(aListener, - aContext, - aUri, - nullptr, // aLoadingNode - aLoadingPrincipal, - nullptr, // aTriggeringPrincipal - aSecurityFlags, - aContentPolicyType, - aLoadGroup, - aCallbacks, - aLoadFlags, - aIoService); -} - inline nsresult NS_MakeAbsoluteURI(nsACString &result, const nsACString &spec, @@ -1744,27 +1561,29 @@ NS_LoadPersistentPropertiesFromURI(nsIPersistentProperties** outResult, nsContentPolicyType aContentPolicyType, nsIIOService* aIoService = nullptr) { + nsCOMPtr channel; + nsresult rv = NS_NewChannel(getter_AddRefs(channel), + aUri, + aLoadingPrincipal, + nsILoadInfo::SEC_NORMAL, + aContentPolicyType, + nullptr, // aLoadGroup + nullptr, // aCallbacks + nsIRequest::LOAD_NORMAL, + aIoService); + NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr in; - nsresult rv = NS_OpenURI(getter_AddRefs(in), - aUri, - aLoadingPrincipal, - nsILoadInfo::SEC_NORMAL, - aContentPolicyType, - nullptr, // aLoadGroup - nullptr, // aCallbacks - nsIRequest::LOAD_NORMAL, //aLoadFlags - aIoService); - + rv = channel->Open(getter_AddRefs(in)); NS_ENSURE_SUCCESS(rv, rv); + nsCOMPtr properties = do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = properties->Load(in); - if (NS_SUCCEEDED(rv)) { - *outResult = nullptr; - properties.swap(*outResult); - } - return rv; + NS_ENSURE_SUCCESS(rv, rv); + + properties.swap(*outResult); + return NS_OK; } inline nsresult diff --git a/netwerk/test/TestOpen.cpp b/netwerk/test/TestOpen.cpp index e6b7437354dbb..9b404976c6f58 100644 --- a/netwerk/test/TestOpen.cpp +++ b/netwerk/test/TestOpen.cpp @@ -59,13 +59,16 @@ main(int argc, char **argv) rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal)); RETURN_IF_FAILED(rv, "Couldn't get system principal!"); - rv = NS_OpenURI(getter_AddRefs(stream), - uri, - systemPrincipal, - nsILoadInfo::SEC_NORMAL, - nsIContentPolicy::TYPE_OTHER); - - RETURN_IF_FAILED(rv, "NS_OpenURI"); + nsCOMPtr channel; + rv = NS_NewChannel(getter_AddRefs(channel), + uri, + systemPrincipal, + nsILoadInfo::SEC_NORMAL, + nsIContentPolicy::TYPE_OTHER); + RETURN_IF_FAILED(rv, "NS_NewChannel"); + + rv = channel->Open(getter_AddRefs(stream)); + RETURN_IF_FAILED(rv, "channel->Open()"); FILE* outfile = fopen(argv[2], "wb"); if (!outfile) { diff --git a/rdf/base/nsRDFXMLDataSource.cpp b/rdf/base/nsRDFXMLDataSource.cpp index d91eccab94fcd..d957a3039f5a1 100644 --- a/rdf/base/nsRDFXMLDataSource.cpp +++ b/rdf/base/nsRDFXMLDataSource.cpp @@ -955,16 +955,17 @@ RDFXMLDataSourceImpl::Refresh(bool aBlocking) } else { // Null LoadGroup ? - rv = NS_OpenURI(this, - nullptr, // aContext - mURL, - nsContentUtils::GetSystemPrincipal(), - nsILoadInfo::SEC_NORMAL, - nsIContentPolicy::TYPE_OTHER, - nullptr, // aLoadGroup - this); // aCallbacks - - if (NS_FAILED(rv)) return rv; + nsCOMPtr channel; + rv = NS_NewChannel(getter_AddRefs(channel), + mURL, + nsContentUtils::GetSystemPrincipal(), + nsILoadInfo::SEC_NORMAL, + nsIContentPolicy::TYPE_OTHER, + nullptr, // aLoadGroup + this); // aCallbacks + NS_ENSURE_SUCCESS(rv, rv); + rv = channel->AsyncOpen(this, nullptr); + NS_ENSURE_SUCCESS(rv, rv); // So we don't try to issue two asynchronous loads at once. mLoadState = eLoadState_Pending;