Skip to content

Commit

Permalink
Bug 1667316 - Pass nsresult status to OnRedirectResult r=necko-review…
Browse files Browse the repository at this point in the history
…ers,kershaw

Differential Revision: https://phabricator.services.mozilla.com/D140569
  • Loading branch information
valenting committed Nov 16, 2022
1 parent 85160a6 commit c05781f
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion netwerk/base/nsIParentRedirectingChannel.idl
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ interface nsIParentRedirectingChannel : nsIParentChannel
* Primarilly used by HttpChannelParent::OnRedirectResult and kept as
* mActiveChannel and mRedirectChannel in that class.
*/
void completeRedirect(in boolean succeeded);
void completeRedirect(in nsresult succeeded);
};
2 changes: 1 addition & 1 deletion netwerk/base/nsIRedirectResultListener.idl
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ interface nsIRedirectResultListener : nsISupports
* Indicated whether the redirect will be proceeding, or not (i.e.
* has been canceled, or failed).
*/
void onRedirectResult(in boolean proceeding);
void onRedirectResult(in nsresult status);
};
4 changes: 2 additions & 2 deletions netwerk/protocol/http/EarlyHintPreloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ EarlyHintPreloader::AsyncOnChannelRedirect(
//-----------------------------------------------------------------------------

NS_IMETHODIMP
EarlyHintPreloader::OnRedirectResult(bool aProceeding) {
if (aProceeding && mRedirectChannel) {
EarlyHintPreloader::OnRedirectResult(nsresult aStatus) {
if (NS_SUCCEEDED(aStatus) && mRedirectChannel) {
mChannel = mRedirectChannel;
}

Expand Down
2 changes: 1 addition & 1 deletion netwerk/protocol/http/HttpChannelChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1529,7 +1529,7 @@ void HttpChannelChild::Redirect3Complete() {
nsCOMPtr<nsIRedirectResultListener> vetoHook;
GetCallback(vetoHook);
if (vetoHook) {
vetoHook->OnRedirectResult(true);
vetoHook->OnRedirectResult(NS_OK);
}

// Chrome channel has been AsyncOpen'd. Reflect this in child.
Expand Down
26 changes: 15 additions & 11 deletions netwerk/protocol/http/HttpChannelParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1795,9 +1795,9 @@ HttpChannelParent::StartRedirect(nsIChannel* newChannel, uint32_t redirectFlags,
}

NS_IMETHODIMP
HttpChannelParent::CompleteRedirect(bool succeeded) {
LOG(("HttpChannelParent::CompleteRedirect [this=%p succeeded=%d]\n", this,
succeeded));
HttpChannelParent::CompleteRedirect(nsresult status) {
LOG(("HttpChannelParent::CompleteRedirect [this=%p status=0x%X]\n", this,
static_cast<uint32_t>(status)));

// If this was an internal redirect for a service worker interception then
// we will not have a redirecting channel here. Hide this redirect from
Expand All @@ -1806,7 +1806,7 @@ HttpChannelParent::CompleteRedirect(bool succeeded) {
return NS_OK;
}

if (succeeded && !mIPCClosed) {
if (NS_SUCCEEDED(status) && !mIPCClosed) {
// TODO: check return value: assume child dead if failed
Unused << SendRedirect3Complete();
}
Expand Down Expand Up @@ -1935,11 +1935,11 @@ HttpChannelParent::AsyncOnChannelRedirect(
//-----------------------------------------------------------------------------

NS_IMETHODIMP
HttpChannelParent::OnRedirectResult(bool succeeded) {
LOG(("HttpChannelParent::OnRedirectResult [this=%p, suc=%d]", this,
succeeded));
HttpChannelParent::OnRedirectResult(nsresult status) {
LOG(("HttpChannelParent::OnRedirectResult [this=%p, status=0x%X]", this,
static_cast<uint32_t>(status)));

nsresult rv;
nsresult rv = NS_OK;

nsCOMPtr<nsIParentChannel> redirectChannel;
if (mRedirectChannelId) {
Expand Down Expand Up @@ -1972,12 +1972,16 @@ HttpChannelParent::OnRedirectResult(bool succeeded) {
}

if (!redirectChannel) {
succeeded = false;
if (NS_FAILED(rv)) {
status = rv;
} else {
status = NS_ERROR_NULL_POINTER;
}
}

CompleteRedirect(succeeded);
CompleteRedirect(status);

if (succeeded) {
if (NS_SUCCEEDED(status)) {
if (!SameCOMIdentity(redirectChannel,
static_cast<nsIParentRedirectingChannel*>(this))) {
Delete();
Expand Down
2 changes: 1 addition & 1 deletion netwerk/protocol/http/InterceptedHttpChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ InterceptedHttpChannel::OnRedirectVerifyCallback(nsresult rv) {
nsCOMPtr<nsIRedirectResultListener> hook;
GetCallback(hook);
if (hook) {
hook->OnRedirectResult(NS_SUCCEEDED(rv));
hook->OnRedirectResult(rv);
}

if (NS_FAILED(rv)) {
Expand Down
2 changes: 1 addition & 1 deletion netwerk/protocol/http/nsHttpChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void AutoRedirectVetoNotifier::ReportRedirectResult(nsresult aRv) {
nsHttpChannel* channel = mChannel;
mChannel = nullptr;

if (vetoHook) vetoHook->OnRedirectResult(NS_SUCCEEDED(aRv));
if (vetoHook) vetoHook->OnRedirectResult(aRv);

// Drop after the notification
channel->StoreHasAutoRedirectVetoNotifier(false);
Expand Down
4 changes: 2 additions & 2 deletions netwerk/protocol/webtransport/WebTransportSessionProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,8 @@ WebTransportSessionProxy::AsyncOnChannelRedirect(
//-----------------------------------------------------------------------------

NS_IMETHODIMP
WebTransportSessionProxy::OnRedirectResult(bool aProceeding) {
if (aProceeding && mRedirectChannel) {
WebTransportSessionProxy::OnRedirectResult(nsresult aStatus) {
if (NS_SUCCEEDED(aStatus) && mRedirectChannel) {
mChannel = mRedirectChannel;
}

Expand Down
4 changes: 2 additions & 2 deletions uriloader/prefetch/nsPrefetchService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ nsPrefetchNode::AsyncOnChannelRedirect(
//-----------------------------------------------------------------------------

NS_IMETHODIMP
nsPrefetchNode::OnRedirectResult(bool proceeding) {
if (proceeding && mRedirectChannel) mChannel = mRedirectChannel;
nsPrefetchNode::OnRedirectResult(nsresult status) {
if (NS_SUCCEEDED(status) && mRedirectChannel) mChannel = mRedirectChannel;

mRedirectChannel = nullptr;

Expand Down
6 changes: 3 additions & 3 deletions uriloader/preload/PreloaderBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ NS_IMETHODIMP PreloaderBase::RedirectSink::AsyncOnChannelRedirect(
return NS_OK;
}

NS_IMETHODIMP PreloaderBase::RedirectSink::OnRedirectResult(bool proceeding) {
if (proceeding && mRedirectChannel) {
NS_IMETHODIMP PreloaderBase::RedirectSink::OnRedirectResult(nsresult status) {
if (NS_SUCCEEDED(status) && mRedirectChannel) {
mPreloader->mChannel = std::move(mRedirectChannel);
} else {
mRedirectChannel = nullptr;
Expand All @@ -89,7 +89,7 @@ NS_IMETHODIMP PreloaderBase::RedirectSink::OnRedirectResult(bool proceeding) {
if (mCallbacks) {
nsCOMPtr<nsIRedirectResultListener> sink(do_GetInterface(mCallbacks));
if (sink) {
return sink->OnRedirectResult(proceeding);
return sink->OnRedirectResult(status);
}
}

Expand Down

0 comments on commit c05781f

Please sign in to comment.