Skip to content

Commit

Permalink
Bug 1584207 - Forward nsILoadInfo.requestBlockingReason to the parent…
Browse files Browse the repository at this point in the history
… process for both old and new redirect channels, r=dragana,asuth

Differential Revision: https://phabricator.services.mozilla.com/D47264

--HG--
extra : moz-landing-system : lando
  • Loading branch information
mayhemer committed Oct 1, 2019
1 parent 92ca18e commit 976b757
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 11 deletions.
12 changes: 10 additions & 2 deletions ipc/glue/BackgroundUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ void LoadInfoToChildLoadInfoForwarder(
nsILoadInfo* aLoadInfo, ChildLoadInfoForwarderArgs* aForwarderArgsOut) {
if (!aLoadInfo) {
*aForwarderArgsOut =
ChildLoadInfoForwarderArgs(Nothing(), Nothing(), Nothing());
ChildLoadInfoForwarderArgs(Nothing(), Nothing(), Nothing(), 0);
return;
}

Expand All @@ -908,7 +908,8 @@ void LoadInfoToChildLoadInfoForwarder(
}

*aForwarderArgsOut =
ChildLoadInfoForwarderArgs(ipcReserved, ipcInitial, ipcController);
ChildLoadInfoForwarderArgs(ipcReserved, ipcInitial, ipcController,
aLoadInfo->GetRequestBlockingReason());
}

nsresult MergeChildLoadInfoForwarder(
Expand Down Expand Up @@ -960,6 +961,13 @@ nsresult MergeChildLoadInfoForwarder(
aLoadInfo->SetController(ServiceWorkerDescriptor(controller.ref()));
}

uint32_t blockingReason = aForwarderArgs.requestBlockingReason();
if (blockingReason) {
// We only want to override when non-null, so that any earlier set non-null
// value is not reverted to 0.
aLoadInfo->SetRequestBlockingReason(blockingReason);
}

return NS_OK;
}

Expand Down
2 changes: 2 additions & 0 deletions netwerk/ipc/NeckoChannelParams.ipdlh
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ struct ChildLoadInfoForwarderArgs
// The ServiceWorker controller may be cleared in the child during
// a redirect.
IPCServiceWorkerDescriptor? controller;

uint32_t requestBlockingReason;
};

//-----------------------------------------------------------------------------
Expand Down
16 changes: 11 additions & 5 deletions netwerk/protocol/http/HttpChannelChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2384,19 +2384,25 @@ HttpChannelChild::OnRedirectVerifyCallback(nsresult result) {
appCacheChannel->GetChooseApplicationCache(&chooseAppcache);
}

uint32_t sourceRequestBlockingReason = 0;
if (mLoadInfo) {
mLoadInfo->GetRequestBlockingReason(&sourceRequestBlockingReason);
}

nsCOMPtr<nsILoadInfo> newChannelLoadInfo = nullptr;
nsCOMPtr<nsIChannel> newChannel = do_QueryInterface(mRedirectChannelChild);
if (newChannel) {
newChannelLoadInfo = newChannel->LoadInfo();
}

ChildLoadInfoForwarderArgs loadInfoForwarder;
LoadInfoToChildLoadInfoForwarder(newChannelLoadInfo, &loadInfoForwarder);
ChildLoadInfoForwarderArgs targetLoadInfoForwarder;
LoadInfoToChildLoadInfoForwarder(newChannelLoadInfo,
&targetLoadInfoForwarder);

if (CanSend())
SendRedirect2Verify(result, *headerTuples, loadInfoForwarder, loadFlags,
referrerInfo, redirectURI, corsPreflightArgs,
chooseAppcache);
SendRedirect2Verify(result, *headerTuples, sourceRequestBlockingReason,
targetLoadInfoForwarder, loadFlags, referrerInfo,
redirectURI, corsPreflightArgs, chooseAppcache);

return NS_OK;
}
Expand Down
14 changes: 12 additions & 2 deletions netwerk/protocol/http/HttpChannelParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,8 @@ mozilla::ipc::IPCResult HttpChannelParent::RecvSetCacheTokenCachedCharset(

mozilla::ipc::IPCResult HttpChannelParent::RecvRedirect2Verify(
const nsresult& aResult, const RequestHeaderTuples& changedHeaders,
const ChildLoadInfoForwarderArgs& aLoadInfoForwarder,
const uint32_t& aSourceRequestBlockingReason,
const ChildLoadInfoForwarderArgs& aTargetLoadInfoForwarder,
const uint32_t& loadFlags, nsIReferrerInfo* aReferrerInfo,
const Maybe<URIParams>& aAPIRedirectURI,
const Maybe<CorsPreflightArgs>& aCorsPreflightArgs,
Expand Down Expand Up @@ -928,13 +929,22 @@ mozilla::ipc::IPCResult HttpChannelParent::RecvRedirect2Verify(
}

nsCOMPtr<nsILoadInfo> newLoadInfo = newHttpChannel->LoadInfo();
rv = MergeChildLoadInfoForwarder(aLoadInfoForwarder, newLoadInfo);
rv = MergeChildLoadInfoForwarder(aTargetLoadInfoForwarder, newLoadInfo);
if (NS_FAILED(rv) && NS_SUCCEEDED(result)) {
result = rv;
}
}
}

// If the redirect is vetoed, reason is set on the source (current) channel's
// load info, so we must carry iver the change.
if (aSourceRequestBlockingReason) {
nsCOMPtr<nsILoadInfo> sourceLoadInfo = mChannel->LoadInfo();
if (sourceLoadInfo) {
sourceLoadInfo->SetRequestBlockingReason(aSourceRequestBlockingReason);
}
}

// Continue the verification procedure if child has veto the redirection.
if (NS_FAILED(result)) {
ContinueRedirect2Verify(result);
Expand Down
3 changes: 2 additions & 1 deletion netwerk/protocol/http/HttpChannelParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ class HttpChannelParent final : public nsIInterfaceRequestor,
virtual mozilla::ipc::IPCResult RecvCancel(const nsresult& status) override;
virtual mozilla::ipc::IPCResult RecvRedirect2Verify(
const nsresult& result, const RequestHeaderTuples& changedHeaders,
const ChildLoadInfoForwarderArgs& aLoadInfoForwarder,
const uint32_t& aSourceRequestBlockingReason,
const ChildLoadInfoForwarderArgs& aTargetLoadInfoForwarder,
const uint32_t& loadFlags, nsIReferrerInfo* aReferrerInfo,
const Maybe<URIParams>& apiRedirectUri,
const Maybe<CorsPreflightArgs>& aCorsPreflightArgs,
Expand Down
3 changes: 2 additions & 1 deletion netwerk/protocol/http/PHttpChannel.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ parent:

// Reports approval/veto of redirect by child process redirect observers
async Redirect2Verify(nsresult result, RequestHeaderTuples changedHeaders,
ChildLoadInfoForwarderArgs loadInfoForwarder,
uint32_t sourceRequestBlockingReason,
ChildLoadInfoForwarderArgs targetLoadInfoForwarder,
uint32_t loadFlags, nsIReferrerInfo referrerInfo,
URIParams? apiRedirectTo,
CorsPreflightArgs? corsPreflightArgs,
Expand Down

0 comments on commit 976b757

Please sign in to comment.