Bug 1741493 - Split IPCInternalResponse r=nika

This commit replaces IPCInternalResponse with three different structs:
ParentToParentInternalResponse, ParentToChildInternalResponse, and
ChildToParentInternalResponse. Doing this lets us convert runtime
checks into compile-time type checks and simplifies relevant code.

Differential Revision: https://phabricator.services.mozilla.com/D131275
This commit is contained in:
Yaron Tausky 2021-11-19 16:45:19 +00:00
parent ea6b431cc4
commit 83bb5d45cd
29 changed files with 281 additions and 191 deletions

View File

@ -66,21 +66,39 @@ struct IPCInternalRequest {
PrincipalInfo? principalInfo;
};
struct IPCInternalResponse {
struct InternalResponseMetadata {
ResponseType type;
nsCString[] urlList;
uint16_t status;
nsCString statusText;
HeadersGuardEnum headersGuard;
HeadersEntry[] headers;
BodyStreamVariant? body;
int64_t bodySize;
nsresult errorCode;
nsCString alternativeDataType;
BodyStreamVariant? alternativeBody;
IPCChannelInfo channelInfo;
PrincipalInfo? principalInfo;
};
struct ParentToParentInternalResponse {
InternalResponseMetadata metadata;
ParentToParentStream? body;
int64_t bodySize;
ParentToParentStream? alternativeBody;
};
struct ParentToChildInternalResponse {
InternalResponseMetadata metadata;
ParentToChildStream? body;
int64_t bodySize;
ParentToChildStream? alternativeBody;
};
struct ChildToParentInternalResponse {
InternalResponseMetadata metadata;
ChildToParentStream? body;
int64_t bodySize;
ChildToParentStream? alternativeBody;
};
} // namespace ipc
} // namespace mozilla

View File

