mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1179505 - Make LoadInfo arguments optional in ipdl (r=bent,sicking)
This commit is contained in:
parent
809f712373
commit
1fe4e1e149
@ -18,6 +18,12 @@
|
||||
#include "nsString.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
class OptionalLoadInfoArgs;
|
||||
}
|
||||
|
||||
using namespace mozilla::net;
|
||||
|
||||
namespace ipc {
|
||||
|
||||
already_AddRefed<nsIPrincipal>
|
||||
@ -220,63 +226,67 @@ PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
||||
|
||||
nsresult
|
||||
LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
|
||||
mozilla::net::LoadInfoArgs* aLoadInfoArgs)
|
||||
OptionalLoadInfoArgs* aOptionalLoadInfoArgs)
|
||||
{
|
||||
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->upgradeInsecureRequests() = aLoadInfo->GetUpgradeInsecureRequests();
|
||||
aLoadInfoArgs->innerWindowID() = aLoadInfo->GetInnerWindowID();
|
||||
aLoadInfoArgs->outerWindowID() = aLoadInfo->GetOuterWindowID();
|
||||
aLoadInfoArgs->parentOuterWindowID() = aLoadInfo->GetParentOuterWindowID();
|
||||
if (!aLoadInfo) {
|
||||
// if there is no loadInfo, then there is nothing to serialize
|
||||
*aOptionalLoadInfoArgs = void_t();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// use default values if no loadInfo is provided
|
||||
rv = PrincipalToPrincipalInfo(nsContentUtils::GetSystemPrincipal(),
|
||||
&aLoadInfoArgs->requestingPrincipalInfo());
|
||||
nsresult rv = NS_OK;
|
||||
PrincipalInfo requestingPrincipalInfo;
|
||||
rv = PrincipalToPrincipalInfo(aLoadInfo->LoadingPrincipal(),
|
||||
&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->upgradeInsecureRequests() = false;
|
||||
aLoadInfoArgs->innerWindowID() = 0;
|
||||
aLoadInfoArgs->outerWindowID() = 0;
|
||||
aLoadInfoArgs->parentOuterWindowID() = 0;
|
||||
|
||||
PrincipalInfo triggeringPrincipalInfo;
|
||||
rv = PrincipalToPrincipalInfo(aLoadInfo->TriggeringPrincipal(),
|
||||
&triggeringPrincipalInfo);
|
||||
|
||||
*aOptionalLoadInfoArgs =
|
||||
LoadInfoArgs(
|
||||
requestingPrincipalInfo,
|
||||
triggeringPrincipalInfo,
|
||||
aLoadInfo->GetSecurityFlags(),
|
||||
aLoadInfo->GetContentPolicyType(),
|
||||
aLoadInfo->GetUpgradeInsecureRequests(),
|
||||
aLoadInfo->GetInnerWindowID(),
|
||||
aLoadInfo->GetOuterWindowID(),
|
||||
aLoadInfo->GetParentOuterWindowID());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
|
||||
LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo)
|
||||
{
|
||||
if (aOptionalLoadInfoArgs.type() == OptionalLoadInfoArgs::Tvoid_t) {
|
||||
*outLoadInfo = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
const LoadInfoArgs& loadInfoArgs =
|
||||
aOptionalLoadInfoArgs.get_LoadInfoArgs();
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIPrincipal> requestingPrincipal =
|
||||
PrincipalInfoToPrincipal(aLoadInfoArgs.requestingPrincipalInfo(), &rv);
|
||||
PrincipalInfoToPrincipal(loadInfoArgs.requestingPrincipalInfo(), &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCOMPtr<nsIPrincipal> triggeringPrincipal =
|
||||
PrincipalInfoToPrincipal(aLoadInfoArgs.triggeringPrincipalInfo(), &rv);
|
||||
PrincipalInfoToPrincipal(loadInfoArgs.triggeringPrincipalInfo(), &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsILoadInfo> loadInfo =
|
||||
new mozilla::LoadInfo(requestingPrincipal,
|
||||
triggeringPrincipal,
|
||||
aLoadInfoArgs.securityFlags(),
|
||||
aLoadInfoArgs.contentPolicyType(),
|
||||
aLoadInfoArgs.upgradeInsecureRequests(),
|
||||
aLoadInfoArgs.innerWindowID(),
|
||||
aLoadInfoArgs.outerWindowID(),
|
||||
aLoadInfoArgs.parentOuterWindowID());
|
||||
loadInfoArgs.securityFlags(),
|
||||
loadInfoArgs.contentPolicyType(),
|
||||
loadInfoArgs.upgradeInsecureRequests(),
|
||||
loadInfoArgs.innerWindowID(),
|
||||
loadInfoArgs.outerWindowID(),
|
||||
loadInfoArgs.parentOuterWindowID());
|
||||
|
||||
loadInfo.forget(outLoadInfo);
|
||||
return NS_OK;
|
||||
|
@ -40,9 +40,11 @@ struct ParamTraits<mozilla::OriginAttributes>
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
class LoadInfoArgs;
|
||||
class OptionalLoadInfoArgs;
|
||||
} // namespace net
|
||||
|
||||
using namespace mozilla::net;
|
||||
|
||||
namespace ipc {
|
||||
|
||||
class PrincipalInfo;
|
||||
@ -70,17 +72,15 @@ PrincipalToPrincipalInfo(nsIPrincipal* aPrincipal,
|
||||
*/
|
||||
nsresult
|
||||
LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
|
||||
mozilla::net::LoadInfoArgs* outLoadInfoArgs);
|
||||
OptionalLoadInfoArgs* outOptionalLoadInfoArgs);
|
||||
|
||||
/**
|
||||
* Convert LoadInfoArgs to a LoadInfo.
|
||||
*/
|
||||
nsresult
|
||||
LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
|
||||
LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo);
|
||||
|
||||
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -18,13 +18,13 @@ class nsINode;
|
||||
namespace mozilla {
|
||||
|
||||
namespace net {
|
||||
class LoadInfoArgs;
|
||||
class OptionalLoadInfoArgs;
|
||||
} // namespace net
|
||||
|
||||
namespace ipc {
|
||||
// we have to forward declare that function so we can use it as a friend.
|
||||
nsresult
|
||||
LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
|
||||
LoadInfoArgsToLoadInfo(const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo);
|
||||
} // namespace ipc
|
||||
|
||||
@ -64,7 +64,8 @@ private:
|
||||
uint64_t aParentOuterWindowID);
|
||||
|
||||
friend nsresult
|
||||
mozilla::ipc::LoadInfoArgsToLoadInfo(const mozilla::net::LoadInfoArgs& aLoadInfoArgs,
|
||||
mozilla::ipc::LoadInfoArgsToLoadInfo(
|
||||
const mozilla::net::OptionalLoadInfoArgs& aLoadInfoArgs,
|
||||
nsILoadInfo** outLoadInfo);
|
||||
|
||||
~LoadInfo();
|
||||
|
@ -36,6 +36,15 @@ struct LoadInfoArgs
|
||||
uint64_t parentOuterWindowID;
|
||||
};
|
||||
|
||||
/**
|
||||
* Not every channel necessarily has a loadInfo attached.
|
||||
*/
|
||||
union OptionalLoadInfoArgs
|
||||
{
|
||||
void_t;
|
||||
LoadInfoArgs;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// HTTP IPDL structs
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -77,7 +86,7 @@ struct HttpChannelOpenArgs
|
||||
bool allowSpdy;
|
||||
bool allowAltSvc;
|
||||
OptionalFileDescriptorSet fds;
|
||||
LoadInfoArgs loadInfo;
|
||||
OptionalLoadInfoArgs loadInfo;
|
||||
OptionalHttpResponseHead synthesizedResponseHead;
|
||||
uint32_t cacheKey;
|
||||
};
|
||||
@ -104,7 +113,7 @@ struct FTPChannelOpenArgs
|
||||
uint64_t startPos;
|
||||
nsCString entityID;
|
||||
OptionalInputStreamParams uploadStream;
|
||||
LoadInfoArgs loadInfo;
|
||||
OptionalLoadInfoArgs loadInfo;
|
||||
};
|
||||
|
||||
struct FTPChannelConnectArgs
|
||||
|
@ -107,7 +107,7 @@ FTPChannelParent::DoAsyncOpen(const URIParams& aURI,
|
||||
const uint64_t& aStartPos,
|
||||
const nsCString& aEntityID,
|
||||
const OptionalInputStreamParams& aUploadStream,
|
||||
const LoadInfoArgs& aLoadInfoArgs)
|
||||
const OptionalLoadInfoArgs& aLoadInfoArgs)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri = DeserializeURI(aURI);
|
||||
if (!uri)
|
||||
|
@ -65,7 +65,7 @@ protected:
|
||||
bool DoAsyncOpen(const URIParams& aURI, const uint64_t& aStartPos,
|
||||
const nsCString& aEntityID,
|
||||
const OptionalInputStreamParams& aUploadStream,
|
||||
const LoadInfoArgs& aLoadInfoArgs);
|
||||
const OptionalLoadInfoArgs& aLoadInfoArgs);
|
||||
|
||||
// used to connect redirected-to channel in parent with just created
|
||||
// ChildChannel. Used during HTTP->FTP redirects.
|
||||
|
@ -274,7 +274,7 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
||||
const bool& allowSpdy,
|
||||
const bool& allowAltSvc,
|
||||
const OptionalFileDescriptorSet& aFds,
|
||||
const LoadInfoArgs& aLoadInfoArgs,
|
||||
const OptionalLoadInfoArgs& aLoadInfoArgs,
|
||||
const OptionalHttpResponseHead& aSynthesizedResponseHead,
|
||||
const uint32_t& aCacheKey)
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ protected:
|
||||
const bool& allowSpdy,
|
||||
const bool& allowAltSvc,
|
||||
const OptionalFileDescriptorSet& aFds,
|
||||
const LoadInfoArgs& aLoadInfoArgs,
|
||||
const OptionalLoadInfoArgs& aLoadInfoArgs,
|
||||
const OptionalHttpResponseHead& aSynthesizedResponseHead,
|
||||
const uint32_t& aCacheKey);
|
||||
|
||||
|
@ -33,7 +33,7 @@ parent:
|
||||
bool aClientSetPingInterval,
|
||||
uint32_t aPingTimeout,
|
||||
bool aClientSetPingTimeout,
|
||||
LoadInfoArgs aLoadInfoArgs);
|
||||
OptionalLoadInfoArgs aLoadInfoArgs);
|
||||
Close(uint16_t code, nsCString reason);
|
||||
SendMsg(nsCString aMsg);
|
||||
SendBinaryMsg(nsCString aMsg);
|
||||
|
@ -483,7 +483,7 @@ WebSocketChannelChild::AsyncOpen(nsIURI *aURI,
|
||||
// Corresponding release in DeallocPWebSocket
|
||||
AddIPDLReference();
|
||||
|
||||
LoadInfoArgs loadInfoArgs;
|
||||
OptionalLoadInfoArgs loadInfoArgs;
|
||||
nsresult rv = LoadInfoToLoadInfoArgs(mLoadInfo, &loadInfoArgs);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
@ -66,7 +66,7 @@ WebSocketChannelParent::RecvAsyncOpen(const URIParams& aURI,
|
||||
const bool& aClientSetPingInterval,
|
||||
const uint32_t& aPingTimeout,
|
||||
const bool& aClientSetPingTimeout,
|
||||
const LoadInfoArgs& aLoadInfoArgs)
|
||||
const OptionalLoadInfoArgs& aLoadInfoArgs)
|
||||
{
|
||||
LOG(("WebSocketChannelParent::RecvAsyncOpen() %p\n", this));
|
||||
|
||||
|
@ -46,7 +46,7 @@ class WebSocketChannelParent : public PWebSocketParent,
|
||||
const bool& aClientSetPingInterval,
|
||||
const uint32_t& aPingTimeout,
|
||||
const bool& aClientSetPingTimeout,
|
||||
const LoadInfoArgs& aLoadInfoArgs) override;
|
||||
const OptionalLoadInfoArgs& 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