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 1732448e16
commit 2a3bd2d81e
7 changed files with 24 additions and 37 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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