@ -27,9 +27,8 @@ namespace {
const uint32_t kMaxRandomNumber = 102400;
nsCOMPtr<nsIInputStream> TakeStreamFromStorage(
const BodyStreamVariant& aVariant, int64_t aBodySize) {
MOZ_ASSERT(aVariant.type() == BodyStreamVariant::TParentToParentStream);
const auto& uuid = aVariant.get_ParentToParentStream().uuid();
const ParentToParentStream& aStream, int64_t aBodySize) {
const auto& uuid = aStream.uuid();
auto storageOrErr = RemoteLazyInputStreamStorage::Get();
MOZ_ASSERT(storageOrErr.isOk());
@ -56,17 +55,20 @@ InternalResponse::InternalResponse(uint16_t aStatus,
mCloned(false) {}
/* static */ SafeRefPtr<InternalResponse> InternalResponse::FromIPC(
const IPCInternalResponse& aIPCResponse) {
if (aIPCResponse.type() == ResponseType::Error) {
return InternalResponse::NetworkError(aIPCResponse.errorCode());
const ParentToParentInternalResponse& aIPCResponse) {
MOZ_ASSERT(XRE_IsParentProcess());
if (aIPCResponse.metadata().type() == ResponseType::Error) {
return InternalResponse::NetworkError(aIPCResponse.metadata().errorCode());
}
SafeRefPtr<InternalResponse> response = MakeSafeRefPtr<InternalResponse>(
aIPCResponse.status(), aIPCResponse.statusText());
aIPCResponse.metadata().status(), aIPCResponse.metadata().statusText());
response->SetURLList(aIPCResponse.urlList());
response->SetURLList(aIPCResponse.metadata().urlList());
response->mHeaders =
new InternalHeaders(aIPCResponse.headers(), aIPCResponse.headersGuard());
new InternalHeaders(aIPCResponse.metadata().headers(),
aIPCResponse.metadata().headersGuard());
if (aIPCResponse.body()) {
auto bodySize = aIPCResponse.bodySize();
@ -75,7 +77,8 @@ InternalResponse::InternalResponse(uint16_t aStatus,
response->SetBody(body, bodySize);
}
response->SetAlternativeDataType(aIPCResponse.alternativeDataType());
response->SetAlternativeDataType(
aIPCResponse.metadata().alternativeDataType());
if (aIPCResponse.alternativeBody()) {
nsCOMPtr<nsIInputStream> alternativeBody = TakeStreamFromStorage(
@ -83,14 +86,14 @@ InternalResponse::InternalResponse(uint16_t aStatus,
response->SetAlternativeBody(alternativeBody);
}
response->InitChannelInfo(aIPCResponse.channelInfo());
response->InitChannelInfo(aIPCResponse.metadata().channelInfo());
if (aIPCResponse.principalInfo()) {
if (aIPCResponse.metadata().principalInfo()) {
response->SetPrincipalInfo(MakeUnique<mozilla::ipc::PrincipalInfo>(
aIPCResponse.principalInfo().ref()));
aIPCResponse.metadata().principalInfo().ref()));
}
switch (aIPCResponse.type()) {
switch (aIPCResponse.metadata().type()) {
case ResponseType::Basic:
response = response->BasicResponse();
break;
@ -114,10 +117,18 @@ InternalResponse::InternalResponse(uint16_t aStatus,
return response;
}
/* static */ SafeRefPtr<InternalResponse> InternalResponse::FromIPC(
const ParentToChildInternalResponse& aIPCResponse) {
MOZ_ASSERT(XRE_IsContentProcess());
MOZ_CRASH("Not implemented yet");
}
InternalResponse::~InternalResponse() = default;
void InternalResponse::ToIPC(
IPCInternalResponse* aIPCResponse, mozilla::ipc::PBackgroundChild* aManager,
ChildToParentInternalResponse* aIPCResponse,
mozilla::ipc::PBackgroundChild* aManager,
UniquePtr<mozilla::ipc::AutoIPCStream>& aAutoBodyStream,
UniquePtr<mozilla::ipc::AutoIPCStream>& aAutoAlternativeBodyStream) {
nsTArray<HeadersEntry> headers;
@ -129,12 +140,13 @@ void InternalResponse::ToIPC(
// Note: all the arguments are copied rather than moved, which would be more
// efficient, because there's no move-friendly constructor generated.
*aIPCResponse =
IPCInternalResponse(mType, GetUnfilteredURLList(), GetUnfilteredStatus(),
GetUnfilteredStatusText(), headersGuard, headers,
Nothing(), static_cast<uint64_t>(UNKNOWN_BODY_SIZE),
mErrorCode, GetAlternativeDataType(), Nothing(),
mChannelInfo.AsIPCChannelInfo(), principalInfo);
*aIPCResponse = ChildToParentInternalResponse(
InternalResponseMetadata(mType, GetUnfilteredURLList(),
GetUnfilteredStatus(), GetUnfilteredStatusText(),
headersGuard, headers, mErrorCode,
GetAlternativeDataType(),
mChannelInfo.AsIPCChannelInfo(), principalInfo),
Nothing(), UNKNOWN_BODY_SIZE, Nothing());
nsCOMPtr<nsIInputStream> body;
int64_t bodySize;
@ -144,8 +156,8 @@ void InternalResponse::ToIPC(
aIPCResponse->body().emplace(ChildToParentStream());
aIPCResponse->bodySize() = bodySize;
aAutoBodyStream.reset(new mozilla::ipc::AutoIPCStream(
aIPCResponse->body()->get_ChildToParentStream().stream()));
aAutoBodyStream.reset(
new mozilla::ipc::AutoIPCStream(aIPCResponse->body()->stream()));
DebugOnly<bool> ok = aAutoBodyStream->Serialize(body, aManager);
MOZ_ASSERT(ok);
}
@ -155,7 +167,7 @@ void InternalResponse::ToIPC(
aIPCResponse->alternativeBody().emplace(ChildToParentStream());
aAutoAlternativeBodyStream.reset(new mozilla::ipc::AutoIPCStream(
aIPCResponse->alternativeBody()->get_ChildToParentStream().stream()));
aIPCResponse->alternativeBody()->stream()));
DebugOnly<bool> ok =
aAutoAlternativeBodyStream->Serialize(alternativeBody, aManager);
MOZ_ASSERT(ok);

View File

@ -28,8 +28,10 @@ class PrincipalInfo;
namespace dom {
class IPCInternalResponse;
class ChildToParentInternalResponse;
class InternalHeaders;
class ParentToChildInternalResponse;
class ParentToParentInternalResponse;
class InternalResponse final : public AtomicSafeRefCounted<InternalResponse> {
friend class FetchDriver;
@ -42,11 +44,14 @@ class InternalResponse final : public AtomicSafeRefCounted<InternalResponse> {
RequestCredentials aCredentialsMode = RequestCredentials::Omit);
static SafeRefPtr<InternalResponse> FromIPC(
const IPCInternalResponse& aIPCResponse);
const ParentToChildInternalResponse& aIPCResponse);
// Note: the AutoIPCStreams must outlive the IPCInternalResponse.
static SafeRefPtr<InternalResponse> FromIPC(
const ParentToParentInternalResponse& aIPCResponse);
// Note: the AutoIPCStreams must outlive the ChildToParentInternalResponse.
void ToIPC(
IPCInternalResponse* aIPCResponse,
ChildToParentInternalResponse* aIPCResponse,
mozilla::ipc::PBackgroundChild* aManager,
UniquePtr<mozilla::ipc::AutoIPCStream>& aAutoBodyStream,
UniquePtr<mozilla::ipc::AutoIPCStream>& aAutoAlternativeBodyStream);
@ -368,8 +373,8 @@ class InternalResponse final : public AtomicSafeRefCounted<InternalResponse> {
bool mCloned;
public:
static const int64_t UNKNOWN_BODY_SIZE = -1;
static const int64_t UNKNOWN_PADDING_SIZE = -1;
static constexpr int64_t UNKNOWN_BODY_SIZE = -1;
static constexpr int64_t UNKNOWN_PADDING_SIZE = -1;
private:
ChannelInfo mChannelInfo;

View File

@ -181,7 +181,7 @@ NS_IMPL_ISUPPORTS(SynthesizeResponseWatcher, nsIInterceptedBodyCallback)
/* static */ RefPtr<GenericPromise> FetchEventOpChild::SendFetchEvent(
PRemoteWorkerControllerChild* aManager,
ServiceWorkerFetchEventOpArgs&& aArgs,
ParentToParentServiceWorkerFetchEventOpArgs&& aArgs,
nsCOMPtr<nsIInterceptedChannel> aInterceptedChannel,
RefPtr<ServiceWorkerRegistrationInfo> aRegistration,
RefPtr<FetchServiceResponsePromise>&& aPreloadResponseReadyPromise,
@ -209,7 +209,7 @@ FetchEventOpChild::~FetchEventOpChild() {
}
FetchEventOpChild::FetchEventOpChild(
ServiceWorkerFetchEventOpArgs&& aArgs,
ParentToParentServiceWorkerFetchEventOpArgs&& aArgs,
nsCOMPtr<nsIInterceptedChannel>&& aInterceptedChannel,
RefPtr<ServiceWorkerRegistrationInfo>&& aRegistration,
RefPtr<FetchServiceResponsePromise>&& aPreloadResponseReadyPromise,
@ -230,7 +230,7 @@ FetchEventOpChild::FetchEventOpChild(
GetCurrentSerialEventTarget(), __func__,
[this](SafeRefPtr<InternalResponse> aInternalResponse) {
// TODO: Serialize aInternalResponse into ipcPreloadResponse.
IPCInternalResponse ipcPreloadResponse;
ParentToParentInternalResponse ipcPreloadResponse;
if (!mWasSent) {
// The actor wasn't sent yet, we can still send the preload
// response with it.
@ -263,7 +263,7 @@ mozilla::ipc::IPCResult FetchEventOpChild::RecvAsyncLog(
}
mozilla::ipc::IPCResult FetchEventOpChild::RecvRespondWith(
IPCFetchEventRespondWithResult&& aResult) {
ParentToParentFetchEventRespondWithResult&& aResult) {
AssertIsOnMainThread();
// Preload response is too late to be ready after we receive RespondWith, so
@ -271,18 +271,20 @@ mozilla::ipc::IPCResult FetchEventOpChild::RecvRespondWith(
mPreloadResponseReadyPromiseRequestHolder.DisconnectIfExists();
switch (aResult.type()) {
case IPCFetchEventRespondWithResult::TIPCSynthesizeResponseArgs:
case ParentToParentFetchEventRespondWithResult::
TParentToParentSynthesizeResponseArgs:
mInterceptedChannel->SetFetchHandlerStart(
aResult.get_IPCSynthesizeResponseArgs()
aResult.get_ParentToParentSynthesizeResponseArgs()
.timeStamps()
.fetchHandlerStart());
mInterceptedChannel->SetFetchHandlerFinish(
aResult.get_IPCSynthesizeResponseArgs()
aResult.get_ParentToParentSynthesizeResponseArgs()
.timeStamps()
.fetchHandlerFinish());
SynthesizeResponse(std::move(aResult.get_IPCSynthesizeResponseArgs()));
SynthesizeResponse(
std::move(aResult.get_ParentToParentSynthesizeResponseArgs()));
break;
case IPCFetchEventRespondWithResult::TResetInterceptionArgs:
case ParentToParentFetchEventRespondWithResult::TResetInterceptionArgs:
mInterceptedChannel->SetFetchHandlerStart(
aResult.get_ResetInterceptionArgs().timeStamps().fetchHandlerStart());
mInterceptedChannel->SetFetchHandlerFinish(
@ -291,7 +293,7 @@ mozilla::ipc::IPCResult FetchEventOpChild::RecvRespondWith(
.fetchHandlerFinish());
ResetInterception(false);
break;
case IPCFetchEventRespondWithResult::TCancelInterceptionArgs:
case ParentToParentFetchEventRespondWithResult::TCancelInterceptionArgs:
mInterceptedChannel->SetFetchHandlerStart(
aResult.get_CancelInterceptionArgs()
.timeStamps()
@ -354,7 +356,7 @@ void FetchEventOpChild::ActorDestroy(ActorDestroyReason) {
}
nsresult FetchEventOpChild::StartSynthesizedResponse(
IPCSynthesizeResponseArgs&& aArgs) {
ParentToParentSynthesizeResponseArgs&& aArgs) {
AssertIsOnMainThread();
MOZ_ASSERT(mInterceptedChannel);
MOZ_ASSERT(!mInterceptedChannelHandled);
@ -380,7 +382,7 @@ nsresult FetchEventOpChild::StartSynthesizedResponse(
nsCOMPtr<nsILoadInfo> loadInfo = underlyingChannel->LoadInfo();
if (!CSPPermitsResponse(loadInfo, response.clonePtr(),
mArgs.workerScriptSpec())) {
mArgs.common().workerScriptSpec())) {
return NS_ERROR_CONTENT_BLOCKED;
}
@ -430,7 +432,7 @@ nsresult FetchEventOpChild::StartSynthesizedResponse(
// Propagate the URL to the content if the request mode is not "navigate".
// Note that, we only reflect the final URL if the response.redirected is
// false. We propagate all the URLs if the response.redirected is true.
const IPCInternalRequest& request = mArgs.internalRequest();
const IPCInternalRequest& request = mArgs.common().internalRequest();
nsAutoCString responseURL;
if (request.requestMode() != RequestMode::Navigate) {
responseURL = response->GetUnfilteredURL();
@ -463,8 +465,9 @@ nsresult FetchEventOpChild::StartSynthesizedResponse(
}
RefPtr<SynthesizeResponseWatcher> watcher = new SynthesizeResponseWatcher(
interceptedChannel, registration, mArgs.isNonSubresourceRequest(),
std::move(aArgs.closure()), NS_ConvertUTF8toUTF16(responseURL));
interceptedChannel, registration,
mArgs.common().isNonSubresourceRequest(), std::move(aArgs.closure()),
NS_ConvertUTF8toUTF16(responseURL));
rv = mInterceptedChannel->StartSynthesizedResponse(
body, watcher, nullptr /* TODO */, responseURL, response->IsRedirected());
@ -481,7 +484,8 @@ nsresult FetchEventOpChild::StartSynthesizedResponse(
return rv;
}
void FetchEventOpChild::SynthesizeResponse(IPCSynthesizeResponseArgs&& aArgs) {
void FetchEventOpChild::SynthesizeResponse(
ParentToParentSynthesizeResponseArgs&& aArgs) {
AssertIsOnMainThread();
MOZ_ASSERT(mInterceptedChannel);
MOZ_ASSERT(!mInterceptedChannelHandled);
@ -527,7 +531,7 @@ void FetchEventOpChild::CancelInterception(nsresult aStatus) {
// worker, which should be the case in non-shutdown/content-process-crash
// situations).
RefPtr<ServiceWorkerInfo> mActive = mRegistration->GetActive();
if (mActive && mArgs.isNonSubresourceRequest()) {
if (mActive && mArgs.common().isNonSubresourceRequest()) {
mActive->ReportNavigationFault();
// Additional mitigations such as unregistering the registration are handled
// in ServiceWorkerRegistrationInfo::MaybeScheduleUpdate which will be
@ -559,7 +563,7 @@ void FetchEventOpChild::MaybeScheduleRegistrationUpdate() const {
MOZ_ASSERT(mRegistration);
MOZ_ASSERT(mInterceptedChannelHandled);
if (mArgs.isNonSubresourceRequest()) {
if (mArgs.common().isNonSubresourceRequest()) {
mRegistration->MaybeScheduleUpdate();
} else {
mRegistration->MaybeScheduleTimeCheckAndUpdate();

View File

@ -33,7 +33,7 @@ class FetchEventOpChild final : public PFetchEventOpChild {
public:
static RefPtr<GenericPromise> SendFetchEvent(
PRemoteWorkerControllerChild* aManager,
ServiceWorkerFetchEventOpArgs&& aArgs,
ParentToParentServiceWorkerFetchEventOpArgs&& aArgs,
nsCOMPtr<nsIInterceptedChannel> aInterceptedChannel,
RefPtr<ServiceWorkerRegistrationInfo> aRegistrationInfo,
RefPtr<FetchServiceResponsePromise>&& aPreloadResponseReadyPromise,
@ -43,7 +43,7 @@ class FetchEventOpChild final : public PFetchEventOpChild {
private:
FetchEventOpChild(
ServiceWorkerFetchEventOpArgs&& aArgs,
ParentToParentServiceWorkerFetchEventOpArgs&& aArgs,
nsCOMPtr<nsIInterceptedChannel>&& aInterceptedChannel,
RefPtr<ServiceWorkerRegistrationInfo>&& aRegistrationInfo,
RefPtr<FetchServiceResponsePromise>&& aPreloadResponseReadyPromise,
@ -56,16 +56,17 @@ class FetchEventOpChild final : public PFetchEventOpChild {
nsTArray<nsString>&& aParams);
mozilla::ipc::IPCResult RecvRespondWith(
IPCFetchEventRespondWithResult&& aResult);
ParentToParentFetchEventRespondWithResult&& aResult);
mozilla::ipc::IPCResult Recv__delete__(
const ServiceWorkerFetchEventOpResult& aResult);
void ActorDestroy(ActorDestroyReason) override;
nsresult StartSynthesizedResponse(IPCSynthesizeResponseArgs&& aArgs);
nsresult StartSynthesizedResponse(
ParentToParentSynthesizeResponseArgs&& aArgs);
void SynthesizeResponse(IPCSynthesizeResponseArgs&& aArgs);
void SynthesizeResponse(ParentToParentSynthesizeResponseArgs&& aArgs);
void ResetInterception(bool aBypass);
@ -73,7 +74,7 @@ class FetchEventOpChild final : public PFetchEventOpChild {
void MaybeScheduleRegistrationUpdate() const;
ServiceWorkerFetchEventOpArgs mArgs;
ParentToParentServiceWorkerFetchEventOpArgs mArgs;
nsCOMPtr<nsIInterceptedChannel> mInterceptedChannel;
RefPtr<ServiceWorkerRegistrationInfo> mRegistration;
RefPtr<KeepAliveToken> mKeepAliveToken;

View File

@ -23,9 +23,9 @@ using namespace ipc;
namespace dom {
Maybe<IPCInternalResponse> FetchEventOpParent::OnStart(
Maybe<ParentToChildInternalResponse> FetchEventOpParent::OnStart(
MovingNotNull<RefPtr<FetchEventOpProxyParent>> aFetchEventOpProxyParent) {
Maybe<IPCInternalResponse> preloadResponse =
Maybe<ParentToChildInternalResponse> preloadResponse =
std::move(mState.as<Pending>().mPreloadResponse);
mState = AsVariant(Started{std::move(aFetchEventOpProxyParent)});
return preloadResponse;
@ -37,20 +37,20 @@ void FetchEventOpParent::OnFinish() {
}
mozilla::ipc::IPCResult FetchEventOpParent::RecvPreloadResponse(
IPCInternalResponse&& aResponse) {
ParentToParentInternalResponse&& aResponse) {
AssertIsOnBackgroundThread();
// TODO: preload response's body and alternativeBody need to be converted to
// ParentToChildStream. This would be done in the following patch.
ParentToChildInternalResponse internalResponse;
mState.match(
[&aResponse](Pending& aPending) {
[&internalResponse](Pending& aPending) {
MOZ_ASSERT(aPending.mPreloadResponse.isNothing());
aPending.mPreloadResponse = Some(std::move(aResponse));
aPending.mPreloadResponse = Some(std::move(internalResponse));
},
[&aResponse](Started& aStarted) {
[&internalResponse](Started& aStarted) {
Unused << aStarted.mFetchEventOpProxyParent->SendPreloadResponse(
aResponse);
internalResponse);
},
[](const Finished&) {});

View File

@ -25,7 +25,7 @@ class FetchEventOpParent final : public PFetchEventOpParent {
// Transition from the Pending state to the Started state. Returns the preload
// response, if it has already arrived.
Maybe<IPCInternalResponse> OnStart(
Maybe<ParentToChildInternalResponse> OnStart(
MovingNotNull<RefPtr<FetchEventOpProxyParent>> aFetchEventOpProxyParent);
// Transition from the Started state to the Finished state.
@ -36,12 +36,13 @@ class FetchEventOpParent final : public PFetchEventOpParent {
// IPDL methods
mozilla::ipc::IPCResult RecvPreloadResponse(IPCInternalResponse&& aResponse);
mozilla::ipc::IPCResult RecvPreloadResponse(
ParentToParentInternalResponse&& aResponse);
void ActorDestroy(ActorDestroyReason) override;
struct Pending {
Maybe<IPCInternalResponse> mPreloadResponse;
Maybe<ParentToChildInternalResponse> mPreloadResponse;
};
struct Started {

View File

@ -8,6 +8,7 @@
#include <utility>
#include "mozilla/dom/FetchTypes.h"
#include "mozilla/dom/ServiceWorkerOpPromise.h"
#include "nsCOMPtr.h"
#include "nsDebug.h"
@ -33,8 +34,8 @@ namespace dom {
namespace {
nsresult GetIPCSynthesizeResponseArgs(
IPCSynthesizeResponseArgs* aIPCArgs, SynthesizeResponseArgs&& aArgs,
UniquePtr<AutoIPCStream>& aAutoBodyStream,
ChildToParentSynthesizeResponseArgs* aIPCArgs,
SynthesizeResponseArgs&& aArgs, UniquePtr<AutoIPCStream>& aAutoBodyStream,
UniquePtr<AutoIPCStream>& aAutoAlternativeBodyStream) {
MOZ_ASSERT(RemoteWorkerService::Thread()->IsOnCurrentThread());
@ -60,13 +61,14 @@ nsresult GetIPCSynthesizeResponseArgs(
} // anonymous namespace
void FetchEventOpProxyChild::Initialize(
const ServiceWorkerFetchEventOpArgs& aArgs) {
const ParentToChildServiceWorkerFetchEventOpArgs& aArgs) {
MOZ_ASSERT(RemoteWorkerService::Thread()->IsOnCurrentThread());
MOZ_ASSERT(!mOp);
mInternalRequest = MakeSafeRefPtr<InternalRequest>(aArgs.internalRequest());
mInternalRequest =
MakeSafeRefPtr<InternalRequest>(aArgs.common().internalRequest());
if (aArgs.preloadNavigation()) {
if (aArgs.common().preloadNavigation()) {
// We use synchronous task dispatch here to make sure that if the preload
// response arrived before we dispatch the fetch event, then the JS preload
// response promise will get resolved immediately.
@ -124,7 +126,7 @@ void FetchEventOpProxyChild::Initialize(
auto& result = aResult.ResolveValue();
if (result.is<SynthesizeResponseArgs>()) {
IPCSynthesizeResponseArgs ipcArgs;
ChildToParentSynthesizeResponseArgs ipcArgs;
UniquePtr<AutoIPCStream> autoBodyStream =
MakeUnique<AutoIPCStream>();
UniquePtr<AutoIPCStream> autoAlternativeBodyStream =
@ -174,7 +176,7 @@ FetchEventOpProxyChild::GetPreloadResponsePromise() {
}
mozilla::ipc::IPCResult FetchEventOpProxyChild::RecvPreloadResponse(
IPCInternalResponse&& aResponse) {
ParentToChildInternalResponse&& aResponse) {
// Receiving this message implies that navigation preload is enabled, so
// Initialize() should have created this promise.
MOZ_ASSERT(mPreloadResponsePromise);

View File

@ -21,7 +21,7 @@ namespace dom {
class InternalRequest;
class InternalResponse;
class ServiceWorkerFetchEventOpArgs;
class ParentToChildServiceWorkerFetchEventOpArgs;
class FetchEventOpProxyChild final : public PFetchEventOpProxyChild {
friend class PFetchEventOpProxyChild;
@ -31,7 +31,7 @@ class FetchEventOpProxyChild final : public PFetchEventOpProxyChild {
FetchEventOpProxyChild() = default;
void Initialize(const ServiceWorkerFetchEventOpArgs& aArgs);
void Initialize(const ParentToChildServiceWorkerFetchEventOpArgs& aArgs);
// Must only be called once and on a worker thread.
SafeRefPtr<InternalRequest> ExtractInternalRequest();
@ -41,7 +41,8 @@ class FetchEventOpProxyChild final : public PFetchEventOpProxyChild {
private:
~FetchEventOpProxyChild() = default;
mozilla::ipc::IPCResult RecvPreloadResponse(IPCInternalResponse&& aResponse);
mozilla::ipc::IPCResult RecvPreloadResponse(
ParentToChildInternalResponse&& aResponse);
void ActorDestroy(ActorDestroyReason) override;

View File

@ -8,6 +8,8 @@
#include <utility>
#include "mozilla/dom/FetchTypes.h"
#include "mozilla/dom/ServiceWorkerOpArgs.h"
#include "nsCOMPtr.h"
#include "nsContentUtils.h"
#include "nsIInputStream.h"
@ -36,17 +38,17 @@ namespace dom {
namespace {
nsresult MaybeDeserializeAndWrapForMainThread(
const Maybe<BodyStreamVariant>& aSource, int64_t aBodyStreamSize,
Maybe<BodyStreamVariant>& aSink, PBackgroundParent* aManager) {
const Maybe<ChildToParentStream>& aSource, int64_t aBodyStreamSize,
Maybe<ParentToParentStream>& aSink, PBackgroundParent* aManager) {
if (aSource.isNothing()) {
return NS_OK;
}
nsCOMPtr<nsIInputStream> deserialized =
DeserializeIPCStream(aSource->get_ChildToParentStream().stream());
DeserializeIPCStream(aSource->stream());
aSink = Some(ParentToParentStream());
auto& uuid = aSink->get_ParentToParentStream().uuid();
auto& uuid = aSink->uuid();
MOZ_TRY(nsContentUtils::GenerateUUIDInPlace(uuid));
@ -61,19 +63,69 @@ nsresult MaybeDeserializeAndWrapForMainThread(
return NS_OK;
}
ParentToParentInternalResponse ToParentToParent(
const ChildToParentInternalResponse& aResponse,
NotNull<PBackgroundParent*> aBackgroundParent) {
ParentToParentInternalResponse parentToParentResponse(
aResponse.metadata(), Nothing(), aResponse.bodySize(), Nothing());
MOZ_ALWAYS_SUCCEEDS(MaybeDeserializeAndWrapForMainThread(
aResponse.body(), aResponse.bodySize(), parentToParentResponse.body(),
aBackgroundParent));
MOZ_ALWAYS_SUCCEEDS(MaybeDeserializeAndWrapForMainThread(
aResponse.alternativeBody(), InternalResponse::UNKNOWN_BODY_SIZE,
parentToParentResponse.alternativeBody(), aBackgroundParent));
return parentToParentResponse;
}
ParentToParentSynthesizeResponseArgs ToParentToParent(
const ChildToParentSynthesizeResponseArgs& aArgs,
NotNull<PBackgroundParent*> aBackgroundParent) {
return ParentToParentSynthesizeResponseArgs(
ToParentToParent(aArgs.internalResponse(), aBackgroundParent),
aArgs.closure(), aArgs.timeStamps());
}
ParentToParentFetchEventRespondWithResult ToParentToParent(
const ChildToParentFetchEventRespondWithResult& aResult,
NotNull<PBackgroundParent*> aBackgroundParent) {
switch (aResult.type()) {
case ChildToParentFetchEventRespondWithResult::
TChildToParentSynthesizeResponseArgs:
return ToParentToParent(aResult.get_ChildToParentSynthesizeResponseArgs(),
aBackgroundParent);
case ChildToParentFetchEventRespondWithResult::TResetInterceptionArgs:
return aResult.get_ResetInterceptionArgs();
case ChildToParentFetchEventRespondWithResult::TCancelInterceptionArgs:
return aResult.get_CancelInterceptionArgs();
default:
MOZ_CRASH("Invalid ParentToParentFetchEventRespondWithResult");
}
}
} // anonymous namespace
/* static */ void FetchEventOpProxyParent::Create(
PRemoteWorkerParent* aManager,
RefPtr<ServiceWorkerFetchEventOpPromise::Private>&& aPromise,
const ServiceWorkerFetchEventOpArgs& aArgs,
const ParentToParentServiceWorkerFetchEventOpArgs& aArgs,
RefPtr<FetchEventOpParent> aReal, nsCOMPtr<nsIInputStream> aBodyStream) {
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
MOZ_ASSERT(aManager);
MOZ_ASSERT(aReal);
ServiceWorkerFetchEventOpArgs copyArgs = aArgs;
ParentToChildServiceWorkerFetchEventOpArgs copyArgs(aArgs.common(),
Nothing());
if (aArgs.preloadResponse().isSome()) {
// Convert the preload response to ParentToChildInternalResponse.
// copyArgs.preloadResponse() =
// ToParentToChild(aArgs.preloadResponse().ref());
}
FetchEventOpProxyParent* actor =
new FetchEventOpProxyParent(std::move(aReal), std::move(aPromise));
@ -84,13 +136,13 @@ nsresult MaybeDeserializeAndWrapForMainThread(
// need to add it to the arguments. Note that we have to make sure that the
// arguments don't contain the preload response already, otherwise we'll end
// up overwriting it with a Nothing.
Maybe<IPCInternalResponse> preloadResponse =
Maybe<ParentToChildInternalResponse> preloadResponse =
actor->mReal->OnStart(WrapNotNull(actor));
if (copyArgs.preloadResponse().isNothing()) {
copyArgs.preloadResponse() = std::move(preloadResponse);
}
IPCInternalRequest& copyRequest = copyArgs.internalRequest();
IPCInternalRequest& copyRequest = copyArgs.common().internalRequest();
if (aBodyStream) {
PBackgroundParent* bgParent = aManager->Manager();
@ -132,47 +184,13 @@ mozilla::ipc::IPCResult FetchEventOpProxyParent::RecvAsyncLog(
}
mozilla::ipc::IPCResult FetchEventOpProxyParent::RecvRespondWith(
const IPCFetchEventRespondWithResult& aResult) {
const ChildToParentFetchEventRespondWithResult& aResult) {
AssertIsOnBackgroundThread();
MOZ_ASSERT(mReal);
// IPCSynthesizeResponseArgs possibly contains an IPCStream. If so,
// deserialize it and reserialize it before forwarding it to the main thread.
if (aResult.type() ==
IPCFetchEventRespondWithResult::TIPCSynthesizeResponseArgs) {
const IPCSynthesizeResponseArgs& originalArgs =
aResult.get_IPCSynthesizeResponseArgs();
const IPCInternalResponse& originalResponse =
originalArgs.internalResponse();
// Do nothing if neither the body nor the alt. body can be deserialized.
if (!originalResponse.body() && !originalResponse.alternativeBody()) {
Unused << mReal->SendRespondWith(aResult);
mReal->OnFinish();
return IPC_OK();
}
IPCSynthesizeResponseArgs copyArgs = originalArgs;
IPCInternalResponse& copyResponse = copyArgs.internalResponse();
PRemoteWorkerControllerParent* manager = mReal->Manager();
MOZ_ASSERT(manager);
PBackgroundParent* bgParent = manager->Manager();
MOZ_ASSERT(bgParent);
MOZ_ALWAYS_SUCCEEDS(MaybeDeserializeAndWrapForMainThread(
originalResponse.body(), copyResponse.bodySize(), copyResponse.body(),
bgParent));
MOZ_ALWAYS_SUCCEEDS(MaybeDeserializeAndWrapForMainThread(
originalResponse.alternativeBody(), InternalResponse::UNKNOWN_BODY_SIZE,
copyResponse.alternativeBody(), bgParent));
Unused << mReal->SendRespondWith(copyArgs);
} else {
Unused << mReal->SendRespondWith(aResult);
}
auto manager = WrapNotNull(mReal->Manager());
auto backgroundParent = WrapNotNull(manager->Manager());
Unused << mReal->SendRespondWith(ToParentToParent(aResult, backgroundParent));
mReal->OnFinish();
return IPC_OK();
}

View File

@ -16,7 +16,7 @@ namespace dom {
class FetchEventOpParent;
class PRemoteWorkerParent;
class ServiceWorkerFetchEventOpArgs;
class ParentToParentServiceWorkerFetchEventOpArgs;
/**
* FetchEventOpProxyParent owns a FetchEventOpParent in order to propagate
@ -36,7 +36,7 @@ class FetchEventOpProxyParent final : public PFetchEventOpProxyParent {
static void Create(
PRemoteWorkerParent* aManager,
RefPtr<ServiceWorkerFetchEventOpPromise::Private>&& aPromise,
const ServiceWorkerFetchEventOpArgs& aArgs,
const ParentToParentServiceWorkerFetchEventOpArgs& aArgs,
RefPtr<FetchEventOpParent> aReal, nsCOMPtr<nsIInputStream> aBodyStream);
private:
@ -53,7 +53,7 @@ class FetchEventOpProxyParent final : public PFetchEventOpProxyParent {
nsTArray<nsString>&& aParams);
mozilla::ipc::IPCResult RecvRespondWith(
const IPCFetchEventRespondWithResult& aResult);
const ChildToParentFetchEventRespondWithResult& aResult);
mozilla::ipc::IPCResult Recv__delete__(
const ServiceWorkerFetchEventOpResult& aResult);

View File

@ -14,14 +14,14 @@ protocol PFetchEventOp {
manager PRemoteWorkerController;
parent:
async PreloadResponse(IPCInternalResponse aResponse);
async PreloadResponse(ParentToParentInternalResponse aResponse);
child:
async AsyncLog(nsCString aScriptSpec, uint32_t aLineNumber,
uint32_t aColumnNumber, nsCString aMessageName,
nsString[] aParams);
async RespondWith(IPCFetchEventRespondWithResult aResult);
async RespondWith(ParentToParentFetchEventRespondWithResult aResult);
async __delete__(ServiceWorkerFetchEventOpResult aResult);
};

View File

@ -18,12 +18,12 @@ namespace dom {
uint32_t aColumnNumber, nsCString aMessageName,
nsString[] aParams);
async RespondWith(IPCFetchEventRespondWithResult aResult);
async RespondWith(ChildToParentFetchEventRespondWithResult aResult);
async __delete__(ServiceWorkerFetchEventOpResult aResult);
child:
async PreloadResponse(IPCInternalResponse aResponse);
async PreloadResponse(ParentToChildInternalResponse aResponse);
};
} // namespace dom

View File

@ -1328,7 +1328,10 @@ void FetchEventOp::AsyncLog(const nsCString& aScriptSpec, uint32_t aLineNumber,
void FetchEventOp::GetRequestURL(nsAString& aOutRequestURL) {
nsTArray<nsCString>& urls =
mArgs.get_ServiceWorkerFetchEventOpArgs().internalRequest().urlList();
mArgs.get_ParentToChildServiceWorkerFetchEventOpArgs()
.common()
.internalRequest()
.urlList();
MOZ_ASSERT(!urls.IsEmpty());
CopyUTF8toUTF16(urls.LastElement(), aOutRequestURL);
@ -1402,9 +1405,9 @@ void FetchEventOp::ResolvedCallback(JSContext* aCx,
return;
}
const ServiceWorkerFetchEventOpArgs& args =
mArgs.get_ServiceWorkerFetchEventOpArgs();
const RequestMode requestMode = args.internalRequest().requestMode();
const ParentToChildServiceWorkerFetchEventOpArgs& args =
mArgs.get_ParentToChildServiceWorkerFetchEventOpArgs();
const RequestMode requestMode = args.common().internalRequest().requestMode();
if (response->Type() == ResponseType::Opaque &&
requestMode != RequestMode::No_cors) {
@ -1420,7 +1423,7 @@ void FetchEventOp::ResolvedCallback(JSContext* aCx,
}
const RequestRedirect requestRedirectMode =
args.internalRequest().requestRedirect();
args.common().internalRequest().requestRedirect();
if (requestRedirectMode != RequestRedirect::Manual &&
response->Type() == ResponseType::Opaqueredirect) {
@ -1559,8 +1562,8 @@ nsresult FetchEventOp::DispatchFetchEvent(JSContext* aCx,
aWorkerPrivate->AssertIsOnWorkerThread();
MOZ_ASSERT(aWorkerPrivate->IsServiceWorker());
ServiceWorkerFetchEventOpArgs& args =
mArgs.get_ServiceWorkerFetchEventOpArgs();
ParentToChildServiceWorkerFetchEventOpArgs& args =
mArgs.get_ParentToChildServiceWorkerFetchEventOpArgs();
/**
* Testing: Failure injection.
@ -1583,8 +1586,8 @@ nsresult FetchEventOp::DispatchFetchEvent(JSContext* aCx,
* NS_ERROR_INTERCEPTION_FAILED, and by returning that here we approximate
* that failure mode.
*/
if (NS_FAILED(args.testingInjectCancellation())) {
return args.testingInjectCancellation();
if (NS_FAILED(args.common().testingInjectCancellation())) {
return args.common().testingInjectCancellation();
}
/**
@ -1631,8 +1634,9 @@ nsresult FetchEventOp::DispatchFetchEvent(JSContext* aCx,
* now. Once we implement .targetClientId we can then start exposing
* .clientId on non-subresource requests as well. See bug 1487534.
*/
if (!args.clientId().IsEmpty() && !internalRequest->IsNavigationRequest()) {
fetchEventInit.mClientId = args.clientId();
if (!args.common().clientId().IsEmpty() &&
!internalRequest->IsNavigationRequest()) {
fetchEventInit.mClientId = args.common().clientId();
}
/*
@ -1643,9 +1647,10 @@ nsresult FetchEventOp::DispatchFetchEvent(JSContext* aCx,
* to reservedClients [resultingClient's] id, and to the empty string
* otherwise." (Step 18.8)
*/
if (!args.resultingClientId().IsEmpty() && args.isNonSubresourceRequest() &&
if (!args.common().resultingClientId().IsEmpty() &&
args.common().isNonSubresourceRequest() &&
internalRequest->Destination() != RequestDestination::Report) {
fetchEventInit.mResultingClientId = args.resultingClientId();
fetchEventInit.mResultingClientId = args.common().resultingClientId();
}
/**
@ -1654,11 +1659,11 @@ nsresult FetchEventOp::DispatchFetchEvent(JSContext* aCx,
RefPtr<FetchEvent> fetchEvent =
FetchEvent::Constructor(globalObject, u"fetch"_ns, fetchEventInit);
fetchEvent->SetTrusted(true);
fetchEvent->PostInit(args.workerScriptSpec(), this);
fetchEvent->PostInit(args.common().workerScriptSpec(), this);
mHandled = fetchEvent->Handled();
mPreloadResponse = fetchEvent->PreloadResponse();
if (args.preloadNavigation()) {
if (args.common().preloadNavigation()) {
RefPtr<FetchEventPreloadResponsePromise> preloadResponsePromise =
mActor->GetPreloadResponsePromise();
MOZ_ASSERT(preloadResponsePromise);
@ -1805,7 +1810,7 @@ nsresult FetchEventOp::DispatchFetchEvent(JSContext* aCx,
case ServiceWorkerOpArgs::TServiceWorkerMessageEventOpArgs:
op = MakeRefPtr<MessageEventOp>(std::move(aArgs), std::move(aCallback));
break;
case ServiceWorkerOpArgs::TServiceWorkerFetchEventOpArgs:
case ServiceWorkerOpArgs::TParentToChildServiceWorkerFetchEventOpArgs:
op = MakeRefPtr<FetchEventOp>(std::move(aArgs), std::move(aCallback));
break;
default:

View File

@ -65,7 +65,7 @@ struct ServiceWorkerMessageEventOpArgs {
ClonedOrErrorMessageData clonedData;
};
struct ServiceWorkerFetchEventOpArgs {
struct ServiceWorkerFetchEventOpArgsCommon {
nsCString workerScriptSpec;
IPCInternalRequest internalRequest;
nsString clientId;
@ -75,10 +75,6 @@ struct ServiceWorkerFetchEventOpArgs {
// preloadResponse was not already provided in this structure, then it's
// expected that a PreloadResponse message will eventually be sent.
bool preloadNavigation;
// For the case the preload response is ready before fetch event is created,
// the preload response is sent with this parameter for initializing
// FetchEvent.preloadResponse.
IPCInternalResponse? preloadResponse;
// Failure injection helper; non-NS_OK values indicate that the event, instead
// of dispatching should instead return a `CancelInterceptionArgs` response
// with this nsresult. This value originates from
@ -86,6 +82,16 @@ struct ServiceWorkerFetchEventOpArgs {
nsresult testingInjectCancellation;
};
struct ParentToParentServiceWorkerFetchEventOpArgs {
ServiceWorkerFetchEventOpArgsCommon common;
ParentToParentInternalResponse? preloadResponse;
};
struct ParentToChildServiceWorkerFetchEventOpArgs {
ServiceWorkerFetchEventOpArgsCommon common;
ParentToChildInternalResponse? preloadResponse;
};
union ServiceWorkerOpArgs {
ServiceWorkerCheckScriptEvaluationOpArgs;
ServiceWorkerUpdateStateOpArgs;
@ -95,7 +101,7 @@ union ServiceWorkerOpArgs {
ServiceWorkerPushSubscriptionChangeEventOpArgs;
ServiceWorkerNotificationEventOpArgs;
ServiceWorkerMessageEventOpArgs;
ServiceWorkerFetchEventOpArgs;
ParentToChildServiceWorkerFetchEventOpArgs;
};
/**
@ -112,8 +118,14 @@ struct FetchEventTimeStamps {
TimeStamp fetchHandlerFinish;
};
struct IPCSynthesizeResponseArgs {
IPCInternalResponse internalResponse;
struct ChildToParentSynthesizeResponseArgs {
ChildToParentInternalResponse internalResponse;
FetchEventRespondWithClosure closure;
FetchEventTimeStamps timeStamps;
};
struct ParentToParentSynthesizeResponseArgs {
ParentToParentInternalResponse internalResponse;
FetchEventRespondWithClosure closure;
FetchEventTimeStamps timeStamps;
};
@ -127,8 +139,14 @@ struct CancelInterceptionArgs {
FetchEventTimeStamps timeStamps;
};
union IPCFetchEventRespondWithResult {
IPCSynthesizeResponseArgs;
union ChildToParentFetchEventRespondWithResult {
ChildToParentSynthesizeResponseArgs;
ResetInterceptionArgs;
CancelInterceptionArgs;
};
union ParentToParentFetchEventRespondWithResult {
ParentToParentSynthesizeResponseArgs;
ResetInterceptionArgs;
CancelInterceptionArgs;
};

View File

@ -613,7 +613,7 @@ nsresult ServiceWorkerPrivateImpl::PendingPushEvent::Send() {
ServiceWorkerPrivateImpl::PendingFetchEvent::PendingFetchEvent(
ServiceWorkerPrivateImpl* aOwner,
RefPtr<ServiceWorkerRegistrationInfo>&& aRegistration,
ServiceWorkerFetchEventOpArgs&& aArgs,
ParentToParentServiceWorkerFetchEventOpArgs&& aArgs,
nsCOMPtr<nsIInterceptedChannel>&& aChannel,
RefPtr<FetchServiceResponsePromise>&& aPreloadResponseReadyPromise)
: PendingFunctionalEvent(aOwner, std::move(aRegistration)),
@ -865,10 +865,12 @@ nsresult ServiceWorkerPrivateImpl::SendFetchEvent(
// SafeRefPtr<InternalRequest>&&, nsCOMPtr<nsIInterceptedChannel>);
}
ServiceWorkerFetchEventOpArgs args(
mOuter->mInfo->ScriptSpec(), std::move(request), nsString(aClientId),
nsString(aResultingClientId), isNonSubresourceRequest, preloadNavigation,
Nothing(), mOuter->mInfo->TestingInjectCancellation());
ParentToParentServiceWorkerFetchEventOpArgs args(
ServiceWorkerFetchEventOpArgsCommon(
mOuter->mInfo->ScriptSpec(), request, nsString(aClientId),
nsString(aResultingClientId), isNonSubresourceRequest,
preloadNavigation, mOuter->mInfo->TestingInjectCancellation()),
Nothing());
if (mOuter->mInfo->State() == ServiceWorkerState::Activating) {
UniquePtr<PendingFunctionalEvent> pendingEvent =
@ -894,7 +896,7 @@ nsresult ServiceWorkerPrivateImpl::SendFetchEvent(
nsresult ServiceWorkerPrivateImpl::SendFetchEventInternal(
RefPtr<ServiceWorkerRegistrationInfo>&& aRegistration,
ServiceWorkerFetchEventOpArgs&& aArgs,
ParentToParentServiceWorkerFetchEventOpArgs&& aArgs,
nsCOMPtr<nsIInterceptedChannel>&& aChannel,
RefPtr<FetchServiceResponsePromise>&& aPreloadResponseReadyPromise) {
AssertIsOnMainThread();
@ -907,8 +909,8 @@ nsresult ServiceWorkerPrivateImpl::SendFetchEventInternal(
}
MOZ_TRY(SpawnWorkerIfNeeded());
MOZ_TRY(
MaybeStoreStreamForBackgroundThread(aChannel, aArgs.internalRequest()));
MOZ_TRY(MaybeStoreStreamForBackgroundThread(
aChannel, aArgs.common().internalRequest()));
scopeExit.release();
@ -1093,7 +1095,8 @@ nsresult ServiceWorkerPrivateImpl::ExecServiceWorkerOp(
AssertIsOnMainThread();
MOZ_ASSERT(mOuter);
MOZ_ASSERT(
aArgs.type() != ServiceWorkerOpArgs::TServiceWorkerFetchEventOpArgs,
aArgs.type() !=
ServiceWorkerOpArgs::TParentToChildServiceWorkerFetchEventOpArgs,
"FetchEvent operations should be sent through FetchEventOp(Proxy) "
"actors!");
MOZ_ASSERT(aSuccessCallback);

View File

@ -124,7 +124,7 @@ class ServiceWorkerPrivateImpl final : public ServiceWorkerPrivate::Inner,
nsresult SendFetchEventInternal(
RefPtr<ServiceWorkerRegistrationInfo>&& aRegistration,
ServiceWorkerFetchEventOpArgs&& aArgs,
ParentToParentServiceWorkerFetchEventOpArgs&& aArgs,
nsCOMPtr<nsIInterceptedChannel>&& aChannel,
RefPtr<FetchServiceResponsePromise>&& aPreloadResponseReadyPromise);
@ -170,7 +170,7 @@ class ServiceWorkerPrivateImpl final : public ServiceWorkerPrivate::Inner,
PendingFetchEvent(
ServiceWorkerPrivateImpl* aOwner,
RefPtr<ServiceWorkerRegistrationInfo>&& aRegistration,
ServiceWorkerFetchEventOpArgs&& aArgs,
ParentToParentServiceWorkerFetchEventOpArgs&& aArgs,
nsCOMPtr<nsIInterceptedChannel>&& aChannel,
RefPtr<FetchServiceResponsePromise>&& aPreloadResponseReadyPromise);
@ -179,7 +179,7 @@ class ServiceWorkerPrivateImpl final : public ServiceWorkerPrivate::Inner,
~PendingFetchEvent();
private:
ServiceWorkerFetchEventOpArgs mArgs;
ParentToParentServiceWorkerFetchEventOpArgs mArgs;
nsCOMPtr<nsIInterceptedChannel> mChannel;
// The promise from FetchService. It indicates if the preload response is
// ready or not. The promise's resolve/reject value should be handled in

View File

@ -74,7 +74,7 @@ parent:
async SetServiceWorkerSkipWaitingFlag() returns (bool aOk);
child:
async PFetchEventOpProxy(ServiceWorkerFetchEventOpArgs aArgs);
async PFetchEventOpProxy(ParentToChildServiceWorkerFetchEventOpArgs aArgs);
async __delete__();

View File

@ -34,7 +34,7 @@ protocol PRemoteWorkerController {
async SetServiceWorkerSkipWaitingFlag() returns (bool aOk);
parent:
async PFetchEventOp(ServiceWorkerFetchEventOpArgs aArgs);
async PFetchEventOp(ParentToParentServiceWorkerFetchEventOpArgs aArgs);
async __delete__();

View File

@ -1013,7 +1013,8 @@ IPCResult RemoteWorkerChild::RecvExecServiceWorkerOp(
ServiceWorkerOpArgs&& aArgs, ExecServiceWorkerOpResolver&& aResolve) {
MOZ_ASSERT(mIsServiceWorker);
MOZ_ASSERT(
aArgs.type() != ServiceWorkerOpArgs::TServiceWorkerFetchEventOpArgs,
aArgs.type() !=
ServiceWorkerOpArgs::TParentToChildServiceWorkerFetchEventOpArgs,
"FetchEvent operations should be sent via PFetchEventOp(Proxy) actors!");
MaybeReportServiceWorkerShutdownProgress(aArgs);
@ -1064,13 +1065,13 @@ RemoteWorkerChild::MaybeSendSetServiceWorkerSkipWaitingFlag() {
*/
already_AddRefed<PFetchEventOpProxyChild>
RemoteWorkerChild::AllocPFetchEventOpProxyChild(
const ServiceWorkerFetchEventOpArgs& aArgs) {
const ParentToChildServiceWorkerFetchEventOpArgs& aArgs) {
return RefPtr{new FetchEventOpProxyChild()}.forget();
}
IPCResult RemoteWorkerChild::RecvPFetchEventOpProxyConstructor(
PFetchEventOpProxyChild* aActor,
const ServiceWorkerFetchEventOpArgs& aArgs) {
const ParentToChildServiceWorkerFetchEventOpArgs& aArgs) {
MOZ_ASSERT(aActor);
(static_cast<FetchEventOpProxyChild*>(aActor))->Initialize(aArgs);

View File

@ -124,11 +124,11 @@ class RemoteWorkerChild final
ServiceWorkerOpArgs&& aArgs, ExecServiceWorkerOpResolver&& aResolve);
already_AddRefed<PFetchEventOpProxyChild> AllocPFetchEventOpProxyChild(
const ServiceWorkerFetchEventOpArgs& aArgs);
const ParentToChildServiceWorkerFetchEventOpArgs& aArgs);
mozilla::ipc::IPCResult RecvPFetchEventOpProxyConstructor(
PFetchEventOpProxyChild* aActor,
const ServiceWorkerFetchEventOpArgs& aArgs) override;
const ParentToChildServiceWorkerFetchEventOpArgs& aArgs) override;
nsresult ExecWorkerOnMainThread(RemoteWorkerData&& aData);

View File

@ -291,7 +291,7 @@ RefPtr<ServiceWorkerOpPromise> RemoteWorkerController::ExecServiceWorkerOp(
RefPtr<ServiceWorkerFetchEventOpPromise>
RemoteWorkerController::ExecServiceWorkerFetchEventOp(
const ServiceWorkerFetchEventOpArgs& aArgs,
const ParentToParentServiceWorkerFetchEventOpArgs& aArgs,
RefPtr<FetchEventOpParent> aReal) {
AssertIsOnBackgroundThread();
MOZ_ASSERT(mIsServiceWorker);
@ -516,7 +516,7 @@ void RemoteWorkerController::PendingServiceWorkerOp::Cancel() {
}
RemoteWorkerController::PendingSWFetchEventOp::PendingSWFetchEventOp(
const ServiceWorkerFetchEventOpArgs& aArgs,
const ParentToParentServiceWorkerFetchEventOpArgs& aArgs,
RefPtr<ServiceWorkerFetchEventOpPromise::Private> aPromise,
RefPtr<FetchEventOpParent>&& aReal)
: mArgs(aArgs), mPromise(std::move(aPromise)), mReal(aReal) {
@ -525,7 +525,7 @@ RemoteWorkerController::PendingSWFetchEventOp::PendingSWFetchEventOp(
// If there is a TParentToParentStream in the request body, we need to
// save it to our stream.
IPCInternalRequest& req = mArgs.internalRequest();
IPCInternalRequest& req = mArgs.common().internalRequest();
if (req.body().isSome() &&
req.body().ref().type() == BodyStreamVariant::TParentToParentStream) {
nsCOMPtr<nsIInputStream> stream;

View File

@ -151,7 +151,7 @@ class RemoteWorkerController final {
ServiceWorkerOpArgs&& aArgs);
RefPtr<ServiceWorkerFetchEventOpPromise> ExecServiceWorkerFetchEventOp(
const ServiceWorkerFetchEventOpArgs& aArgs,
const ParentToParentServiceWorkerFetchEventOpArgs& aArgs,
RefPtr<FetchEventOpParent> aReal);
RefPtr<GenericPromise> SetServiceWorkerSkipWaitingFlag() const;
@ -295,7 +295,7 @@ class RemoteWorkerController final {
class PendingSWFetchEventOp final : public PendingOp {
public:
PendingSWFetchEventOp(
const ServiceWorkerFetchEventOpArgs& aArgs,
const ParentToParentServiceWorkerFetchEventOpArgs& aArgs,
RefPtr<ServiceWorkerFetchEventOpPromise::Private> aPromise,
RefPtr<FetchEventOpParent>&& aReal);
@ -306,7 +306,7 @@ class RemoteWorkerController final {
void Cancel() override;
private:
ServiceWorkerFetchEventOpArgs mArgs;
ParentToParentServiceWorkerFetchEventOpArgs mArgs;
RefPtr<ServiceWorkerFetchEventOpPromise::Private> mPromise;
RefPtr<FetchEventOpParent> mReal;
nsCOMPtr<nsIInputStream> mBodyStream;

View File

@ -32,7 +32,7 @@ RemoteWorkerControllerChild::RemoteWorkerControllerChild(
}
PFetchEventOpChild* RemoteWorkerControllerChild::AllocPFetchEventOpChild(
const ServiceWorkerFetchEventOpArgs& aArgs) {
const ParentToParentServiceWorkerFetchEventOpArgs& aArgs) {
MOZ_CRASH("PFetchEventOpChild actors must be manually constructed!");
return nullptr;
}

View File

@ -38,7 +38,7 @@ class RemoteWorkerControllerChild final : public PRemoteWorkerControllerChild {
~RemoteWorkerControllerChild() = default;
PFetchEventOpChild* AllocPFetchEventOpChild(
const ServiceWorkerFetchEventOpArgs& aArgs);
const ParentToParentServiceWorkerFetchEventOpArgs& aArgs);
bool DeallocPFetchEventOpChild(PFetchEventOpChild* aActor);

View File

@ -69,7 +69,7 @@ RemoteWorkerControllerParent::~RemoteWorkerControllerParent() {
}
PFetchEventOpParent* RemoteWorkerControllerParent::AllocPFetchEventOpParent(
const ServiceWorkerFetchEventOpArgs& aArgs) {
const ParentToParentServiceWorkerFetchEventOpArgs& aArgs) {
AssertIsOnBackgroundThread();
RefPtr<FetchEventOpParent> actor = new FetchEventOpParent();
@ -77,7 +77,8 @@ PFetchEventOpParent* RemoteWorkerControllerParent::AllocPFetchEventOpParent(
}
IPCResult RemoteWorkerControllerParent::RecvPFetchEventOpConstructor(
PFetchEventOpParent* aActor, const ServiceWorkerFetchEventOpArgs& aArgs) {
PFetchEventOpParent* aActor,
const ParentToParentServiceWorkerFetchEventOpArgs& aArgs) {
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);

View File

@ -44,11 +44,11 @@ class RemoteWorkerControllerParent final : public PRemoteWorkerControllerParent,
~RemoteWorkerControllerParent();
PFetchEventOpParent* AllocPFetchEventOpParent(
const ServiceWorkerFetchEventOpArgs& aArgs);
const ParentToParentServiceWorkerFetchEventOpArgs& aArgs);
mozilla::ipc::IPCResult RecvPFetchEventOpConstructor(
PFetchEventOpParent* aActor,
const ServiceWorkerFetchEventOpArgs& aArgs) override;
const ParentToParentServiceWorkerFetchEventOpArgs& aArgs) override;
bool DeallocPFetchEventOpParent(PFetchEventOpParent* aActor);

View File

@ -70,7 +70,7 @@ void RemoteWorkerParent::Initialize(bool aAlreadyRegistered) {
already_AddRefed<PFetchEventOpProxyParent>
RemoteWorkerParent::AllocPFetchEventOpProxyParent(
const ServiceWorkerFetchEventOpArgs& aArgs) {
const ParentToChildServiceWorkerFetchEventOpArgs& aArgs) {
MOZ_CRASH("PFetchEventOpProxyParent actors must be manually constructed!");
return nullptr;
}

View File

@ -37,7 +37,7 @@ class RemoteWorkerParent final : public PRemoteWorkerParent {
~RemoteWorkerParent();
already_AddRefed<PFetchEventOpProxyParent> AllocPFetchEventOpProxyParent(
const ServiceWorkerFetchEventOpArgs& aArgs);
const ParentToChildServiceWorkerFetchEventOpArgs& aArgs);
void ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason) override;