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>
Tue, 8 Mar 2022 21:47:37 +0000 (21:47 +0000)
commit31c76493ffd63f00388ec4aa90716b1edc8ab3b0
tree80f0a39dfd714d1a08818e562bbeaeab2868ce62
parente397b9e58f5252e9e0a08194f47804b6a9c4b551
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