mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1175352 - Refactor LoadInfo arguments to be more self contained (r=bent)
This commit is contained in:
parent
7c76869c13
commit
49f2bed566
@ -7,6 +7,7 @@
|
||||
#include "MainThreadUtils.h"
|
||||
#include "mozilla/Assertions.h"
|
||||
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
||||
#include "mozilla/net/NeckoChannelParams.h"
|
||||
#include "nsPrincipal.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIURI.h"
|
||||
@ -216,5 +217,66 @@ PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
|
||||
mozilla::net::LoadInfoArgs* aLoadInfoArgs)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (aLoadInfo) {
|
||||
rv = PrincipalToPrincipalInfo(aLoadInfo->LoadingPrincipal(),
|
||||
&aLoadInfoArgs->requestingPrincipalInfo());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(),
|
||||
&aLoadInfoArgs->triggeringPrincipalInfo());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aLoadInfoArgs->securityFlags() = aLoadInfo->GetSecurityFlags();
|
||||
aLoadInfoArgs->contentPolicyType() = aLoadInfo->GetContentPolicyType();
|
||||
aLoadInfoArgs->innerWindowID() = aLoadInfo->GetInnerWindowID();
|
||||
aLoadInfoArgs->outerWindowID() = aLoadInfo->GetOuterWindowID();
|
||||
aLoadInfoArgs->parentOuterWindowID() = aLoadInfo->GetParentOuterWindowID();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// use default values if no loadInfo is provided
|
||||
rv = PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(),
|
||||
&aLoadInfoArgs->requestingPrincipalInfo());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(),
|
||||
&aLoadInfoArgs->triggeringPrincipalInfo());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
aLoadInfoArgs->securityFlags() = nsILoadInfo::SEC_NORMAL;
|
||||
aLoadInfoArgs->contentPolicyType() = nsIContentPolicy::TYPE_OTHER;
|
||||
aLoadInfoArgs->innerWindowID() = 0;
|
||||
aLoadInfoArgs->outerWindowID() = 0;
|
||||
aLoadInfoArgs->parentOuterWindowID() = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIPrincipal> requestingPrincipal =
|
||||
PrincipalInfoToPrincipal(aLoadInfoArgs.requestingPrincipalInfo(), &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal =
|
||||
PrincipalInfoToPrincipal(aLoadInfoArgs.triggeringPrincipalInfo(), &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new mozilla::LoadInfo(requestingPrincipal,
|
||||
triggeringPrincipal,
|
||||
aLoadInfoArgs.securityFlags(),
|
||||
aLoadInfoArgs.contentPolicyType(),
|
||||
aLoadInfoArgs.innerWindowID(),
|
||||
aLoadInfoArgs.outerWindowID(),
|
||||
aLoadInfoArgs.parentOuterWindowID());
|
||||
|
||||
loadInfo.forget(outLoadInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
@ -38,6 +38,10 @@ struct ParamTraits<mozilla::OriginAttributes>
|
||||
} // IPC namespace
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
class LoadInfoArgs;
|
||||
}
|
||||
|
||||
namespace ipc {
|
||||
|
||||
class PrincipalInfo;
|
||||
@ -60,6 +64,22 @@ nsresult
|
||||
PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
||||
PrincipalInfo* aPrincipalInfo);
|
||||
|
||||
/**
|
||||
* Convert a LoadInfo to LoadInfoArgs struct.
|
||||
*/
|
||||
nsresult
|
||||
LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
|
||||
mozilla::net::LoadInfoArgs* outLoadInfoArgs);
|
||||
|
||||
/**
|
||||
* Convert LoadInfoArgs to a LoadInfo.
|
||||
*/
|
||||
nsresult
|
||||
LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo);
|
||||
|
||||
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -18,9 +18,14 @@ class nsINode;
|
||||
namespace mozilla {
|
||||
|
||||
namespace net {
|
||||
class HttpChannelParent;
|
||||
class FTPChannelParent;
|
||||
class WebSocketChannelParent;
|
||||
class LoadInfoArgs;
|
||||
}
|
||||
|
||||
namespace ipc {
|
||||
// we have to forward declare that function so we can use it as a friend.
|
||||
nsresult
|
||||
LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,9 +62,9 @@ private:
|
||||
uint64_t aOuterWindowID,
|
||||
uint64_t aParentOuterWindowID);
|
||||
|
||||
friend class net::HttpChannelParent;
|
||||
friend class net::FTPChannelParent;
|
||||
friend class net::WebSocketChannelParent;
|
||||
friend nsresult
|
||||
mozilla::ipc::LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo);
|
||||
|
||||
~LoadInfo();
|
||||
|
||||
|
@ -20,6 +20,21 @@ using class nsHttpResponseHead from "nsHttpResponseHead.h";
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LoadInfo IPDL structs
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct LoadInfoArgs
|
||||
{
|
||||
PrincipalInfo requestingPrincipalInfo;
|
||||
PrincipalInfo triggeringPrincipalInfo;
|
||||
uint32_t securityFlags;
|
||||
uint32_t contentPolicyType;
|
||||
uint64_t innerWindowID;
|
||||
uint64_t outerWindowID;
|
||||
uint64_t parentOuterWindowID;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HTTP IPDL structs
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -61,13 +76,7 @@ struct HttpChannelOpenArgs
|
||||
bool allowSpdy;
|
||||
bool allowAltSvc;
|
||||
OptionalFileDescriptorSet fds;
|
||||
PrincipalInfo requestingPrincipalInfo;
|
||||
PrincipalInfo triggeringPrincipalInfo;
|
||||
uint32_t securityFlags;
|
||||
uint32_t contentPolicyType;
|
||||
uint64_t innerWindowID;
|
||||
uint64_t outerWindowID;
|
||||
uint64_t parentOuterWindowID;
|
||||
LoadInfoArgs loadInfo;
|
||||
OptionalHttpResponseHead synthesizedResponseHead;
|
||||
uint32_t cacheKey;
|
||||
};
|
||||
@ -94,13 +103,7 @@ struct FTPChannelOpenArgs
|
||||
uint64_t startPos;
|
||||
nsCString entityID;
|
||||
OptionalInputStreamParams uploadStream;
|
||||
PrincipalInfo requestingPrincipalInfo;
|
||||
PrincipalInfo triggeringPrincipalInfo;
|
||||
uint32_t securityFlags;
|
||||
uint32_t contentPolicyType;
|
||||
uint64_t innerWindowID;
|
||||
uint64_t outerWindowID;
|
||||
uint64_t parentOuterWindowID;
|
||||
LoadInfoArgs loadInfo;
|
||||
};
|
||||
|
||||
struct FTPChannelConnectArgs
|
||||
@ -136,20 +139,5 @@ struct RtspChannelConnectArgs
|
||||
uint32_t channelId;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// WS IPDL structs
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
struct WebSocketLoadInfoArgs
|
||||
{
|
||||
PrincipalInfo requestingPrincipalInfo;
|
||||
PrincipalInfo triggeringPrincipalInfo;
|
||||
uint32_t securityFlags;
|
||||
uint32_t contentPolicyType;
|
||||
uint64_t innerWindowID;
|
||||
uint64_t outerWindowID;
|
||||
uint64_t parentOuterWindowID;
|
||||
};
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
@ -141,45 +141,6 @@ FTPChannelChild::GetUploadStream(nsIInputStream** stream)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// helper function to assign loadInfo to openArgs
|
||||
void
|
||||
propagateLoadInfo(nsILoadInfo *aLoadInfo,
|
||||
FTPChannelOpenArgs& openArgs)
|
||||
{
|
||||
mozilla::ipc::PrincipalInfo requestingPrincipalInfo;
|
||||
mozilla::ipc::PrincipalInfo triggeringPrincipalInfo;
|
||||
|
||||
if (aLoadInfo) {
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(aLoadInfo->LoadingPrincipal(),
|
||||
&requestingPrincipalInfo);
|
||||
openArgs.requestingPrincipalInfo() = requestingPrincipalInfo;
|
||||
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(),
|
||||
&triggeringPrincipalInfo);
|
||||
openArgs.triggeringPrincipalInfo() = triggeringPrincipalInfo;
|
||||
|
||||
openArgs.securityFlags() = aLoadInfo->GetSecurityFlags();
|
||||
openArgs.contentPolicyType() = aLoadInfo->GetContentPolicyType();
|
||||
openArgs.innerWindowID() = aLoadInfo->GetInnerWindowID();
|
||||
openArgs.outerWindowID() = aLoadInfo->GetOuterWindowID();
|
||||
openArgs.parentOuterWindowID() = aLoadInfo->GetParentOuterWindowID();
|
||||
return;
|
||||
}
|
||||
|
||||
// use default values if no loadInfo is provided
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(),
|
||||
&requestingPrincipalInfo);
|
||||
openArgs.requestingPrincipalInfo() = requestingPrincipalInfo;
|
||||
openArgs.triggeringPrincipalInfo() = requestingPrincipalInfo;
|
||||
openArgs.securityFlags() = nsILoadInfo::SEC_NORMAL;
|
||||
openArgs.contentPolicyType() = nsIContentPolicy::TYPE_OTHER;
|
||||
openArgs.innerWindowID() = 0;
|
||||
openArgs.outerWindowID() = 0;
|
||||
openArgs.parentOuterWindowID() = 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FTPChannelChild::AsyncOpen(::nsIStreamListener* listener, nsISupports* aContext)
|
||||
{
|
||||
@ -233,7 +194,8 @@ FTPChannelChild::AsyncOpen(::nsIStreamListener* listener, nsISupports* aContext)
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
GetLoadInfo(getter_AddRefs(loadInfo));
|
||||
propagateLoadInfo(loadInfo, openArgs);
|
||||
rv = mozilla::ipc::LoadInfoToLoadInfoArgs(loadInfo, &openArgs.loadInfo());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
gNeckoChild->
|
||||
SendPFTPChannelConstructor(this, tabChild, IPC::SerializedLoadContext(this),
|
||||
|
@ -88,9 +88,7 @@ FTPChannelParent::Init(const FTPChannelCreationArgs& aArgs)
|
||||
{
|
||||
const FTPChannelOpenArgs& a = aArgs.get_FTPChannelOpenArgs();
|
||||
return DoAsyncOpen(a.uri(), a.startPos(), a.entityID(), a.uploadStream(),
|
||||
a.requestingPrincipalInfo(), a.triggeringPrincipalInfo(),
|
||||
a.securityFlags(), a.contentPolicyType(),
|
||||
a.innerWindowID(), a.outerWindowID(), a.parentOuterWindowID());
|
||||
a.loadInfo());
|
||||
}
|
||||
case FTPChannelCreationArgs::TFTPChannelConnectArgs:
|
||||
{
|
||||
@ -108,13 +106,7 @@ FTPChannelParent::DoAsyncOpen(const URIParams& aURI,
|
||||
const uint64_t& aStartPos,
|
||||
const nsCString& aEntityID,
|
||||
const OptionalInputStreamParams& aUploadStream,
|
||||
const ipc::PrincipalInfo& aRequestingPrincipalInfo,
|
||||
const ipc::PrincipalInfo& aTriggeringPrincipalInfo,
|
||||
const uint32_t& aSecurityFlags,
|
||||
const uint32_t& aContentPolicyType,
|
||||
const uint64_t& aInnerWindowID,
|
||||
const uint64_t& aOuterWindowID,
|
||||
const uint64_t& aParentOuterWindowID)
|
||||
const LoadInfoArgs& aLoadInfoArgs)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
||||
if (!uri)
|
||||
@ -143,21 +135,12 @@ FTPChannelParent::DoAsyncOpen(const URIParams& aURI,
|
||||
if (NS_FAILED(rv))
|
||||
return SendFailedAsyncOpen(rv);
|
||||
|
||||
nsCOMPtr<nsIPrincipal> requestingPrincipal =
|
||||
mozilla::ipc::PrincipalInfoToPrincipal(aRequestingPrincipalInfo, &rv);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
rv = mozilla::ipc::LoadInfoArgsToLoadInfo(aLoadInfoArgs,
|
||||
getter_AddRefs(loadInfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return SendFailedAsyncOpen(rv);
|
||||
}
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal =
|
||||
mozilla::ipc::PrincipalInfoToPrincipal(aTriggeringPrincipalInfo, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return SendFailedAsyncOpen(rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new mozilla::LoadInfo(requestingPrincipal, triggeringPrincipal,
|
||||
aSecurityFlags, aContentPolicyType,
|
||||
aInnerWindowID, aOuterWindowID, aParentOuterWindowID);
|
||||
|
||||
nsCOMPtr<nsIChannel> chan;
|
||||
rv = NS_NewChannelInternal(getter_AddRefs(chan), uri, loadInfo,
|
||||
|
@ -64,13 +64,7 @@ protected:
|
||||
bool DoAsyncOpen(const URIParams& aURI, const uint64_t& aStartPos,
|
||||
const nsCString& aEntityID,
|
||||
const OptionalInputStreamParams& aUploadStream,
|
||||
const ipc::PrincipalInfo& aRequestingPrincipalInfo,
|
||||
const ipc::PrincipalInfo& aTriggeringPrincipalInfo,
|
||||
const uint32_t& aSecurityFlags,
|
||||
const uint32_t& aContentPolicyType,
|
||||
const uint64_t& aInnerWindowID,
|
||||
const uint64_t& aOuterWindowID,
|
||||
const uint64_t& aParentOuterWindowID);
|
||||
const LoadInfoArgs& aLoadInfoArgs);
|
||||
|
||||
// used to connect redirected-to channel in parent with just created
|
||||
// ChildChannel. Used during HTTP->FTP redirects.
|
||||
|
@ -1474,43 +1474,6 @@ HttpChannelChild::Resume()
|
||||
// HttpChannelChild::nsIChannel
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// helper function to assign loadInfo to openArgs
|
||||
void
|
||||
propagateLoadInfo(nsILoadInfo *aLoadInfo,
|
||||
HttpChannelOpenArgs& openArgs)
|
||||
{
|
||||
mozilla::ipc::PrincipalInfo requestingPrincipalInfo;
|
||||
mozilla::ipc::PrincipalInfo triggeringPrincipalInfo;
|
||||
|
||||
if (aLoadInfo) {
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(aLoadInfo->LoadingPrincipal(),
|
||||
&requestingPrincipalInfo);
|
||||
openArgs.requestingPrincipalInfo() = requestingPrincipalInfo;
|
||||
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(),
|
||||
&triggeringPrincipalInfo);
|
||||
openArgs.triggeringPrincipalInfo() = triggeringPrincipalInfo;
|
||||
|
||||
openArgs.securityFlags() = aLoadInfo->GetSecurityFlags();
|
||||
openArgs.contentPolicyType() = aLoadInfo->GetContentPolicyType();
|
||||
openArgs.innerWindowID() = aLoadInfo->GetInnerWindowID();
|
||||
openArgs.outerWindowID() = aLoadInfo->GetOuterWindowID();
|
||||
openArgs.parentOuterWindowID() = aLoadInfo->GetParentOuterWindowID();
|
||||
return;
|
||||
}
|
||||
|
||||
// use default values if no loadInfo is provided
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(),
|
||||
&requestingPrincipalInfo);
|
||||
openArgs.requestingPrincipalInfo() = requestingPrincipalInfo;
|
||||
openArgs.triggeringPrincipalInfo() = requestingPrincipalInfo;
|
||||
openArgs.securityFlags() = nsILoadInfo::SEC_NORMAL;
|
||||
openArgs.contentPolicyType() = nsIContentPolicy::TYPE_OTHER;
|
||||
openArgs.innerWindowID() = 0;
|
||||
openArgs.outerWindowID() = 0;
|
||||
openArgs.parentOuterWindowID() = 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpChannelChild::GetSecurityInfo(nsISupports **aSecurityInfo)
|
||||
{
|
||||
@ -1715,7 +1678,8 @@ HttpChannelChild::ContinueAsyncOpen()
|
||||
}
|
||||
openArgs.cacheKey() = cacheKey;
|
||||
|
||||
propagateLoadInfo(mLoadInfo, openArgs);
|
||||
nsresult rv = mozilla::ipc::LoadInfoToLoadInfoArgs(mLoadInfo, &openArgs.loadInfo());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// 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.
|
||||
|
@ -120,10 +120,7 @@ HttpChannelParent::Init(const HttpChannelCreationArgs& aArgs)
|
||||
a.thirdPartyFlags(), a.resumeAt(), a.startPos(),
|
||||
a.entityID(), a.chooseApplicationCache(),
|
||||
a.appCacheClientID(), a.allowSpdy(), a.allowAltSvc(), a.fds(),
|
||||
a.requestingPrincipalInfo(), a.triggeringPrincipalInfo(),
|
||||
a.securityFlags(), a.contentPolicyType(),
|
||||
a.innerWindowID(), a.outerWindowID(), a.parentOuterWindowID(),
|
||||
a.synthesizedResponseHead(), a.cacheKey());
|
||||
a.loadInfo(), a.synthesizedResponseHead(), a.cacheKey());
|
||||
}
|
||||
case HttpChannelCreationArgs::THttpChannelConnectArgs:
|
||||
{
|
||||
@ -277,13 +274,7 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
||||
const bool& allowSpdy,
|
||||
const bool& allowAltSvc,
|
||||
const OptionalFileDescriptorSet& aFds,
|
||||
const ipc::PrincipalInfo& aRequestingPrincipalInfo,
|
||||
const ipc::PrincipalInfo& aTriggeringPrincipalInfo,
|
||||
const uint32_t& aSecurityFlags,
|
||||
const uint32_t& aContentPolicyType,
|
||||
const uint64_t& aInnerWindowID,
|
||||
const uint64_t& aOuterWindowID,
|
||||
const uint64_t& aParentOuterWindowID,
|
||||
const LoadInfoArgs& aLoadInfoArgs,
|
||||
const OptionalHttpResponseHead& aSynthesizedResponseHead,
|
||||
const uint32_t& aCacheKey)
|
||||
{
|
||||
@ -310,17 +301,6 @@ 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<nsIPrincipal> triggeringPrincipal =
|
||||
mozilla::ipc::PrincipalInfoToPrincipal(aTriggeringPrincipalInfo, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return SendFailedAsyncOpen(rv);
|
||||
}
|
||||
|
||||
bool appOffline = false;
|
||||
uint32_t appId = GetAppId();
|
||||
if (appId != NECKO_UNKNOWN_APP_ID &&
|
||||
@ -335,10 +315,12 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
||||
loadFlags |= nsICachingChannel::LOAD_NO_NETWORK_IO;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new mozilla::LoadInfo(requestingPrincipal, triggeringPrincipal,
|
||||
aSecurityFlags, aContentPolicyType,
|
||||
aInnerWindowID, aOuterWindowID, aParentOuterWindowID);
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
rv = mozilla::ipc::LoadInfoArgsToLoadInfo(aLoadInfoArgs,
|
||||
getter_AddRefs(loadInfo));
|
||||
if (NS_FAILED(rv)) {
|
||||
return SendFailedAsyncOpen(rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = NS_NewChannelInternal(getter_AddRefs(channel), uri, loadInfo,
|
||||
|
@ -116,13 +116,7 @@ protected:
|
||||
const bool& allowSpdy,
|
||||
const bool& allowAltSvc,
|
||||
const OptionalFileDescriptorSet& aFds,
|
||||
const ipc::PrincipalInfo& aRequestingPrincipalInfo,
|
||||
const ipc::PrincipalInfo& aTriggeringPrincipalInfo,
|
||||
const uint32_t& aSecurityFlags,
|
||||
const uint32_t& aContentPolicyType,
|
||||
const uint64_t& aInnerWindowID,
|
||||
const uint64_t& aOuterWindowID,
|
||||
const uint64_t& aParentOuterWindowID,
|
||||
const LoadInfoArgs& aLoadInfoArgs,
|
||||
const OptionalHttpResponseHead& aSynthesizedResponseHead,
|
||||
const uint32_t& aCacheKey);
|
||||
|
||||
|
@ -33,7 +33,7 @@ parent:
|
||||
bool aClientSetPingInterval,
|
||||
uint32_t aPingTimeout,
|
||||
bool aClientSetPingTimeout,
|
||||
WebSocketLoadInfoArgs aLoadInfoArgs);
|
||||
LoadInfoArgs aLoadInfoArgs);
|
||||
Close(uint16_t code, nsCString reason);
|
||||
SendMsg(nsCString aMsg);
|
||||
SendBinaryMsg(nsCString aMsg);
|
||||
|
@ -453,27 +453,6 @@ WebSocketChannelChild::OnServerClose(const uint16_t& aCode,
|
||||
}
|
||||
}
|
||||
|
||||
// helper function to assign loadInfo to wsArgs
|
||||
void
|
||||
propagateLoadInfo(nsILoadInfo *aLoadInfo,
|
||||
WebSocketLoadInfoArgs& wsArgs)
|
||||
{
|
||||
mozilla::ipc::PrincipalInfo requestingPrincipalInfo;
|
||||
mozilla::ipc::PrincipalInfo triggeringPrincipalInfo;
|
||||
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(aLoadInfo->LoadingPrincipal(),
|
||||
&requestingPrincipalInfo);
|
||||
wsArgs.requestingPrincipalInfo() = requestingPrincipalInfo;
|
||||
mozilla::ipc::PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(),
|
||||
&triggeringPrincipalInfo);
|
||||
wsArgs.triggeringPrincipalInfo() = triggeringPrincipalInfo;
|
||||
wsArgs.securityFlags() = aLoadInfo->GetSecurityFlags();
|
||||
wsArgs.contentPolicyType() = aLoadInfo->GetContentPolicyType();
|
||||
wsArgs.innerWindowID() = aLoadInfo->GetInnerWindowID();
|
||||
wsArgs.outerWindowID() = aLoadInfo->GetOuterWindowID();
|
||||
wsArgs.parentOuterWindowID() = aLoadInfo->GetParentOuterWindowID();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebSocketChannelChild::AsyncOpen(nsIURI *aURI,
|
||||
const nsACString &aOrigin,
|
||||
@ -504,14 +483,15 @@ WebSocketChannelChild::AsyncOpen(nsIURI *aURI,
|
||||
// Corresponding release in DeallocPWebSocket
|
||||
AddIPDLReference();
|
||||
|
||||
WebSocketLoadInfoArgs wsArgs;
|
||||
propagateLoadInfo(mLoadInfo, wsArgs);
|
||||
LoadInfoArgs loadInfoArgs;
|
||||
nsresult rv = LoadInfoToLoadInfoArgs(mLoadInfo, &loadInfoArgs);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
gNeckoChild->SendPWebSocketConstructor(this, tabChild,
|
||||
IPC::SerializedLoadContext(this));
|
||||
if (!SendAsyncOpen(uri, nsCString(aOrigin), mProtocol, mEncrypted,
|
||||
mPingInterval, mClientSetPingInterval,
|
||||
mPingResponseTimeout, mClientSetPingTimeout, wsArgs)) {
|
||||
mPingResponseTimeout, mClientSetPingTimeout, loadInfoArgs)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
|
@ -66,13 +66,12 @@ WebSocketChannelParent::RecvAsyncOpen(const URIParams& aURI,
|
||||
const bool& aClientSetPingInterval,
|
||||
const uint32_t& aPingTimeout,
|
||||
const bool& aClientSetPingTimeout,
|
||||
const WebSocketLoadInfoArgs& aLoadInfoArgs)
|
||||
const LoadInfoArgs& aLoadInfoArgs)
|
||||
{
|
||||
LOG(("WebSocketChannelParent::RecvAsyncOpen() %p\n", this));
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsCOMPtr<nsIPrincipal> requestingPrincipal, triggeringPrincipal;
|
||||
nsCOMPtr<nsILoadInfo> loadInfo;
|
||||
|
||||
bool appOffline = false;
|
||||
@ -95,25 +94,10 @@ WebSocketChannelParent::RecvAsyncOpen(const URIParams& aURI,
|
||||
if (NS_FAILED(rv))
|
||||
goto fail;
|
||||
|
||||
requestingPrincipal =
|
||||
mozilla::ipc::PrincipalInfoToPrincipal(aLoadInfoArgs.requestingPrincipalInfo(), &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
rv = LoadInfoArgsToLoadInfo(aLoadInfoArgs, getter_AddRefs(loadInfo));
|
||||
if (NS_FAILED(rv))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
triggeringPrincipal =
|
||||
mozilla::ipc::PrincipalInfoToPrincipal(aLoadInfoArgs.triggeringPrincipalInfo(), &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
loadInfo = new LoadInfo(requestingPrincipal,
|
||||
triggeringPrincipal,
|
||||
aLoadInfoArgs.securityFlags(),
|
||||
aLoadInfoArgs.contentPolicyType(),
|
||||
aLoadInfoArgs.innerWindowID(),
|
||||
aLoadInfoArgs.outerWindowID(),
|
||||
aLoadInfoArgs.parentOuterWindowID());
|
||||
rv = mChannel->SetLoadInfo(loadInfo);
|
||||
if (NS_FAILED(rv)) {
|
||||
goto fail;
|
||||
|
@ -46,7 +46,7 @@ class WebSocketChannelParent : public PWebSocketParent,
|
||||
const bool& aClientSetPingInterval,
|
||||
const uint32_t& aPingTimeout,
|
||||
const bool& aClientSetPingTimeout,
|
||||
const WebSocketLoadInfoArgs& aLoadInfoArgs) override;
|
||||
const LoadInfoArgs& aLoadInfoArgs) override;
|
||||
bool RecvClose(const uint16_t & code, const nsCString & reason) override;
|
||||
bool RecvSendMsg(const nsCString& aMsg) override;
|
||||
bool RecvSendBinaryMsg(const nsCString& aMsg) override;
|
||||
|
Loading…
Reference in New Issue
Block a user