Bug 1851992 - implement nsIThreadRetargetableStreamListener::OnDataFinished to multiple listeners. r=necko-reviewers,extension-reviewers,jesup,rpl

Differential Revision: https://phabricator.services.mozilla.com/D187833
This commit is contained in:
sunil mayya 2023-10-17 08:27:49 +00:00
Родитель b324bd24fe
Коммит f350089afd
63 изменённых файлов: 378 добавлений и 64 удалений

Просмотреть файл

@ -73,7 +73,6 @@ static LazyLogModule gEventSourceLog("EventSource");
PR_IntervalToMilliseconds(DELAY_INTERVAL_LIMIT)
class EventSourceImpl final : public nsIObserver,
public nsIStreamListener,
public nsIChannelEventSink,
public nsIInterfaceRequestor,
public nsSupportsWeakReference,
@ -1950,6 +1949,10 @@ EventSourceImpl::CheckListenerChain() {
MOZ_ASSERT(NS_IsMainThread(), "Should be on the main thread!");
return NS_OK;
}
NS_IMETHODIMP
EventSourceImpl::OnDataFinished(nsresult) { return NS_OK; }
////////////////////////////////////////////////////////////////////////////////
// EventSource
////////////////////////////////////////////////////////////////////////////////

Просмотреть файл

