Closed Bug 1598497 Opened 5 years ago Closed 5 years ago

Consider moving nsIHttpChannelInternal.canceled to nsIChannel

Categories

(Core :: Networking: HTTP, task, P2)

task

Tracking

()

RESOLVED FIXED
mozilla73
Fission Milestone M5
Tracking Status
firefox73 --- fixed

People

(Reporter: ehsan.akhgari, Assigned: jya)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

Attachments

(2 files)

I noticed in the debugger that a QI in nsAsyncRedirectVerifyHelper::IsOldChannelCanceled fails on a DocumentChannelChild, whereas this channel definitely has a cancelled status and might be cancelled here, so this looked like a bug, though I'm unsure of its implications.

Component: Networking → Networking: HTTP
Priority: -- → P2
Whiteboard: [necko-triaged]
Assignee: nobody → jyavenard

(In reply to :ehsan akhgari from comment #0)

I noticed in the debugger that a QI in nsAsyncRedirectVerifyHelper::IsOldChannelCanceled fails on a DocumentChannelChild, whereas this channel definitely has a cancelled status and might be cancelled here, so this looked like a bug, though I'm unsure of its implications.

What do you mean by failing?

nsAsyncRedirectVerifyHelper::IsOldChannelCanceled will QI nsIHttpChannelInternal and if that fails will default to checking the status instead.

This fallback will work just fine with DocumentChannelChild, as calling DCC::Cancel(status) will set the status to an error code, and as such we will get to there:
https://searchfox.org/mozilla-central/rev/652014ca1183c56bc5f04daf01af180d4e50a91c/netwerk/base/nsAsyncRedirectVerifyHelper.cpp#288

I'm happy to move GetCanceled to nsIChannel, as I believe it makes for a more elegant solution than the one in place, but it's an expansive change.

Flags: needinfo?(ehsan)

There is no functional change with this commit. The default implementation for GetCanceled() is still to check if the status code is a failure.

However, it can be argued that as you had to call Cancel() on the nsIChannel, having to check the nsIHttpChannelInternal interface to determine if you had been canceled in the past was rather a non obvious path.

It makes more sense to check the nsIChannel interface to determine if it's been canceled already and this allows for finer granularity if needed in the future.

(In reply to Jean-Yves Avenard [:jya] from comment #1)

(In reply to :ehsan akhgari from comment #0)

I noticed in the debugger that a QI in nsAsyncRedirectVerifyHelper::IsOldChannelCanceled fails on a DocumentChannelChild, whereas this channel definitely has a cancelled status and might be cancelled here, so this looked like a bug, though I'm unsure of its implications.

What do you mean by failing?

I mean at https://searchfox.org/mozilla-central/rev/652014ca1183c56bc5f04daf01af180d4e50a91c/netwerk/base/nsAsyncRedirectVerifyHelper.cpp#276-277 mOldChan is pointing to a DocumentChannelChild, and that line calls DocumentChannelChild::QueryInterface() asking for nsIHttpChannelInternal and gets a nullptr out.

nsAsyncRedirectVerifyHelper::IsOldChannelCanceled will QI nsIHttpChannelInternal and if that fails will default to checking the status instead.

This fallback will work just fine with DocumentChannelChild, as calling DCC::Cancel(status) will set the status to an error code, and as such we will get to there:
https://searchfox.org/mozilla-central/rev/652014ca1183c56bc5f04daf01af180d4e50a91c/netwerk/base/nsAsyncRedirectVerifyHelper.cpp#288

Perhaps I'm misunderstanding how this code works, but when DocumentChannelChild::mCanceled is set it seems that DocumentChannelChild::mStatus is not set immediately. (I think the parent will end up notifying the child later and that's when mStatus gets set.) So it wasn't obvious to me if the fallback path is indeed working as expected here.

I'm happy to move GetCanceled to nsIChannel, as I believe it makes for a more elegant solution than the one in place, but it's an expansive change.

FWIW my suggestion may be the wrong way to fix the bug, it was the best I could come up with. :-)

Flags: needinfo?(ehsan)

BTW if my understanding here is correct, there is indeed a functional change in the patch you've posted here, FWIW.

Attachment #9112526 - Attachment description: Bug 1598497 - move canceled attribute to nsIChannel. r?mayhemer → Bug 1598497 - P1. move canceled attribute to nsIChannel. r?mayhemer

For all but nsBaseChannel implementation, GetCanceled will only return true if Cancel() was called.

With nsBaseChannel however, following a call to OnStopRequest and OnRedirectVerifyCallback, GetCanceled() would now return true. Is this intented.

With some methods, calling Cancel(NS_OK) will now make a call to GetCanceled() return true which is a change with earlier behaviour which only returned true if the error code was an actual error.

Depends on D55268

Status: NEW → ASSIGNED
Type: defect → task
Fission Milestone: --- → M5
Attachment #9112793 - Attachment description: Bug 1598497 - P2. Have the canceled attribute only if explicitly canceled. r?mayhemer. → Bug 1598497 - P2. Have the canceled attribute returns true only if explicitly canceled. r?mayhemer.
Attachment #9112793 - Attachment description: Bug 1598497 - P2. Have the canceled attribute returns true only if explicitly canceled. r?mayhemer. → Bug 1598497 - P2. Have the canceled attribute only if explicitly canceled. r?mayhemer.
Pushed by jyavenard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/81beebdc2202 P1. move canceled attribute to nsIChannel. r=mayhemer https://hg.mozilla.org/integration/autoland/rev/3b31bbf74a5f P2. Have the canceled attribute only if explicitly canceled. r=mayhemer.
Pushed by jyavenard@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/37aaa3438c41 P1. move canceled attribute to nsIChannel. r=mayhemer https://hg.mozilla.org/integration/autoland/rev/9f7e7ee68891 P2. Have the canceled attribute only if explicitly canceled. r=mayhemer.
Flags: needinfo?(jyavenard)
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla73
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: