Bug 1667316 - Pass nsresult status to OnRedirectResult r=necko-reviewers,kershaw

Differential Revision: https://phabricator.services.mozilla.com/D140569
This commit is contained in:
Valentin Gosu 2022-11-16 08:49:45 +00:00
parent 85160a6f9d
commit c05781f028
10 changed files with 29 additions and 25 deletions

View File

@ -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);
};

View File

@ -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);
};

View File

@ -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;
}

View File

@ -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.

View File

@ -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
@ -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();
}
@ -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) {
@ -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();

View File

@ -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)) {

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
@ -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);
}
}