mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1038756: Callsites creating a channel in /netwerk/ [e10s parts] (r=mcmanus)
This commit is contained in:
parent
a1024eede2
commit
e27bd0e936
@ -10,6 +10,7 @@ include protocol PFTPChannel;
|
||||
include protocol PRtspChannel;
|
||||
include URIParams;
|
||||
include InputStreamParams;
|
||||
include PBackgroundSharedTypes;
|
||||
|
||||
using struct mozilla::void_t from "ipc/IPCMessageUtils.h";
|
||||
using RequestHeaderTuples from "mozilla/net/PHttpChannelParams.h";
|
||||
@ -49,6 +50,9 @@ struct HttpChannelOpenArgs
|
||||
nsCString appCacheClientID;
|
||||
bool allowSpdy;
|
||||
OptionalFileDescriptorSet fds;
|
||||
PrincipalInfo requestingPrincipalInfo;
|
||||
uint32_t securityFlags;
|
||||
uint32_t contentPolicyType;
|
||||
};
|
||||
|
||||
struct HttpChannelConnectArgs
|
||||
@ -68,10 +72,13 @@ union HttpChannelCreationArgs
|
||||
|
||||
struct FTPChannelOpenArgs
|
||||
{
|
||||
URIParams uri;
|
||||
uint64_t startPos;
|
||||
nsCString entityID;
|
||||
URIParams uri;
|
||||
uint64_t startPos;
|
||||
nsCString entityID;
|
||||
OptionalInputStreamParams uploadStream;
|
||||
PrincipalInfo requestingPrincipalInfo;
|
||||
uint32_t securityFlags;
|
||||
uint32_t contentPolicyType;
|
||||
};
|
||||
|
||||
struct FTPChannelConnectArgs
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "SerializedLoadContext.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
@ -143,6 +144,30 @@ FTPChannelChild::GetUploadStream(nsIInputStream** stream)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// helper function to assign loadInfo to openArgs
|
||||
void
|
||||
propagateLoadInfo(nsILoadInfo *aLoadInfo,
|
||||
FTPChannelOpenArgs& openArgs)
|
||||
{
|
||||
mozilla::ipc::PrincipalInfo principalInfo;
|
||||
|
||||
if (aLoadInfo) {
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(aLoadInfo->LoadingPrincipal(),
|
||||
&principalInfo);
|
||||
openArgs.requestingPrincipalInfo() = principalInfo;
|
||||
openArgs.securityFlags() = aLoadInfo->GetSecurityFlags();
|
||||
openArgs.contentPolicyType() = aLoadInfo->GetContentPolicyType();
|
||||
return;
|
||||
}
|
||||
|
||||
// use default values if no loadInfo is provided
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(),
|
||||
&principalInfo);
|
||||
openArgs.requestingPrincipalInfo() = principalInfo;
|
||||
openArgs.securityFlags() = nsILoadInfo::SEC_NORMAL;
|
||||
openArgs.contentPolicyType() = nsIContentPolicy::TYPE_OTHER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FTPChannelChild::AsyncOpen(::nsIStreamListener* listener, nsISupports* aContext)
|
||||
{
|
||||
@ -194,6 +219,10 @@ FTPChannelChild::AsyncOpen(::nsIStreamListener* listener, nsISupports* aContext)
|
||||
openArgs.entityID() = mEntityID;
|
||||
openArgs.uploadStream() = uploadStream;
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
propagateLoadInfo(loadInfo, openArgs);
|
||||
|
||||
gNeckoChild->
|
||||
SendPFTPChannelConstructor(this, tabChild, IPC::SerializedLoadContext(this),
|
||||
openArgs);
|
||||
|
@ -16,6 +16,8 @@
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "SerializedLoadContext.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
@ -78,7 +80,9 @@ FTPChannelParent::Init(const FTPChannelCreationArgs& aArgs)
|
||||
case FTPChannelCreationArgs::TFTPChannelOpenArgs:
|
||||
{
|
||||
const FTPChannelOpenArgs& a = aArgs.get_FTPChannelOpenArgs();
|
||||
return DoAsyncOpen(a.uri(), a.startPos(), a.entityID(), a.uploadStream());
|
||||
return DoAsyncOpen(a.uri(), a.startPos(), a.entityID(), a.uploadStream(),
|
||||
a.requestingPrincipalInfo(), a.securityFlags(),
|
||||
a.contentPolicyType());
|
||||
}
|
||||
case FTPChannelCreationArgs::TFTPChannelConnectArgs:
|
||||
{
|
||||
@ -95,7 +99,10 @@ bool
|
||||
FTPChannelParent::DoAsyncOpen(const URIParams& aURI,
|
||||
const uint64_t& aStartPos,
|
||||
const nsCString& aEntityID,
|
||||
const OptionalInputStreamParams& aUploadStream)
|
||||
const OptionalInputStreamParams& aUploadStream,
|
||||
const ipc::PrincipalInfo& aRequestingPrincipalInfo,
|
||||
const uint32_t& aSecurityFlags,
|
||||
const uint32_t& aContentPolicyType)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
||||
if (!uri)
|
||||
@ -113,8 +120,24 @@ FTPChannelParent::DoAsyncOpen(const URIParams& aURI,
|
||||
if (NS_FAILED(rv))
|
||||
return SendFailedAsyncOpen(rv);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> requestingPrincipal =
|
||||
mozilla::ipc::PrincipalInfoToPrincipal(aRequestingPrincipalInfo, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return SendFailedAsyncOpen(rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> chan;
|
||||
rv = NS_NewChannel(getter_AddRefs(chan), uri, ios);
|
||||
rv = NS_NewChannel(getter_AddRefs(chan),
|
||||
uri,
|
||||
requestingPrincipal,
|
||||
aSecurityFlags,
|
||||
aContentPolicyType,
|
||||
nullptr, // aChannelPolicy
|
||||
nullptr, // aLoadGroup
|
||||
nullptr, // aCallbacks
|
||||
nsIRequest::LOAD_NORMAL,
|
||||
ios);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return SendFailedAsyncOpen(rv);
|
||||
|
||||
|
@ -62,7 +62,10 @@ protected:
|
||||
|
||||
bool DoAsyncOpen(const URIParams& aURI, const uint64_t& aStartPos,
|
||||
const nsCString& aEntityID,
|
||||
const OptionalInputStreamParams& aUploadStream);
|
||||
const OptionalInputStreamParams& aUploadStream,
|
||||
const ipc::PrincipalInfo& aRequestingPrincipalInfo,
|
||||
const uint32_t& aSecurityFlags,
|
||||
const uint32_t& aContentPolicyType);
|
||||
|
||||
// used to connect redirected-to channel in parent with just created
|
||||
// ChildChannel. Used during HTTP->FTP redirects.
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ipc/InputStreamUtils.h"
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
#include "mozilla/net/ChannelDiverterChild.h"
|
||||
#include "mozilla/net/DNS.h"
|
||||
#include "SerializedLoadContext.h"
|
||||
@ -1144,6 +1145,30 @@ HttpChannelChild::Resume()
|
||||
// HttpChannelChild::nsIChannel
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// helper function to assign loadInfo to openArgs
|
||||
void
|
||||
propagateLoadInfo(nsILoadInfo *aLoadInfo,
|
||||
HttpChannelOpenArgs& openArgs)
|
||||
{
|
||||
mozilla::ipc::PrincipalInfo principalInfo;
|
||||
|
||||
if (aLoadInfo) {
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(aLoadInfo->LoadingPrincipal(),
|
||||
&principalInfo);
|
||||
openArgs.requestingPrincipalInfo() = principalInfo;
|
||||
openArgs.securityFlags() = aLoadInfo->GetSecurityFlags();
|
||||
openArgs.contentPolicyType() = aLoadInfo->GetContentPolicyType();
|
||||
return;
|
||||
}
|
||||
|
||||
// use default values if no loadInfo is provided
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(),
|
||||
&principalInfo);
|
||||
openArgs.requestingPrincipalInfo() = principalInfo;
|
||||
openArgs.securityFlags() = nsILoadInfo::SEC_NORMAL;
|
||||
openArgs.contentPolicyType() = nsIContentPolicy::TYPE_OTHER;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelChild::GetSecurityInfo(nsISupports **aSecurityInfo)
|
||||
{
|
||||
@ -1286,6 +1311,8 @@ HttpChannelChild::AsyncOpen(nsIStreamListener *listener, nsISupports *aContext)
|
||||
openArgs.appCacheClientID() = appCacheClientId;
|
||||
openArgs.allowSpdy() = mAllowSpdy;
|
||||
|
||||
propagateLoadInfo(mLoadInfo, openArgs);
|
||||
|
||||
// The socket transport in the chrome process now holds a logical ref to us
|
||||
// until OnStopRequest, or we do a redirect, or we hit an IPDL error.
|
||||
AddIPDLReference();
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "SerializedLoadContext.h"
|
||||
#include "nsIAuthInformation.h"
|
||||
#include "nsIAuthPromptCallback.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::ipc;
|
||||
@ -93,7 +95,9 @@ HttpChannelParent::Init(const HttpChannelCreationArgs& aArgs)
|
||||
a.redirectionLimit(), a.allowPipelining(), a.allowSTS(),
|
||||
a.forceAllowThirdPartyCookie(), a.resumeAt(),
|
||||
a.startPos(), a.entityID(), a.chooseApplicationCache(),
|
||||
a.appCacheClientID(), a.allowSpdy(), a.fds());
|
||||
a.appCacheClientID(), a.allowSpdy(), a.fds(),
|
||||
a.requestingPrincipalInfo(), a.securityFlags(),
|
||||
a.contentPolicyType());
|
||||
}
|
||||
case HttpChannelCreationArgs::THttpChannelConnectArgs:
|
||||
{
|
||||
@ -176,7 +180,10 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
||||
const bool& chooseApplicationCache,
|
||||
const nsCString& appCacheClientID,
|
||||
const bool& allowSpdy,
|
||||
const OptionalFileDescriptorSet& aFds)
|
||||
const OptionalFileDescriptorSet& aFds,
|
||||
const ipc::PrincipalInfo& aRequestingPrincipalInfo,
|
||||
const uint32_t& aSecurityFlags,
|
||||
const uint32_t& aContentPolicyType)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
||||
if (!uri) {
|
||||
@ -200,8 +207,24 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
||||
if (NS_FAILED(rv))
|
||||
return SendFailedAsyncOpen(rv);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> requestingPrincipal =
|
||||
mozilla::ipc::PrincipalInfoToPrincipal(aRequestingPrincipalInfo, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return SendFailedAsyncOpen(rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = NS_NewChannel(getter_AddRefs(channel), uri, ios, nullptr, nullptr, loadFlags);
|
||||
rv = NS_NewChannel(getter_AddRefs(channel),
|
||||
uri,
|
||||
requestingPrincipal,
|
||||
aSecurityFlags,
|
||||
aContentPolicyType,
|
||||
nullptr, // aChannelPolicy
|
||||
nullptr, // loadGroup
|
||||
nullptr, // aCallbacks
|
||||
loadFlags,
|
||||
ios);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return SendFailedAsyncOpen(rv);
|
||||
|
||||
|
@ -96,7 +96,10 @@ protected:
|
||||
const bool& chooseApplicationCache,
|
||||
const nsCString& appCacheClientID,
|
||||
const bool& allowSpdy,
|
||||
const OptionalFileDescriptorSet& aFds);
|
||||
const OptionalFileDescriptorSet& aFds,
|
||||
const ipc::PrincipalInfo& aRequestingPrincipalInfo,
|
||||
const uint32_t& aSecurityFlags,
|
||||
const uint32_t& aContentPolicyType);
|
||||
|
||||
virtual bool RecvSetPriority(const uint16_t& priority) MOZ_OVERRIDE;
|
||||
virtual bool RecvSetCacheTokenCachedCharset(const nsCString& charset) MOZ_OVERRIDE;
|
||||
|
@ -5,7 +5,7 @@
|
||||
include protocol PNecko;
|
||||
include protocol PBrowser;
|
||||
include URIParams;
|
||||
|
||||
include PBackgroundSharedTypes;
|
||||
|
||||
using class IPC::SerializedLoadContext from "SerializedLoadContext.h";
|
||||
|
||||
@ -20,7 +20,10 @@ protocol PWyciwygChannel
|
||||
parent:
|
||||
__delete__();
|
||||
|
||||
Init(URIParams uri);
|
||||
Init(URIParams uri,
|
||||
PrincipalInfo requestingPrincipalInfo,
|
||||
uint32_t securityFlags,
|
||||
uint32_t contentPolicyType);
|
||||
AsyncOpen(URIParams originalURI,
|
||||
uint32_t loadFlags,
|
||||
SerializedLoadContext loadContext,
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "SerializedLoadContext.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
@ -80,7 +81,28 @@ WyciwygChannelChild::Init(nsIURI* uri)
|
||||
URIParams serializedUri;
|
||||
SerializeURI(uri, serializedUri);
|
||||
|
||||
SendInit(serializedUri);
|
||||
// propagate loadInfo
|
||||
mozilla::ipc::PrincipalInfo principalInfo;
|
||||
uint32_t securityFlags;
|
||||
uint32_t policyType;
|
||||
if (mLoadInfo) {
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(mLoadInfo->LoadingPrincipal(),
|
||||
&principalInfo);
|
||||
securityFlags = mLoadInfo->GetSecurityFlags();
|
||||
policyType = mLoadInfo->GetContentPolicyType();
|
||||
}
|
||||
else {
|
||||
// use default values if no loadInfo is provided
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(),
|
||||
&principalInfo);
|
||||
securityFlags = nsILoadInfo::SEC_NORMAL;
|
||||
policyType = nsIContentPolicy::TYPE_OTHER;
|
||||
}
|
||||
|
||||
SendInit(serializedUri,
|
||||
principalInfo,
|
||||
securityFlags,
|
||||
policyType);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,8 @@
|
||||
#include "mozilla/ipc/URIUtils.h"
|
||||
#include "mozilla/net/NeckoParent.h"
|
||||
#include "SerializedLoadContext.h"
|
||||
#include "nsIContentPolicy.h"
|
||||
#include "mozilla/ipc/BackgroundUtils.h"
|
||||
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
@ -58,7 +60,10 @@ NS_IMPL_ISUPPORTS(WyciwygChannelParent,
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool
|
||||
WyciwygChannelParent::RecvInit(const URIParams& aURI)
|
||||
WyciwygChannelParent::RecvInit(const URIParams& aURI,
|
||||
const ipc::PrincipalInfo& aRequestingPrincipalInfo,
|
||||
const uint32_t& aSecurityFlags,
|
||||
const uint32_t& aContentPolicyType)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -75,8 +80,24 @@ WyciwygChannelParent::RecvInit(const URIParams& aURI)
|
||||
if (NS_FAILED(rv))
|
||||
return SendCancelEarly(rv);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> requestingPrincipal =
|
||||
mozilla::ipc::PrincipalInfoToPrincipal(aRequestingPrincipalInfo, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return SendCancelEarly(rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> chan;
|
||||
rv = NS_NewChannel(getter_AddRefs(chan), uri, ios);
|
||||
rv = NS_NewChannel(getter_AddRefs(chan),
|
||||
uri,
|
||||
requestingPrincipal,
|
||||
aSecurityFlags,
|
||||
aContentPolicyType,
|
||||
nullptr, // aChannelPolicy
|
||||
nullptr, // loadGroup
|
||||
nullptr, // aCallbacks
|
||||
nsIRequest::LOAD_NORMAL,
|
||||
ios);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return SendCancelEarly(rv);
|
||||
|
||||
|
@ -35,7 +35,10 @@ public:
|
||||
protected:
|
||||
virtual ~WyciwygChannelParent();
|
||||
|
||||
virtual bool RecvInit(const URIParams& uri) MOZ_OVERRIDE;
|
||||
virtual bool RecvInit(const URIParams& uri,
|
||||
const ipc::PrincipalInfo& aRequestingPrincipalInfo,
|
||||
const uint32_t& aSecurityFlags,
|
||||
const uint32_t& aContentPolicyType) MOZ_OVERRIDE;
|
||||
virtual bool RecvAsyncOpen(const URIParams& original,
|
||||
const uint32_t& loadFlags,
|
||||
const IPC::SerializedLoadContext& loadContext,
|
||||
|
Loading…
Reference in New Issue
Block a user