From c0aef79fdb7cad00b7498f0fe850cae199d1ada6 Mon Sep 17 00:00:00 2001 From: Valentin Gosu Date: Tue, 31 Mar 2020 07:56:11 +0000 Subject: [PATCH] Bug 1625727 - Only pass ChildLoadInfoForwarderArgs when mRedirectChannelChild implements nsIChannel r=ckerschb,kershaw Differential Revision: https://phabricator.services.mozilla.com/D68811 --HG-- extra : moz-landing-system : lando --- netwerk/protocol/http/HttpChannelChild.cpp | 11 +++++------ netwerk/protocol/http/HttpChannelParent.cpp | 13 ++++++++----- netwerk/protocol/http/HttpChannelParent.h | 2 +- netwerk/protocol/http/PHttpChannel.ipdl | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/netwerk/protocol/http/HttpChannelChild.cpp b/netwerk/protocol/http/HttpChannelChild.cpp index a5aeba019d17..bf03b2ec54af 100644 --- a/netwerk/protocol/http/HttpChannelChild.cpp +++ b/netwerk/protocol/http/HttpChannelChild.cpp @@ -2245,16 +2245,15 @@ HttpChannelChild::OnRedirectVerifyCallback(nsresult aResult) { mLoadInfo->GetRequestBlockingReason(&sourceRequestBlockingReason); } - nsCOMPtr newChannelLoadInfo = nullptr; + Maybe targetLoadInfoForwarder; nsCOMPtr newChannel = do_QueryInterface(mRedirectChannelChild); if (newChannel) { - newChannelLoadInfo = newChannel->LoadInfo(); + ChildLoadInfoForwarderArgs args; + nsCOMPtr loadInfo = newChannel->LoadInfo(); + LoadInfoToChildLoadInfoForwarder(loadInfo, &args); + targetLoadInfoForwarder.emplace(args); } - ChildLoadInfoForwarderArgs targetLoadInfoForwarder; - LoadInfoToChildLoadInfoForwarder(newChannelLoadInfo, - &targetLoadInfoForwarder); - if (CanSend()) SendRedirect2Verify(aResult, *headerTuples, sourceRequestBlockingReason, targetLoadInfoForwarder, loadFlags, referrerInfo, diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index 9196e72122c7..d1313d2aef50 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -843,7 +843,7 @@ mozilla::ipc::IPCResult HttpChannelParent::RecvSetCacheTokenCachedCharset( mozilla::ipc::IPCResult HttpChannelParent::RecvRedirect2Verify( const nsresult& aResult, const RequestHeaderTuples& changedHeaders, const uint32_t& aSourceRequestBlockingReason, - const ChildLoadInfoForwarderArgs& aTargetLoadInfoForwarder, + const Maybe& aTargetLoadInfoForwarder, const uint32_t& loadFlags, nsIReferrerInfo* aReferrerInfo, const Maybe& aAPIRedirectURI, const Maybe& aCorsPreflightArgs, @@ -927,10 +927,13 @@ mozilla::ipc::IPCResult HttpChannelParent::RecvRedirect2Verify( appCacheChannel->SetChooseApplicationCache(setChooseAppCache); } - nsCOMPtr newLoadInfo = newHttpChannel->LoadInfo(); - rv = MergeChildLoadInfoForwarder(aTargetLoadInfoForwarder, newLoadInfo); - if (NS_FAILED(rv) && NS_SUCCEEDED(result)) { - result = rv; + if (aTargetLoadInfoForwarder.isSome()) { + nsCOMPtr newLoadInfo = newHttpChannel->LoadInfo(); + rv = MergeChildLoadInfoForwarder(aTargetLoadInfoForwarder.ref(), + newLoadInfo); + if (NS_FAILED(rv) && NS_SUCCEEDED(result)) { + result = rv; + } } } } diff --git a/netwerk/protocol/http/HttpChannelParent.h b/netwerk/protocol/http/HttpChannelParent.h index 4db571a44b27..fa4191c52b40 100644 --- a/netwerk/protocol/http/HttpChannelParent.h +++ b/netwerk/protocol/http/HttpChannelParent.h @@ -192,7 +192,7 @@ class HttpChannelParent final : public nsIInterfaceRequestor, virtual mozilla::ipc::IPCResult RecvRedirect2Verify( const nsresult& result, const RequestHeaderTuples& changedHeaders, const uint32_t& aSourceRequestBlockingReason, - const ChildLoadInfoForwarderArgs& aTargetLoadInfoForwarder, + const Maybe& aTargetLoadInfoForwarder, const uint32_t& loadFlags, nsIReferrerInfo* aReferrerInfo, const Maybe& apiRedirectUri, const Maybe& aCorsPreflightArgs, diff --git a/netwerk/protocol/http/PHttpChannel.ipdl b/netwerk/protocol/http/PHttpChannel.ipdl index f874b5cfcf21..c2bc0d9c3e91 100644 --- a/netwerk/protocol/http/PHttpChannel.ipdl +++ b/netwerk/protocol/http/PHttpChannel.ipdl @@ -47,7 +47,7 @@ parent: // Reports approval/veto of redirect by child process redirect observers async Redirect2Verify(nsresult result, RequestHeaderTuples changedHeaders, uint32_t sourceRequestBlockingReason, - ChildLoadInfoForwarderArgs targetLoadInfoForwarder, + ChildLoadInfoForwarderArgs? targetLoadInfoForwarder, uint32_t loadFlags, nsIReferrerInfo referrerInfo, URIParams? apiRedirectTo, CorsPreflightArgs? corsPreflightArgs,