@ -99,8 +99,7 @@ bool ShouldCheckSRI(const InternalRequest& aRequest,
// AlternativeDataStreamListener
//-----------------------------------------------------------------------------
class AlternativeDataStreamListener final
: public nsIStreamListener,
public nsIThreadRetargetableStreamListener {
: public nsIThreadRetargetableStreamListener {
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
@ -318,6 +317,12 @@ AlternativeDataStreamListener::OnStopRequest(nsIRequest* aRequest,
NS_IMETHODIMP
AlternativeDataStreamListener::CheckListenerChain() { return NS_OK; }
NS_IMETHODIMP
AlternativeDataStreamListener::OnDataFinished(nsresult aStatus) {
return NS_OK;
}
//-----------------------------------------------------------------------------
// FetchDriver
//-----------------------------------------------------------------------------
@ -1660,6 +1665,9 @@ FetchDriver::AsyncOnChannelRedirect(nsIChannel* aOldChannel,
NS_IMETHODIMP
FetchDriver::CheckListenerChain() { return NS_OK; }
NS_IMETHODIMP
FetchDriver::OnDataFinished(nsresult) { return NS_OK; }
NS_IMETHODIMP
FetchDriver::GetInterface(const nsIID& aIID, void** aResult) {
if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {

Просмотреть файл

@ -94,8 +94,7 @@ class FetchDriverObserver {
class AlternativeDataStreamListener;
class FetchDriver final : public nsIStreamListener,
public nsIChannelEventSink,
class FetchDriver final : public nsIChannelEventSink,
public nsIInterfaceRequestor,
public nsINetworkInterceptController,
public nsIThreadRetargetableStreamListener,

Просмотреть файл

@ -99,4 +99,7 @@ nsresult MutableBlobStreamListener::WriteSegmentFun(
NS_IMETHODIMP
MutableBlobStreamListener::CheckListenerChain() { return NS_OK; }
NS_IMETHODIMP
MutableBlobStreamListener::OnDataFinished(nsresult) { return NS_OK; }
} // namespace mozilla::dom

Просмотреть файл

@ -17,8 +17,7 @@ class nsIEventTarget;
namespace mozilla::dom {
class MutableBlobStreamListener final
: public nsIStreamListener,
public nsIThreadRetargetableStreamListener {
: public nsIThreadRetargetableStreamListener {
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSISTREAMLISTENER

Просмотреть файл

@ -1212,8 +1212,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
* We break the reference cycle in OnStartRequest by clearing mElement.
*/
class HTMLMediaElement::MediaLoadListener final
: public nsIStreamListener,
public nsIChannelEventSink,
: public nsIChannelEventSink,
public nsIInterfaceRequestor,
public nsIObserver,
public nsIThreadRetargetableStreamListener {
@ -1363,6 +1362,20 @@ HTMLMediaElement::MediaLoadListener::OnDataAvailable(nsIRequest* aRequest,
return mNextListener->OnDataAvailable(aRequest, aStream, aOffset, aCount);
}
NS_IMETHODIMP
HTMLMediaElement::MediaLoadListener::OnDataFinished(nsresult aStatus) {
if (!mNextListener) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetable =
do_QueryInterface(mNextListener);
if (retargetable) {
return retargetable->OnDataFinished(aStatus);
}
return NS_OK;
}
NS_IMETHODIMP
HTMLMediaElement::MediaLoadListener::AsyncOnChannelRedirect(
nsIChannel* aOldChannel, nsIChannel* aNewChannel, uint32_t aFlags,

Просмотреть файл

@ -88,6 +88,20 @@ MediaDocumentStreamListener::OnDataAvailable(nsIRequest* request,
return NS_OK;
}
NS_IMETHODIMP
MediaDocumentStreamListener::OnDataFinished(nsresult aStatus) {
if (!mNextStream) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetable =
do_QueryInterface(mNextStream);
if (retargetable) {
return retargetable->OnDataFinished(aStatus);
}
return NS_OK;
}
NS_IMETHODIMP
MediaDocumentStreamListener::CheckListenerChain() {
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetable =

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/Attributes.h"
#include "nsHTMLDocument.h"
#include "nsGenericHTMLElement.h"
#include "nsIStreamListener.h"
#include "nsIStringBundle.h"
#include "nsIThreadRetargetableStreamListener.h"
@ -95,8 +96,7 @@ class MediaDocument : public nsHTMLDocument {
bool mDidInitialDocumentSetup;
};
class MediaDocumentStreamListener : public nsIStreamListener,
public nsIThreadRetargetableStreamListener {
class MediaDocumentStreamListener : public nsIThreadRetargetableStreamListener {
protected:
virtual ~MediaDocumentStreamListener();

Просмотреть файл

@ -104,6 +104,9 @@ nsresult ChannelMediaResource::Listener::AsyncOnChannelRedirect(
nsresult ChannelMediaResource::Listener::CheckListenerChain() { return NS_OK; }
NS_IMETHODIMP
ChannelMediaResource::Listener::OnDataFinished(nsresult) { return NS_OK; }
nsresult ChannelMediaResource::Listener::GetInterface(const nsIID& aIID,
void** aResult) {
return QueryInterface(aIID, aResult);

Просмотреть файл

@ -166,8 +166,7 @@ class ChannelMediaResource
void GetDebugInfo(dom::MediaResourceDebugInfo& aInfo) override;
class Listener final : public nsIStreamListener,
public nsIInterfaceRequestor,
class Listener final : public nsIInterfaceRequestor,
public nsIChannelEventSink,
public nsIThreadRetargetableStreamListener {
~Listener() = default;

Просмотреть файл

@ -1082,6 +1082,9 @@ nsWebBrowserPersist::OnDataAvailable(nsIRequest* request,
NS_IMETHODIMP nsWebBrowserPersist::CheckListenerChain() { return NS_OK; }
NS_IMETHODIMP
nsWebBrowserPersist::OnDataFinished(nsresult) { return NS_OK; }
//*****************************************************************************
// nsWebBrowserPersist::nsIProgressEventSink
//*****************************************************************************

Просмотреть файл

@ -37,7 +37,6 @@ using ClosePromise = mozilla::MozPromise<nsresult, nsresult, true>;
class nsWebBrowserPersist final : public nsIInterfaceRequestor,
public nsIWebBrowserPersist,
public nsIStreamListener,
public nsIThreadRetargetableStreamListener,
public nsIProgressEventSink,
public nsSupportsWeakReference {

Просмотреть файл

@ -7,6 +7,7 @@
// Undefine windows version of LoadImage because our code uses that name.
#include "mozilla/ScopeExit.h"
#include "nsIChildChannel.h"
#include "nsIThreadRetargetableStreamListener.h"
#undef LoadImage
#include "imgLoader.h"
@ -1792,7 +1793,7 @@ bool imgLoader::ValidateRequestWithNewChannel(
// Casting needed here to get past multiple inheritance.
nsCOMPtr<nsIStreamListener> listener =
do_QueryInterface(static_cast<nsIThreadRetargetableStreamListener*>(hvc));
static_cast<nsIThreadRetargetableStreamListener*>(hvc);
NS_ENSURE_TRUE(listener, false);
// We must set the notification callbacks before setting up the
@ -2979,6 +2980,20 @@ ProxyListener::OnDataAvailable(nsIRequest* aRequest, nsIInputStream* inStr,
return mDestListener->OnDataAvailable(aRequest, inStr, sourceOffset, count);
}
NS_IMETHODIMP
ProxyListener::OnDataFinished(nsresult aStatus) {
if (!mDestListener) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
do_QueryInterface(mDestListener);
if (retargetableListener) {
return retargetableListener->OnDataFinished(aStatus);
}
return NS_OK;
}
/** nsThreadRetargetableStreamListener methods **/
NS_IMETHODIMP
ProxyListener::CheckListenerChain() {
@ -3213,6 +3228,20 @@ imgCacheValidator::OnDataAvailable(nsIRequest* aRequest, nsIInputStream* inStr,
return mDestListener->OnDataAvailable(aRequest, inStr, sourceOffset, count);
}
NS_IMETHODIMP
imgCacheValidator::OnDataFinished(nsresult aStatus) {
if (!mDestListener) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
do_QueryInterface(mDestListener);
if (retargetableListener) {
return retargetableListener->OnDataFinished(aStatus);
}
return NS_OK;
}
/** nsIThreadRetargetableStreamListener methods **/
NS_IMETHODIMP

Просмотреть файл

@ -415,8 +415,7 @@ class imgLoader final : public imgILoader,
#include "nsIStreamListener.h"
#include "nsIThreadRetargetableStreamListener.h"
class ProxyListener : public nsIStreamListener,
public nsIThreadRetargetableStreamListener {
class ProxyListener : public nsIThreadRetargetableStreamListener {
public:
explicit ProxyListener(nsIStreamListener* dest);
@ -464,8 +463,7 @@ class nsProgressNotificationProxy final : public nsIProgressEventSink,
#include "nsCOMArray.h"
class imgCacheValidator : public nsIStreamListener,
public nsIThreadRetargetableStreamListener,
class imgCacheValidator : public nsIThreadRetargetableStreamListener,
public nsIChannelEventSink,
public nsIInterfaceRequestor,
public nsIAsyncVerifyRedirectCallback {

Просмотреть файл

@ -838,6 +838,9 @@ imgRequest::CheckListenerChain() {
return NS_OK;
}
NS_IMETHODIMP
imgRequest::OnDataFinished(nsresult) { return NS_OK; }
/** nsIStreamListener methods **/
struct NewPartResult final {

Просмотреть файл

@ -41,8 +41,7 @@ class ProgressTracker;
struct NewPartResult;
class imgRequest final : public nsIStreamListener,
public nsIThreadRetargetableStreamListener,
class imgRequest final : public nsIThreadRetargetableStreamListener,
public nsIChannelEventSink,
public nsIInterfaceRequestor,
public nsIAsyncVerifyRedirectCallback {

Просмотреть файл

@ -17,8 +17,7 @@ class nsIInputStream;
namespace mozilla::css {
class StreamLoader : public nsIStreamListener,
public nsIThreadRetargetableStreamListener {
class StreamLoader : public nsIThreadRetargetableStreamListener {
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER

Просмотреть файл

@ -1363,3 +1363,14 @@ nsJARChannel::CheckListenerChain() {
return listener->CheckListenerChain();
}
NS_IMETHODIMP
nsJARChannel::OnDataFinished(nsresult aStatus) {
nsCOMPtr<nsIThreadRetargetableStreamListener> listener =
do_QueryInterface(mListener);
if (listener) {
return listener->OnDataFinished(aStatus);
}
return NS_OK;
}

Просмотреть файл

@ -34,7 +34,6 @@ class nsInputStreamPump;
//-----------------------------------------------------------------------------
class nsJARChannel final : public nsIJARChannel,
public nsIStreamListener,
public nsIThreadRetargetableRequest,
public nsIThreadRetargetableStreamListener,
public nsHashPropertyBag {

Просмотреть файл

@ -4,7 +4,9 @@
*/
#include "StreamFunctions.h"
#include "MainThreadUtils.h"
#include "nsDeflateConverter.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "nsStringStream.h"
#include "nsComponentManagerUtils.h"
#include "nsCRT.h"
@ -22,7 +24,7 @@ using namespace mozilla;
* method to the data.
*/
NS_IMPL_ISUPPORTS(nsDeflateConverter, nsIStreamConverter, nsIStreamListener,
nsIRequestObserver)
nsIThreadRetargetableStreamListener, nsIRequestObserver)
nsresult nsDeflateConverter::Init() {
int zerr;
@ -137,6 +139,21 @@ NS_IMETHODIMP nsDeflateConverter::OnStartRequest(nsIRequest* aRequest) {
return mListener->OnStartRequest(aRequest);
}
NS_IMETHODIMP
nsDeflateConverter::OnDataFinished(nsresult aStatus) {
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetable =
do_QueryInterface(mListener);
if (retargetable) {
return retargetable->OnDataFinished(aStatus);
}
return NS_OK;
}
NS_IMETHODIMP
nsDeflateConverter::CheckListenerChain() { return NS_ERROR_NO_INTERFACE; }
NS_IMETHODIMP nsDeflateConverter::OnStopRequest(nsIRequest* aRequest,
nsresult aStatusCode) {
if (!mListener) return NS_ERROR_NOT_INITIALIZED;

Просмотреть файл

@ -8,6 +8,7 @@
#include "nsIStreamConverter.h"
#include "nsCOMPtr.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "zlib.h"
#include "mozilla/Attributes.h"
@ -25,6 +26,7 @@ class nsDeflateConverter final : public nsIStreamConverter {
NS_DECL_ISUPPORTS
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
NS_DECL_NSISTREAMCONVERTER
nsDeflateConverter() : mWrapMode(WRAP_NONE), mOffset(0), mZstream() {

Просмотреть файл

@ -942,6 +942,25 @@ nsBaseChannel::CheckListenerChain() {
return listener->CheckListenerChain();
}
NS_IMETHODIMP
nsBaseChannel::OnDataFinished(nsresult aStatus) {
if (!mListener) {
return NS_ERROR_FAILURE;
}
if (!mAllowThreadRetargeting) {
return NS_ERROR_NOT_IMPLEMENTED;
}
nsCOMPtr<nsIThreadRetargetableStreamListener> listener =
do_QueryInterface(mListener);
if (listener) {
return listener->OnDataFinished(aStatus);
}
return NS_OK;
}
NS_IMETHODIMP nsBaseChannel::GetCanceled(bool* aCanceled) {
*aCanceled = mCanceled;
return NS_OK;

Просмотреть файл

@ -53,7 +53,6 @@ class nsBaseChannel
public nsIAsyncVerifyRedirectCallback,
public mozilla::net::PrivateBrowsingChannel<nsBaseChannel>,
public mozilla::net::NeckoTargetHolder,
protected nsIStreamListener,
protected nsIThreadRetargetableStreamListener {
public:
NS_DECL_ISUPPORTS_INHERITED

Просмотреть файл

@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIStreamListener.idl"
#include "nsIThreadRetargetableStreamListener.idl"
interface nsIRequest;
interface nsIIncrementalStreamLoader;
@ -77,7 +77,7 @@ interface nsIIncrementalStreamLoaderObserver : nsISupports
* XXX define behaviour for sizes >4 GB
*/
[scriptable, uuid(a023b060-ba23-431a-b449-2dd63e220554)]
interface nsIIncrementalStreamLoader : nsIStreamListener
interface nsIIncrementalStreamLoader : nsIThreadRetargetableStreamListener
{
/**
* Initialize this stream loader, and start loading the data.

Просмотреть файл

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIStreamListener.idl"
#include "nsIThreadRetargetableStreamListener.idl"
interface nsIOutputStream;
interface nsIRequestObserver;
@ -13,7 +13,7 @@ interface nsIEventTarget;
* and then forwarded to the real listener.
*/
[scriptable, uuid(62b27fc1-6e8c-4225-8ad0-b9d44252973a)]
interface nsIStreamListenerTee : nsIStreamListener
interface nsIStreamListenerTee : nsIThreadRetargetableStreamListener
{
/**
* Initalize the tee.

Просмотреть файл

@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIStreamListener.idl"
#include "nsIThreadRetargetableStreamListener.idl"
interface nsIRequest;
interface nsIStreamLoader;
@ -50,7 +50,7 @@ interface nsIStreamLoaderObserver : nsISupports
* XXX define behaviour for sizes >4 GB
*/
[scriptable, uuid(323bcff1-7513-4e1f-a541-1c9213c2ed1b)]
interface nsIStreamLoader : nsIStreamListener
interface nsIStreamLoader : nsIThreadRetargetableStreamListener
{
/**
* Initialize this stream loader, and start loading the data.

Просмотреть файл

@ -12,7 +12,7 @@
* To be used by classes which implement nsIStreamListener and whose
* OnDataAvailable callback may be retargeted for delivery off the main thread.
*/
[uuid(fb2304b8-f82f-4433-af68-d874a2ebbdc1)]
[scriptable, uuid(fb2304b8-f82f-4433-af68-d874a2ebbdc1)]
interface nsIThreadRetargetableStreamListener : nsIStreamListener
{
/**

Просмотреть файл

@ -183,3 +183,6 @@ void nsIncrementalStreamLoader::ReleaseData() { mData.clearAndFree(); }
NS_IMETHODIMP
nsIncrementalStreamLoader::CheckListenerChain() { return NS_OK; }
NS_IMETHODIMP
nsIncrementalStreamLoader::OnDataFinished(nsresult aStatus) { return NS_OK; }

Просмотреть файл

@ -14,9 +14,7 @@
class nsIRequest;
class nsIncrementalStreamLoader final
: public nsIIncrementalStreamLoader,
public nsIThreadRetargetableStreamListener {
class nsIncrementalStreamLoader final : public nsIIncrementalStreamLoader {
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIINCREMENTALSTREAMLOADER

Просмотреть файл

@ -134,6 +134,27 @@ nsStreamListenerTee::CheckListenerChain() {
return rv;
}
NS_IMETHODIMP
nsStreamListenerTee::OnDataFinished(nsresult aStatus) {
nsresult rv = NS_OK;
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
do_QueryInterface(mListener, &rv);
if (retargetableListener) {
rv = retargetableListener->OnDataFinished(aStatus);
}
if (NS_FAILED(rv)) {
return rv;
}
if (!mObserver) {
return rv;
}
retargetableListener = do_QueryInterface(mObserver, &rv);
if (retargetableListener) {
rv = retargetableListener->OnDataFinished(aStatus);
}
return rv;
}
NS_IMETHODIMP
nsStreamListenerTee::Init(nsIStreamListener* listener, nsIOutputStream* sink,
nsIRequestObserver* requestObserver) {

Просмотреть файл

@ -17,7 +17,6 @@ namespace mozilla {
namespace net {
class nsStreamListenerTee : public nsIStreamListenerTee,
public nsIThreadRetargetableStreamListener,
public nsIMultiPartChannelListener {
public:
NS_DECL_THREADSAFE_ISUPPORTS

Просмотреть файл

@ -35,5 +35,15 @@ nsStreamListenerWrapper::CheckListenerChain() {
return rv;
}
NS_IMETHODIMP
nsStreamListenerWrapper::OnDataFinished(nsresult aStatus) {
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
do_QueryInterface(mListener);
if (retargetableListener) {
return retargetableListener->OnDataFinished(aStatus);
}
return NS_OK;
}
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -17,8 +17,7 @@ namespace net {
// Wrapper class to make replacement of nsHttpChannel's listener
// from JavaScript possible. It is workaround for bug 433711 and 682305.
class nsStreamListenerWrapper final
: public nsIStreamListener,
public nsIMultiPartChannelListener,
: public nsIMultiPartChannelListener,
public nsIThreadRetargetableStreamListener {
public:
explicit nsStreamListenerWrapper(nsIStreamListener* listener)

Просмотреть файл

@ -133,5 +133,8 @@ void nsStreamLoader::ReleaseData() { mData.clearAndFree(); }
NS_IMETHODIMP
nsStreamLoader::CheckListenerChain() { return NS_OK; }
NS_IMETHODIMP
nsStreamLoader::OnDataFinished(nsresult) { return NS_OK; }
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -17,8 +17,7 @@ class nsIRequest;
namespace mozilla {
namespace net {
class nsStreamLoader final : public nsIStreamLoader,
public nsIThreadRetargetableStreamListener {
class nsStreamLoader final : public nsIStreamLoader {
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSISTREAMLOADER

Просмотреть файл

@ -2888,7 +2888,6 @@ NS_IMETHODIMP
HttpChannelChild::RetargetDeliveryTo(nsISerialEventTarget* aNewTarget) {
LOG(("HttpChannelChild::RetargetDeliveryTo [this=%p, aNewTarget=%p]", this,
aNewTarget));
MOZ_ASSERT(NS_IsMainThread(), "Should be called on main thread only");
MOZ_ASSERT(aNewTarget);

Просмотреть файл

@ -648,6 +648,9 @@ HttpTransactionChild::CheckListenerChain() {
return NS_OK;
}
NS_IMETHODIMP
HttpTransactionChild::OnDataFinished(nsresult aStatus) { return NS_OK; }
NS_IMETHODIMP
HttpTransactionChild::EarlyHint(const nsACString& aValue,
const nsACString& aReferrerPolicy,

Просмотреть файл

@ -32,7 +32,6 @@ class nsProxyInfo;
// manages the real nsHttpTransaction and transaction pump.
//-----------------------------------------------------------------------------
class HttpTransactionChild final : public PHttpTransactionChild,
public nsIStreamListener,
public nsITransportEventSink,
public nsIThrottledInputChannel,
public nsIThreadRetargetableStreamListener,

Просмотреть файл

@ -1194,6 +1194,20 @@ InterceptedHttpChannel::OnDataAvailable(nsIRequest* aRequest,
return mListener->OnDataAvailable(this, aInputStream, aOffset, aCount);
}
NS_IMETHODIMP
InterceptedHttpChannel::OnDataFinished(nsresult aStatus) {
if (mCanceled || !mListener) {
return aStatus;
}
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
do_QueryInterface(mListener);
if (retargetableListener) {
return retargetableListener->OnDataFinished(aStatus);
}
return NS_OK;
}
NS_IMETHODIMP
InterceptedHttpChannel::RetargetDeliveryTo(nsISerialEventTarget* aNewTarget) {
MOZ_ASSERT(NS_IsMainThread());

Просмотреть файл

@ -54,7 +54,6 @@ class InterceptedHttpChannel final
public nsIInterceptedChannel,
public nsICacheInfoChannel,
public nsIAsyncVerifyRedirectCallback,
public nsIStreamListener,
public nsIThreadRetargetableRequest,
public nsIThreadRetargetableStreamListener {
NS_DECL_ISUPPORTS_INHERITED

Просмотреть файл

@ -18,6 +18,7 @@
#include "nsIHttpHeaderVisitor.h"
#include "nsIPrompt.h"
#include "nsISecureBrowserUI.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "nsIWindowWatcher.h"
#include "nsQueryObject.h"
#include "nsIAuthPrompt.h"
@ -116,6 +117,20 @@ ParentChannelListener::OnDataAvailable(nsIRequest* aRequest,
aCount);
}
NS_IMETHODIMP
ParentChannelListener::OnDataFinished(nsresult aStatus) {
if (!mNextListener) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIThreadRetargetableStreamListener> listener =
do_QueryInterface(mNextListener);
if (listener) {
return listener->OnDataFinished(aStatus);
}
return NS_OK;
}
//-----------------------------------------------------------------------------
// ParentChannelListener::nsIMultiPartChannelListener
//-----------------------------------------------------------------------------

Просмотреть файл

@ -27,7 +27,6 @@ namespace net {
}
class ParentChannelListener final : public nsIInterfaceRequestor,
public nsIStreamListener,
public nsIMultiPartChannelListener,
public nsINetworkInterceptController,
public nsIThreadRetargetableStreamListener,

Просмотреть файл

@ -4,6 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIThreadRetargetableStreamListener.h"
#include "nsString.h"
#include "mozilla/Assertions.h"
#include "mozilla/LinkedList.h"
@ -706,6 +707,25 @@ nsCORSListenerProxy::OnDataAvailable(nsIRequest* aRequest,
return listener->OnDataAvailable(aRequest, aInputStream, aOffset, aCount);
}
NS_IMETHODIMP
nsCORSListenerProxy::OnDataFinished(nsresult aStatus) {
nsCOMPtr<nsIStreamListener> listener;
{
MutexAutoLock lock(mMutex);
listener = mOuterListener;
}
if (!listener) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
do_QueryInterface(listener);
if (retargetableListener) {
return retargetableListener->OnDataFinished(aStatus);
}
return NS_OK;
}
void nsCORSListenerProxy::SetInterceptController(
nsINetworkInterceptController* aInterceptController) {
mInterceptController = aInterceptController;

Просмотреть файл

@ -41,8 +41,7 @@ enum class UpdateType {
InternalOrHSTSRedirect
};
class nsCORSListenerProxy final : public nsIStreamListener,
public nsIInterfaceRequestor,
class nsCORSListenerProxy final : public nsIInterfaceRequestor,
public nsIChannelEventSink,
public nsIThreadRetargetableStreamListener {
public:

Просмотреть файл

@ -8404,6 +8404,18 @@ nsHttpChannel::CheckListenerChain() {
return rv;
}
NS_IMETHODIMP
nsHttpChannel::OnDataFinished(nsresult aStatus) {
nsCOMPtr<nsIThreadRetargetableStreamListener> listener =
do_QueryInterface(mListener);
if (listener) {
return listener->OnDataFinished(aStatus);
}
return NS_OK;
}
//-----------------------------------------------------------------------------
// nsHttpChannel::nsITransportEventSink
//-----------------------------------------------------------------------------

Просмотреть файл

@ -63,7 +63,6 @@ using DNSPromise = MozPromise<nsCOMPtr<nsIDNSRecord>, nsresult, false>;
class nsHttpChannel final : public HttpBaseChannel,
public HttpAsyncAborter<nsHttpChannel>,
public nsIStreamListener,
public nsICachingChannel,
public nsICacheEntryOpenCallback,
public nsITransportEventSink,

Просмотреть файл

@ -7,6 +7,7 @@
#include "mozTXTToHTMLConv.h"
#include "mozilla/intl/Segmenter.h"
#include "mozilla/Maybe.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "nsNetUtil.h"
#include "nsUnicharUtils.h"
#include "nsUnicodeProperties.h"
@ -909,7 +910,8 @@ bool mozTXTToHTMLConv::GlyphHit(const char16_t* aInString, int32_t aInLength,
****************************************************************************/
NS_IMPL_ISUPPORTS(mozTXTToHTMLConv, mozITXTToHTMLConv, nsIStreamConverter,
nsIStreamListener, nsIRequestObserver)
nsIThreadRetargetableStreamListener, nsIStreamListener,
nsIRequestObserver)
int32_t mozTXTToHTMLConv::CiteLevelTXT(const char16_t* line,
uint32_t& logLineStart) {
@ -1256,6 +1258,14 @@ mozTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsIInputStream* inStr,
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
mozTXTToHTMLConv::OnDataFinished(nsresult aStatus) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
mozTXTToHTMLConv::CheckListenerChain() { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHODIMP
mozTXTToHTMLConv::OnStartRequest(nsIRequest* request) {
return NS_ERROR_NOT_IMPLEMENTED;

Просмотреть файл

@ -12,6 +12,7 @@
#define _mozTXTToHTMLConv_h__
#include "mozITXTToHTMLConv.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "nsString.h"
#include "nsCOMPtr.h"
@ -30,6 +31,7 @@ class mozTXTToHTMLConv : public mozITXTToHTMLConv {
NS_DECL_MOZITXTTOHTMLCONV
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
NS_DECL_NSISTREAMCONVERTER
/**

Просмотреть файл

@ -8,6 +8,7 @@
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "nsError.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "nsStreamUtils.h"
#include "nsStringStream.h"
#include "nsComponentManagerUtils.h"
@ -730,6 +731,22 @@ nsHTTPCompressConv::CheckListenerChain() {
return listener->CheckListenerChain();
}
NS_IMETHODIMP
nsHTTPCompressConv::OnDataFinished(nsresult aStatus) {
nsCOMPtr<nsIThreadRetargetableStreamListener> listener;
{
MutexAutoLock lock(mMutex);
listener = do_QueryInterface(mListener);
}
if (listener) {
return listener->OnDataFinished(aStatus);
}
return NS_OK;
}
} // namespace net
} // namespace mozilla

Просмотреть файл

@ -41,8 +41,7 @@ namespace net {
class BrotliWrapper;
class nsHTTPCompressConv : public nsIStreamConverter,
public nsICompressConvStats,
public nsIThreadRetargetableStreamListener {
public nsICompressConvStats {
public:
// nsISupports methods
NS_DECL_THREADSAFE_ISUPPORTS

Просмотреть файл

@ -8,6 +8,7 @@
#include "mozilla/Encoding.h"
#include "mozilla/intl/AppDateTimeFormat.h"
#include "mozilla/intl/LocaleService.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "nsNetUtil.h"
#include "netCore.h"
#include "nsStringStream.h"
@ -31,7 +32,8 @@ using mozilla::intl::LocaleService;
using namespace mozilla;
NS_IMPL_ISUPPORTS(nsIndexedToHTML, nsIDirIndexListener, nsIStreamConverter,
nsIRequestObserver, nsIStreamListener)
nsIThreadRetargetableStreamListener, nsIRequestObserver,
nsIStreamListener)
static void AppendNonAsciiToNCR(const nsAString& in, nsCString& out) {
nsAString::const_iterator start, end;
@ -615,6 +617,25 @@ nsIndexedToHTML::OnDataAvailable(nsIRequest* aRequest, nsIInputStream* aInput,
return mParser->OnDataAvailable(aRequest, aInput, aOffset, aCount);
}
NS_IMETHODIMP
nsIndexedToHTML::OnDataFinished(nsresult aStatus) {
nsCOMPtr<nsIThreadRetargetableStreamListener> listener =
do_QueryInterface(mListener);
if (listener) {
return listener->OnDataFinished(aStatus);
}
return NS_OK;
}
NS_IMETHODIMP
nsIndexedToHTML::CheckListenerChain() {
// nsIndexedToHTML does not support OnDataAvailable to run OMT. This class
// should only pass-through OnDataFinished notification.
return NS_ERROR_NO_INTERFACE;
}
static nsresult FormatTime(
const mozilla::intl::DateTimeFormat::StyleBag& aStyleBag,
const PRTime aPrTime, nsAString& aStringOut) {

Просмотреть файл

@ -7,6 +7,7 @@
#define ____nsindexedtohtml___h___
#include "nsCOMPtr.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "nsString.h"
#include "nsIStreamConverter.h"
#include "nsIDirIndexListener.h"
@ -27,6 +28,7 @@ class nsIndexedToHTML : public nsIStreamConverter, public nsIDirIndexListener {
NS_DECL_NSISTREAMCONVERTER
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
NS_DECL_NSIDIRINDEXLISTENER
nsIndexedToHTML() = default;

Просмотреть файл

@ -5,6 +5,7 @@
#include "nsMultiMixedConv.h"
#include "nsIHttpChannel.h"
#include "nsIThreadRetargetableStreamListener.h"
#include "nsNetCID.h"
#include "nsMimeTypes.h"
#include "nsIStringStream.h"
@ -402,7 +403,7 @@ nsPartChannel::GetBaseChannel(nsIChannel** aReturn) {
// nsISupports implementation
NS_IMPL_ISUPPORTS(nsMultiMixedConv, nsIStreamConverter, nsIStreamListener,
nsIRequestObserver)
nsIThreadRetargetableStreamListener, nsIRequestObserver)
// nsIStreamConverter implementation
@ -553,6 +554,12 @@ nsMultiMixedConv::OnDataAvailable(nsIRequest* request, nsIInputStream* inStr,
return NS_FAILED(rv_send) ? rv_send : rv_feed;
}
NS_IMETHODIMP
nsMultiMixedConv::OnDataFinished(nsresult aStatus) { return NS_OK; }
NS_IMETHODIMP
nsMultiMixedConv::CheckListenerChain() { return NS_ERROR_NOT_IMPLEMENTED; }
NS_IMETHODIMP
nsMultiMixedConv::OnStopRequest(nsIRequest* request, nsresult aStatus) {
nsresult rv;

Просмотреть файл

@ -132,6 +132,7 @@ class nsMultiMixedConv : public nsIStreamConverter {
NS_DECL_ISUPPORTS
NS_DECL_NSISTREAMCONVERTER
NS_DECL_NSISTREAMLISTENER
NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
NS_DECL_NSIREQUESTOBSERVER
explicit nsMultiMixedConv();

Просмотреть файл

@ -108,7 +108,8 @@ NS_INTERFACE_MAP_BEGIN(nsUnknownDecoder)
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
NS_INTERFACE_MAP_ENTRY(nsIContentSniffer)
NS_INTERFACE_MAP_ENTRY(nsIThreadRetargetableStreamListener)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIStreamListener)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports,
nsIThreadRetargetableStreamListener)
NS_INTERFACE_MAP_END
// ----
@ -796,6 +797,20 @@ nsUnknownDecoder::CheckListenerChain() {
return listener->CheckListenerChain();
}
NS_IMETHODIMP
nsUnknownDecoder::OnDataFinished(nsresult aStatus) {
nsCOMPtr<nsIThreadRetargetableStreamListener> listener;
{
MutexAutoLock lock(mMutex);
listener = do_QueryInterface(mNextListener);
}
if (listener) {
return listener->OnDataFinished(aStatus);
}
return NS_OK;
}
void nsBinaryDetector::DetermineContentType(nsIRequest* aRequest) {
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(aRequest);
if (!httpChannel) {

Просмотреть файл

@ -22,9 +22,7 @@
} \
}
class nsUnknownDecoder : public nsIStreamConverter,
public nsIContentSniffer,
public nsIThreadRetargetableStreamListener {
class nsUnknownDecoder : public nsIStreamConverter, public nsIContentSniffer {
public:
// nsISupports methods
NS_DECL_ISUPPORTS

Просмотреть файл

@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIStreamListener.idl"
#include "nsIThreadRetargetableStreamListener.idl"
interface nsIChannel;
interface nsIInputStream;
@ -52,7 +52,7 @@ interface nsIInputStream;
*/
[scriptable, uuid(0b6e2c69-5cf5-48b0-9dfd-c95950e2cc7b)]
interface nsIStreamConverter : nsIStreamListener {
interface nsIStreamConverter : nsIThreadRetargetableStreamListener {
/**
* <b>SYNCRONOUS VERSION</b>

Просмотреть файл

@ -1197,6 +1197,18 @@ ChannelWrapper::RequestListener::CheckListenerChain() {
return rv;
}
NS_IMETHODIMP
ChannelWrapper::RequestListener::OnDataFinished(nsresult aStatus) {
MOZ_ASSERT(mOrigStreamListener, "Should have mOrigStreamListener");
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
do_QueryInterface(mOrigStreamListener);
if (retargetableListener) {
return retargetableListener->OnDataFinished(aStatus);
}
return NS_OK;
}
/*****************************************************************************
* Event dispatching
*****************************************************************************/

Просмотреть файл

@ -326,8 +326,7 @@ class ChannelWrapper final : public DOMEventTargetHelper,
// when called for the first time and then cleared on the Resume method.
nsCString mSuspendedMarkerText = VoidCString();
class RequestListener final : public nsIStreamListener,
public nsIMultiPartChannelListener,
class RequestListener final : public nsIMultiPartChannelListener,
public nsIThreadRetargetableStreamListener {
public:
NS_DECL_THREADSAFE_ISUPPORTS

Просмотреть файл

@ -233,6 +233,17 @@ StreamFilterParent::CheckListenerChain() {
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
StreamFilterParent::OnDataFinished(nsresult aStatus) {
nsCOMPtr<nsIThreadRetargetableStreamListener> listener =
do_QueryInterface(mOrigListener);
if (listener) {
return listener->OnDataFinished(aStatus);
}
return NS_OK;
}
/*****************************************************************************
* Error handling
*****************************************************************************/

Просмотреть файл

@ -39,7 +39,6 @@ using namespace mozilla::dom;
using mozilla::ipc::IPCResult;
class StreamFilterParent final : public PStreamFilterParent,
public nsIStreamListener,
public nsIThreadRetargetableStreamListener,
public nsIRequest,
public StreamFilterBase {

Просмотреть файл

@ -204,6 +204,20 @@ nsDocumentOpenInfo::OnDataAvailable(nsIRequest* request, nsIInputStream* inStr,
return rv;
}
NS_IMETHODIMP
nsDocumentOpenInfo::OnDataFinished(nsresult aStatus) {
if (!m_targetStreamListener) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIThreadRetargetableStreamListener> retargetableListener =
do_QueryInterface(m_targetStreamListener);
if (retargetableListener) {
return retargetableListener->OnDataFinished(aStatus);
}
return NS_OK;
}
NS_IMETHODIMP nsDocumentOpenInfo::OnStopRequest(nsIRequest* request,
nsresult aStatus) {
LOG(("[0x%p] nsDocumentOpenInfo::OnStopRequest", this));

Просмотреть файл

@ -63,8 +63,7 @@ class nsURILoader final : public nsIURILoader {
* Each instance remains alive until its target URL has been loaded
* (or aborted).
*/
class nsDocumentOpenInfo : public nsIStreamListener,
public nsIThreadRetargetableStreamListener {
class nsDocumentOpenInfo : public nsIThreadRetargetableStreamListener {
public:
// Real constructor
// aFlags is a combination of the flags on nsIURILoader