Bug 1901851 - Part 2: Remove unnecessary BackgroundParent arguments from response serializations, r=dom-worker-reviewers,asuth

These arguments were already unused, and are no longer necessary since previous
changes to input stream serialization.

Differential Revision: https://phabricator.services.mozilla.com/D213332
This commit is contained in:
Nika Layzell 2024-06-24 23:19:26 +00:00
parent c04b7872be
commit eb355c902b
7 changed files with 24 additions and 37 deletions

View File

@ -271,7 +271,7 @@ void FetchParent::OnResponseAvailableInternal(
}
Unused << SendOnResponseAvailableInternal(
aResponse->ToParentToChildInternalResponse(WrapNotNull(Manager())));
aResponse->ToParentToChildInternalResponse());
}
void FetchParent::OnResponseEnd(const ResponseEndArgs& aArgs) {

View File

@ -56,7 +56,6 @@ ParentToParentStream ToParentToParentStream(
ParentToChildStream ToParentToChildStream(
const NotNull<nsCOMPtr<nsIInputStream>>& aStream, int64_t aStreamSize,
NotNull<mozilla::ipc::PBackgroundParent*> aBackgroundParent,
bool aSerializeAsLazy) {
MOZ_ASSERT(XRE_IsParentProcess());
@ -73,11 +72,9 @@ ParentToChildStream ToParentToChildStream(
return result;
}
ParentToChildStream ToParentToChildStream(
const ParentToParentStream& aStream, int64_t aStreamSize,
NotNull<mozilla::ipc::PBackgroundParent*> aBackgroundParent) {
return ToParentToChildStream(ToInputStream(aStream), aStreamSize,
aBackgroundParent);
ParentToChildStream ToParentToChildStream(const ParentToParentStream& aStream,
int64_t aStreamSize) {
return ToParentToChildStream(ToInputStream(aStream), aStreamSize);
}
} // namespace mozilla::dom

View File

@ -40,14 +40,12 @@ ParentToParentStream ToParentToParentStream(
// process. Can only be called in the parent process.
ParentToChildStream ToParentToChildStream(
const NotNull<nsCOMPtr<nsIInputStream>>& aStream, int64_t aStreamSize,
NotNull<mozilla::ipc::PBackgroundParent*> aBackgroundParent,
bool aSerializeAsLazy = true);
// Convert a ParentToParentStream to a ParentToChildStream. Can only be called
// in the parent process.
ParentToChildStream ToParentToChildStream(
const ParentToParentStream& aStream, int64_t aStreamSize,
NotNull<mozilla::ipc::PBackgroundParent*> aBackgroundParent);
ParentToChildStream ToParentToChildStream(const ParentToParentStream& aStream,
int64_t aStreamSize);
} // namespace dom

View File

@ -197,8 +197,8 @@ InternalResponse::ToParentToParentInternalResponse() {
return result;
}
ParentToChildInternalResponse InternalResponse::ToParentToChildInternalResponse(
NotNull<mozilla::ipc::PBackgroundParent*> aBackgroundParent) {
ParentToChildInternalResponse
InternalResponse::ToParentToChildInternalResponse() {
ParentToChildInternalResponse result(GetMetadata(), Nothing(),
UNKNOWN_BODY_SIZE, Nothing());
@ -207,8 +207,8 @@ ParentToChildInternalResponse InternalResponse::ToParentToChildInternalResponse(
GetUnfilteredBody(getter_AddRefs(body), &bodySize);
if (body) {
ParentToChildStream bodyStream = ToParentToChildStream(
WrapNotNull(body), bodySize, aBackgroundParent, mSerializeAsLazy);
ParentToChildStream bodyStream =
ToParentToChildStream(WrapNotNull(body), bodySize, mSerializeAsLazy);
// The body stream can fail to serialize as an IPCStream. In the case, the
// IPCStream's type would be T__None. Don't set up IPCInternalResponse's
// body with the failed IPCStream.
@ -221,9 +221,8 @@ ParentToChildInternalResponse InternalResponse::ToParentToChildInternalResponse(
nsCOMPtr<nsIInputStream> alternativeBody = TakeAlternativeBody();
if (alternativeBody) {
ParentToChildStream alterBodyStream =
ToParentToChildStream(WrapNotNull(alternativeBody), UNKNOWN_BODY_SIZE,
aBackgroundParent, mSerializeAsLazy);
ParentToChildStream alterBodyStream = ToParentToChildStream(
WrapNotNull(alternativeBody), UNKNOWN_BODY_SIZE, mSerializeAsLazy);
// The body stream can fail to serialize as an IPCStream. In the case, the
// IPCStream's type would be T__None. Don't set up IPCInternalResponse's
// body with the failed IPCStream.
@ -433,19 +432,18 @@ SafeRefPtr<InternalResponse> InternalResponse::CreateIncompleteCopy() {
}
ParentToChildInternalResponse ToParentToChild(
const ParentToParentInternalResponse& aResponse,
NotNull<mozilla::ipc::PBackgroundParent*> aBackgroundParent) {
const ParentToParentInternalResponse& aResponse) {
ParentToChildInternalResponse result(aResponse.metadata(), Nothing(),
aResponse.bodySize(), Nothing());
if (aResponse.body().isSome()) {
result.body() = Some(ToParentToChildStream(
aResponse.body().ref(), aResponse.bodySize(), aBackgroundParent));
result.body() = Some(
ToParentToChildStream(aResponse.body().ref(), aResponse.bodySize()));
}
if (aResponse.alternativeBody().isSome()) {
result.alternativeBody() = Some(ToParentToChildStream(
aResponse.alternativeBody().ref(), InternalResponse::UNKNOWN_BODY_SIZE,
aBackgroundParent));
result.alternativeBody() =
Some(ToParentToChildStream(aResponse.alternativeBody().ref(),
InternalResponse::UNKNOWN_BODY_SIZE));
}
return result;

View File

@ -57,8 +57,7 @@ class InternalResponse final : public AtomicSafeRefCounted<InternalResponse> {
ParentToParentInternalResponse ToParentToParentInternalResponse();
ParentToChildInternalResponse ToParentToChildInternalResponse(
NotNull<mozilla::ipc::PBackgroundParent*> aBackgroundParent);
ParentToChildInternalResponse ToParentToChildInternalResponse();
enum CloneType {
eCloneInputStream,
@ -410,8 +409,7 @@ class InternalResponse final : public AtomicSafeRefCounted<InternalResponse> {
};
ParentToChildInternalResponse ToParentToChild(
const ParentToParentInternalResponse& aResponse,
NotNull<mozilla::ipc::PBackgroundParent*> aBackgroundParent);
const ParentToParentInternalResponse& aResponse);
} // namespace dom
} // namespace mozilla

View File

@ -51,11 +51,8 @@ mozilla::ipc::IPCResult FetchEventOpParent::RecvPreloadResponse(
aPending.mPreloadResponse = Some(std::move(aResponse));
},
[&aResponse](Started& aStarted) {
auto backgroundParent = WrapNotNull(
WrapNotNull(aStarted.mFetchEventOpProxyParent->Manager())
->Manager());
Unused << aStarted.mFetchEventOpProxyParent->SendPreloadResponse(
ToParentToChild(aResponse, backgroundParent));
ToParentToChild(aResponse));
},
[](const Finished&) {});

View File

@ -121,8 +121,8 @@ ParentToParentFetchEventRespondWithResult ToParentToParent(
Nothing(), Nothing());
if (aArgs.preloadResponse().isSome()) {
// Convert the preload response to ParentToChildInternalResponse.
copyArgs.preloadResponse() = Some(ToParentToChild(
aArgs.preloadResponse().ref(), WrapNotNull(aManager->Manager())));
copyArgs.preloadResponse() =
Some(ToParentToChild(aArgs.preloadResponse().ref()));
}
if (aArgs.preloadResponseTiming().isSome()) {
@ -145,8 +145,7 @@ ParentToParentFetchEventRespondWithResult ToParentToParent(
auto [preloadResponse, preloadResponseEndArgs] =
actor->mReal->OnStart(WrapNotNull(actor));
if (copyArgs.preloadResponse().isNothing() && preloadResponse.isSome()) {
copyArgs.preloadResponse() = Some(ToParentToChild(
preloadResponse.ref(), WrapNotNull(aManager->Manager())));
copyArgs.preloadResponse() = Some(ToParentToChild(preloadResponse.ref()));
}
if (copyArgs.preloadResponseEndArgs().isNothing() &&
preloadResponseEndArgs.isSome()) {