mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1099296 - Attach LoadInfo to remaining callers of ioService and ProtocolHandlers - in netwerk/ (r=sworkman)
This commit is contained in:
parent
ab8bfd6650
commit
4981e1ea79
@ -90,6 +90,7 @@ nsBaseChannel::Redirect(nsIChannel *newChannel, uint32_t redirectFlags,
|
||||
newChannel->SetLoadGroup(mLoadGroup);
|
||||
newChannel->SetNotificationCallbacks(mCallbacks);
|
||||
newChannel->SetLoadFlags(mLoadFlags | LOAD_REPLACE);
|
||||
newChannel->SetLoadInfo(mLoadInfo);
|
||||
|
||||
// Try to preserve the privacy bit if it has been overridden
|
||||
if (mPrivateBrowsingOverriden) {
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsISystemProxySettings.h"
|
||||
#include "nsContentUtils.h"
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
#include "ipc/Nuwa.h"
|
||||
#endif
|
||||
@ -432,7 +433,15 @@ nsPACMan::StartLoading()
|
||||
// NOTE: This results in GetProxyForURI being called
|
||||
if (pacURI) {
|
||||
pacURI->GetSpec(mNormalPACURISpec);
|
||||
ios->NewChannelFromURI(pacURI, getter_AddRefs(channel));
|
||||
NS_NewChannel(getter_AddRefs(channel),
|
||||
pacURI,
|
||||
nsContentUtils::GetSystemPrincipal(),
|
||||
nsILoadInfo::SEC_NORMAL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
nullptr, // aLoadGroup
|
||||
nullptr, // aCallbacks
|
||||
nsIRequest::LOAD_NORMAL,
|
||||
ios);
|
||||
}
|
||||
else {
|
||||
LOG(("nsPACMan::StartLoading Failed pacspec uri conversion %s\n",
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIAsyncVerifyRedirectCallback.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@ -136,11 +137,15 @@ NS_IMETHODIMP
|
||||
nsURIChecker::Init(nsIURI *aURI)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIIOService> ios = do_GetIOService(&rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = ios->NewChannelFromURI(aURI, getter_AddRefs(mChannel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = NS_NewChannel(getter_AddRefs(mChannel),
|
||||
aURI,
|
||||
nullPrincipal,
|
||||
nsILoadInfo::SEC_NORMAL,
|
||||
nsIContentPolicy::TYPE_OTHER);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mAllowHead) {
|
||||
mAllowHead = false;
|
||||
|
@ -41,6 +41,8 @@
|
||||
#include "nsISocketTransportService.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsICacheSession.h"
|
||||
#include "nsILoadInfo.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
#include "NetStatistics.h"
|
||||
@ -2381,7 +2383,10 @@ CreateHTTPProxiedChannel(nsIChannel *channel, nsIProxyInfo *pi, nsIChannel **new
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
channel->GetURI(getter_AddRefs(uri));
|
||||
|
||||
return pph->NewProxiedChannel(uri, pi, 0, nullptr, newChannel);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
channel->GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
|
||||
return pph->NewProxiedChannel2(uri, pi, 0, nullptr, loadInfo, newChannel);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -944,7 +944,14 @@ HttpChannelChild::Redirect1Begin(const uint32_t& newChannelId,
|
||||
nsCOMPtr<nsIURI> uri = DeserializeURI(newUri);
|
||||
|
||||
nsCOMPtr<nsIChannel> newChannel;
|
||||
rv = ioService->NewChannelFromURI(uri, getter_AddRefs(newChannel));
|
||||
rv = NS_NewChannelInternal(getter_AddRefs(newChannel),
|
||||
uri,
|
||||
mLoadInfo,
|
||||
nullptr, // aLoadGroup
|
||||
nullptr, // aCallbacks
|
||||
nsIRequest::LOAD_NORMAL,
|
||||
ioService);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// Veto redirect. nsHttpChannel decides to cancel or continue.
|
||||
OnRedirectVerifyCallback(rv);
|
||||
|
@ -76,6 +76,7 @@
|
||||
#include "nsIHttpPushListener.h"
|
||||
#include "nsIX509Cert.h"
|
||||
#include "ScopedNSSTypes.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
|
||||
namespace mozilla { namespace net {
|
||||
|
||||
@ -1793,7 +1794,13 @@ nsHttpChannel::StartRedirectChannelToURI(nsIURI *upgradedURI, uint32_t flags)
|
||||
rv = gHttpHandler->GetIOService(getter_AddRefs(ioService));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = ioService->NewChannelFromURI(upgradedURI, getter_AddRefs(newChannel));
|
||||
rv = NS_NewChannelInternal(getter_AddRefs(newChannel),
|
||||
upgradedURI,
|
||||
mLoadInfo,
|
||||
nullptr, // aLoadGroup
|
||||
nullptr, // aCallbacks
|
||||
nsIRequest::LOAD_NORMAL,
|
||||
ioService);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = SetupReplacementChannel(upgradedURI, newChannel, true);
|
||||
@ -1897,8 +1904,9 @@ nsHttpChannel::AsyncDoReplaceWithProxy(nsIProxyInfo* pi)
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> newChannel;
|
||||
rv = gHttpHandler->NewProxiedChannel(mURI, pi, mProxyResolveFlags,
|
||||
mProxyURI, getter_AddRefs(newChannel));
|
||||
rv = gHttpHandler->NewProxiedChannel2(mURI, pi, mProxyResolveFlags,
|
||||
mProxyURI, mLoadInfo,
|
||||
getter_AddRefs(newChannel));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -2544,7 +2552,9 @@ nsHttpChannel::ProcessFallback(bool *waitingForRedirectCallback)
|
||||
|
||||
// Create a new channel to load the fallback entry.
|
||||
nsRefPtr<nsIChannel> newChannel;
|
||||
rv = gHttpHandler->NewChannel(mURI, getter_AddRefs(newChannel));
|
||||
rv = gHttpHandler->NewChannel2(mURI,
|
||||
mLoadInfo,
|
||||
getter_AddRefs(newChannel));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = SetupReplacementChannel(mURI, newChannel, true);
|
||||
@ -4426,8 +4436,14 @@ nsHttpChannel::ContinueProcessRedirectionAfterFallback(nsresult rv)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> newChannel;
|
||||
rv = ioService->NewChannelFromURI(mRedirectURI, getter_AddRefs(newChannel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_NewChannelInternal(getter_AddRefs(newChannel),
|
||||
mRedirectURI,
|
||||
mLoadInfo,
|
||||
nullptr, // aLoadGroup
|
||||
nullptr, // aCallbacks
|
||||
nsIRequest::LOAD_NORMAL,
|
||||
ioService);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = SetupReplacementChannel(mRedirectURI, newChannel, !rewriteToGET);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -6635,7 +6651,13 @@ nsHttpChannel::OnPush(const nsACString &url, Http2PushedStream *pushedStream)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIChannel> pushChannel;
|
||||
rv = ioService->NewChannelFromURI(pushResource, getter_AddRefs(pushChannel));
|
||||
rv = NS_NewChannelInternal(getter_AddRefs(pushChannel),
|
||||
pushResource,
|
||||
mLoadInfo,
|
||||
nullptr, // aLoadGroup
|
||||
nullptr, // aCallbacks
|
||||
nsIRequest::LOAD_NORMAL,
|
||||
ioService);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIHttpChannel> pushHttpChannel = do_QueryInterface(pushChannel);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsIHttpHeaderVisitor.h"
|
||||
#include "nsNullPrincipal.h"
|
||||
|
||||
NS_IMPL_ADDREF(nsViewSourceChannel)
|
||||
NS_IMPL_RELEASE(nsViewSourceChannel)
|
||||
@ -55,9 +56,24 @@ nsViewSourceChannel::Init(nsIURI* uri)
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
rv = pService->NewChannel(path, nullptr, nullptr, getter_AddRefs(mChannel));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
// This function is called from within nsViewSourceHandler::NewChannel2
|
||||
// and sets the right loadInfo right after returning from this function.
|
||||
// Until then we follow the principal of least privilege and use
|
||||
// nullPrincipal as the loadingPrincipal.
|
||||
nsCOMPtr<nsIPrincipal> nullPrincipal =
|
||||
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = pService->NewChannel2(path,
|
||||
nullptr, // aOriginCharset
|
||||
nullptr, // aCharSet
|
||||
nullptr, // aLoadingNode
|
||||
nullPrincipal,
|
||||
nullptr, // aTriggeringPrincipal
|
||||
nsILoadInfo::SEC_NORMAL,
|
||||
nsIContentPolicy::TYPE_OTHER,
|
||||
getter_AddRefs(mChannel));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mIsSrcdocChannel = false;
|
||||
|
||||
|
@ -3070,14 +3070,22 @@ WebSocketChannel::AsyncOpen(nsIURI *aURI,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = io2->NewChannelFromURIWithProxyFlags(
|
||||
rv = io2->NewChannelFromURIWithProxyFlags2(
|
||||
localURI,
|
||||
mURI,
|
||||
nsIProtocolProxyService::RESOLVE_PREFER_HTTPS_PROXY |
|
||||
nsIProtocolProxyService::RESOLVE_ALWAYS_TUNNEL,
|
||||
mLoadInfo->LoadingNode() ?
|
||||
mLoadInfo->LoadingNode()->AsDOMNode() : nullptr,
|
||||
mLoadInfo->LoadingPrincipal(),
|
||||
mLoadInfo->TriggeringPrincipal(),
|
||||
mLoadInfo->GetSecurityFlags(),
|
||||
mLoadInfo->GetContentPolicyType(),
|
||||
getter_AddRefs(localChannel));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Please note that we still call SetLoadInfo on the channel because
|
||||
// we want the same instance of the loadInfo to be set on the channel.
|
||||
rv = localChannel->SetLoadInfo(mLoadInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIComponentManager.h"
|
||||
@ -18,6 +17,9 @@
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsILoadInfo.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#define TEST_URL "resource:/res/test.properties"
|
||||
static NS_DEFINE_CID(kPersistentPropertiesCID, NS_IPERSISTENTPROPERTIES_CID);
|
||||
@ -39,11 +41,23 @@ main(int argc, char* argv[])
|
||||
|
||||
nsIInputStream* in = nullptr;
|
||||
|
||||
nsCOMPtr<nsIIOService> service(do_GetService(kIOServiceCID, &ret));
|
||||
nsCOMPtr<nsIScriptSecurityManager> secman =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &ret);
|
||||
if (NS_FAILED(ret)) return 1;
|
||||
nsCOMPtr<nsIPrincipal> systemPrincipal;
|
||||
ret = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
|
||||
if (NS_FAILED(ret)) return 1;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
ret = NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING(TEST_URL));
|
||||
if (NS_FAILED(ret)) return 1;
|
||||
|
||||
nsIChannel *channel = nullptr;
|
||||
ret = service->NewChannel(NS_LITERAL_CSTRING(TEST_URL), nullptr, nullptr, &channel);
|
||||
ret = NS_NewChannel(&channel,
|
||||
uri,
|
||||
systemPrincipal,
|
||||
nsILoadInfo::SEC_NORMAL,
|
||||
nsIContentPolicy::TYPE_OTHER);
|
||||
if (NS_FAILED(ret)) return 1;
|
||||
|
||||
ret = channel->Open(&in);
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "nspr.h"
|
||||
#include "nscore.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
@ -26,8 +25,6 @@
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsStringAPI.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
static bool gError = false;
|
||||
static int32_t gKeepRunning = 0;
|
||||
|
||||
@ -253,18 +250,25 @@ nsresult StartLoad(const char *aURISpec) {
|
||||
nsCOMPtr<nsISupports> contextSup = do_QueryInterface(context, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
nsCOMPtr<nsIIOService> serv = do_GetService(kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// create a uri
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewURI(getter_AddRefs(uri), aURISpec);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIScriptSecurityManager> secman =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIPrincipal> systemPrincipal;
|
||||
rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// create a channel
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = serv->NewChannelFromURI(uri, getter_AddRefs(channel));
|
||||
rv = NS_NewChannel(getter_AddRefs(channel),
|
||||
uri,
|
||||
systemPrincipal,
|
||||
nsILoadInfo::SEC_NORMAL,
|
||||
nsIContentPolicy::TYPE_OTHER);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
Consumer *consumer = new Consumer;
|
||||
|
@ -5,7 +5,6 @@
|
||||
|
||||
#include "nsIResProtocolHandler.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
@ -14,6 +13,9 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsILoadInfo.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
@ -51,13 +53,22 @@ TestOpenInputStream(const char* url)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIIOService> serv(do_GetService(kIOServiceCID, &rv));
|
||||
nsCOMPtr<nsIScriptSecurityManager> secman =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIPrincipal> systemPrincipal;
|
||||
rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewURI(getter_AddRefs(uri), url);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = serv->NewChannel(url,
|
||||
nullptr, // base uri
|
||||
getter_AddRefs(channel));
|
||||
rv = NS_NewChannel(getter_AddRefs(channel),
|
||||
uri,
|
||||
systemPrincipal,
|
||||
nsILoadInfo::SEC_NORMAL,
|
||||
nsIContentPolicy::TYPE_OTHER);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIInputStream> in;
|
||||
@ -180,13 +191,22 @@ TestAsyncRead(const char* url)
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIIOService> serv(do_GetService(kIOServiceCID, &rv));
|
||||
nsCOMPtr<nsIScriptSecurityManager> secman =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIPrincipal> systemPrincipal;
|
||||
rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewURI(getter_AddRefs(uri), url);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = serv->NewChannel(url,
|
||||
nullptr, // base uri
|
||||
getter_AddRefs(channel));
|
||||
rv = NS_NewChannel(getter_AddRefs(channel),
|
||||
uri,
|
||||
systemPrincipal,
|
||||
nsILoadInfo::SEC_NORMAL,
|
||||
nsIContentPolicy::TYPE_OTHER);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIStreamListener> listener = new Listener();
|
||||
|
@ -10,14 +10,11 @@
|
||||
#endif
|
||||
|
||||
#include "nsIComponentRegistrar.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsIUploadChannel.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
#include "prlog.h"
|
||||
#if defined(PR_LOGGING)
|
||||
//
|
||||
@ -129,15 +126,24 @@ main(int argc, char* argv[])
|
||||
nsDependentCString(fileName)); // XXX UTF-8
|
||||
if (NS_FAILED(rv)) return -1;
|
||||
|
||||
nsCOMPtr<nsIIOService> ioService(do_GetService(kIOServiceCID, &rv));
|
||||
|
||||
// create our url.
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = NS_NewURI(getter_AddRefs(uri), uriSpec);
|
||||
if (NS_FAILED(rv)) return -1;
|
||||
|
||||
nsCOMPtr<nsIScriptSecurityManager> secman =
|
||||
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return -1;
|
||||
nsCOMPtr<nsIPrincipal> systemPrincipal;
|
||||
rv = secman->GetSystemPrincipal(getter_AddRefs(systemPrincipal));
|
||||
if (NS_FAILED(rv)) return -1;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = ioService->NewChannelFromURI(uri, getter_AddRefs(channel));
|
||||
rv = NS_NewChannel(getter_AddRefs(channel),
|
||||
uri,
|
||||
systemPrincipal,
|
||||
nsILoadInfo::SEC_NORMAL,
|
||||
nsIContentPolicy::TYPE_OTHER);
|
||||
if (NS_FAILED(rv)) return -1;
|
||||
|
||||
// QI and set the upload stream
|
||||
|
Loading…
Reference in New Issue
Block a user