Bug 1231211 P3 Serialize LoadInfo's mClientInfo, mReservedClientInfo, and mReservedClientInfo members across IPC. r=valentin

This commit is contained in:
Ben Kelly 2018-01-23 10:38:52 -05:00
Родитель 8e535f8460
Коммит 9225189e3a
5 изменённых файлов: 79 добавлений и 0 удалений

Просмотреть файл

@ -34,6 +34,12 @@ struct IPCClientInfo
FrameType frameType;
};
union OptionalIPCClientInfo
{
IPCClientInfo;
void_t;
};
struct IPCClientWindowState
{
VisibilityState visibilityState;

Просмотреть файл

@ -368,6 +368,24 @@ LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
NS_ENSURE_SUCCESS(rv, rv);
}
OptionalIPCClientInfo ipcClientInfo = mozilla::void_t();
const Maybe<ClientInfo>& clientInfo = aLoadInfo->GetClientInfo();
if (clientInfo.isSome()) {
ipcClientInfo = clientInfo.ref().ToIPC();
}
OptionalIPCClientInfo ipcReservedClientInfo = mozilla::void_t();
const Maybe<ClientInfo>& reservedClientInfo = aLoadInfo->GetReservedClientInfo();
if (reservedClientInfo.isSome()) {
ipcReservedClientInfo = reservedClientInfo.ref().ToIPC();
}
OptionalIPCClientInfo ipcInitialClientInfo = mozilla::void_t();
const Maybe<ClientInfo>& initialClientInfo = aLoadInfo->GetInitialClientInfo();
if (initialClientInfo.isSome()) {
ipcInitialClientInfo = initialClientInfo.ref().ToIPC();
}
OptionalIPCServiceWorkerDescriptor ipcController = mozilla::void_t();
const Maybe<ServiceWorkerDescriptor>& controller = aLoadInfo->GetController();
if (controller.isSome()) {
@ -403,6 +421,9 @@ LoadInfoToLoadInfoArgs(nsILoadInfo *aLoadInfo,
redirectChain,
ancestorPrincipals,
aLoadInfo->AncestorOuterWindowIDs(),
ipcClientInfo,
ipcReservedClientInfo,
ipcInitialClientInfo,
ipcController,
aLoadInfo->CorsUnsafeHeaders(),
aLoadInfo->GetForcePreflight(),
@ -483,6 +504,29 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
ancestorPrincipals.AppendElement(ancestorPrincipal.forget());
}
Maybe<ClientInfo> clientInfo;
if (loadInfoArgs.clientInfo().type() != OptionalIPCClientInfo::Tvoid_t) {
clientInfo.emplace(ClientInfo(loadInfoArgs.clientInfo().get_IPCClientInfo()));
}
Maybe<ClientInfo> reservedClientInfo;
if (loadInfoArgs.reservedClientInfo().type() != OptionalIPCClientInfo::Tvoid_t) {
reservedClientInfo.emplace(
ClientInfo(loadInfoArgs.reservedClientInfo().get_IPCClientInfo()));
}
Maybe<ClientInfo> initialClientInfo;
if (loadInfoArgs.initialClientInfo().type() != OptionalIPCClientInfo::Tvoid_t) {
initialClientInfo.emplace(
ClientInfo(loadInfoArgs.initialClientInfo().get_IPCClientInfo()));
}
// We can have an initial client info or a reserved client info, but not both.
MOZ_DIAGNOSTIC_ASSERT(reservedClientInfo.isNothing() ||
initialClientInfo.isNothing());
NS_ENSURE_TRUE(reservedClientInfo.isNothing() ||
initialClientInfo.isNothing(), NS_ERROR_UNEXPECTED);
Maybe<ServiceWorkerDescriptor> controller;
if (loadInfoArgs.controller().type() != OptionalIPCServiceWorkerDescriptor::Tvoid_t) {
controller.emplace(ServiceWorkerDescriptor(
@ -495,6 +539,9 @@ LoadInfoArgsToLoadInfo(const OptionalLoadInfoArgs& aOptionalLoadInfoArgs,
principalToInherit,
sandboxedLoadingPrincipal,
resultPrincipalURI,
clientInfo,
reservedClientInfo,
initialClientInfo,
controller,
loadInfoArgs.securityFlags(),
loadInfoArgs.contentPolicyType(),

Просмотреть файл

@ -352,6 +352,9 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
nsIPrincipal* aPrincipalToInherit,
nsIPrincipal* aSandboxedLoadingPrincipal,
nsIURI* aResultPrincipalURI,
const Maybe<ClientInfo>& aClientInfo,
const Maybe<ClientInfo>& aReservedClientInfo,
const Maybe<ClientInfo>& aInitialClientInfo,
const Maybe<ServiceWorkerDescriptor>& aController,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,
@ -384,6 +387,9 @@ LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
, mTriggeringPrincipal(aTriggeringPrincipal)
, mPrincipalToInherit(aPrincipalToInherit)
, mResultPrincipalURI(aResultPrincipalURI)
, mClientInfo(aClientInfo)
, mReservedClientInfo(aReservedClientInfo)
, mInitialClientInfo(aInitialClientInfo)
, mController(aController)
, mSecurityFlags(aSecurityFlags)
, mInternalContentPolicyType(aContentPolicyType)

Просмотреть файл

@ -99,6 +99,9 @@ private:
nsIPrincipal* aPrincipalToInherit,
nsIPrincipal* aSandboxedLoadingPrincipal,
nsIURI* aResultPrincipalURI,
const Maybe<mozilla::dom::ClientInfo>& aClientInfo,
const Maybe<mozilla::dom::ClientInfo>& aReservedClientInfo,
const Maybe<mozilla::dom::ClientInfo>& aInitialClientInfo,
const Maybe<mozilla::dom::ServiceWorkerDescriptor>& aController,
nsSecurityFlags aSecurityFlags,
nsContentPolicyType aContentPolicyType,

Просмотреть файл

@ -9,6 +9,7 @@ include protocol PHttpChannel;
include protocol PFTPChannel;
include protocol PChildToParentStream;
include BlobTypes;
include ClientIPCTypes;
include URIParams;
include IPCServiceWorkerDescriptor;
include IPCStream;
@ -70,6 +71,22 @@ struct LoadInfoArgs
PrincipalInfo[] ancestorPrincipals;
uint64_t[] ancestorOuterWindowIDs;
/**
* ClientInfo structure representing the window or worker that triggered
* this network request. May be void_t if its a system internal request.
*/
OptionalIPCClientInfo clientInfo;
/**
* Non-subresource requests will result in the creation of a window or
* worker client. The reserved and initial ClientInfo values represent
* this resulting client. An initial ClientInfo represents an initial
* about:blank window that will be re-used while a reserved ClientInfo
* represents a to-be-newly-created window/worker.
*/
OptionalIPCClientInfo reservedClientInfo;
OptionalIPCClientInfo initialClientInfo;
/**
* Subresource loads may have a controller set based on their owning
* window/worker client. We must send this across IPC to support