Bug 1706594 - Add nsICancelable out param to nsBaseChannel::BeginAsyncRead virtual...
authorLuca Greco <lgreco@mozilla.com>
Mon, 11 Oct 2021 11:06:47 +0000 (11:06 +0000)
committerMike Hommey <glandium@debian.org>
Sat, 5 Mar 2022 22:31:23 +0000 (22:31 +0000)
commitc9001e7a76c53c858b2b412c45cd4c204a05629b
tree4fb54fa97074c9f21ff49bccaba8e05834787cec
parentb2fbed37ff1c2cf512fb5ab0a4de8c9663e38647
Bug 1706594 - Add nsICancelable out param to nsBaseChannel::BeginAsyncRead virtual method. r=nika,necko-reviewers,valentin

This patch introduces:

- a second nsICancelable out param in nsBaseChannel::BeginAsyncRead, which is meant to be non-null
  when the subclass is unable to set the nsIRequest out param right away (e.g because there is
  some async work needed before the subclass is able to get an nsIRequest instance).
  The nsICancelable does only allow the channel to cancel the underlying request (and stream pump),
  but it doesn't allow the channel to be suspended and resumed, but that was already the case
  for the subclasses that were already not returning an nsIRequest instance (e.g. like the
  ExtensionProtocolHandler was doing when it is asynchrously retriving a stream from the parent
  process).

- require NotNull<nsCOMPtr<...>> in the SimpleChannel's BeginAsyncRead callback signature, to make harder
  to overlook the requirement of returning an nsIRequest or nsICancelable.

- a diagnostic assertion (from SimpleChannel's BeginAsyncRead method) to more visible fail if we still end
  up with neither an nsIRequest or nsICancelable result as SimpleChannel callback result.

- changes to ExtensionProtocolHandler, PageThumbProtocolHandler and nsAnnoProtocolHandler to adapt them
  to the new nsBaseChannel::BeginAsyncRead signature.

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

Gbp-Pq: Topic fixes
Gbp-Pq: Name Bug-1706594-Add-nsICancelable-out-param-to-nsBaseCha.patch
netwerk/base/SimpleChannel.cpp
netwerk/base/SimpleChannel.h
netwerk/base/nsBaseChannel.cpp
netwerk/base/nsBaseChannel.h
netwerk/protocol/res/ExtensionProtocolHandler.cpp
netwerk/protocol/res/PageThumbProtocolHandler.cpp
toolkit/components/places/nsAnnoProtocolHandler.cpp