Bug 1826206 - Require nsISerialEventTarget for RetargetDeliveryTo, r=necko-reviewers,valentin
This avoids potential issues where multiple OnDataAvailable callbacks or similar could theoretically be called concurrently on different StreamTransportService threads when targeting the STS - these cases will now target a TaskQueue on the STS instead, structurally ensuring serial execution. Differential Revision: https://phabricator.services.mozilla.com/D179984
This commit is contained in:
@@ -23,6 +23,7 @@
|
|||||||
#include "mozilla/dom/WorkerScope.h"
|
#include "mozilla/dom/WorkerScope.h"
|
||||||
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
||||||
#include "mozilla/ScopeExit.h"
|
#include "mozilla/ScopeExit.h"
|
||||||
|
#include "mozilla/TaskQueue.h"
|
||||||
#include "nsComponentManagerUtils.h"
|
#include "nsComponentManagerUtils.h"
|
||||||
#include "nsIFile.h"
|
#include "nsIFile.h"
|
||||||
#include "nsIThreadRetargetableRequest.h"
|
#include "nsIThreadRetargetableRequest.h"
|
||||||
@@ -272,7 +273,7 @@ NS_IMPL_ISUPPORTS(ConsumeBodyDoneObserver, nsIStreamLoaderObserver)
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
/* static */ already_AddRefed<Promise> BodyConsumer::Create(
|
/* static */ already_AddRefed<Promise> BodyConsumer::Create(
|
||||||
nsIGlobalObject* aGlobal, nsIEventTarget* aMainThreadEventTarget,
|
nsIGlobalObject* aGlobal, nsISerialEventTarget* aMainThreadEventTarget,
|
||||||
nsIInputStream* aBodyStream, AbortSignalImpl* aSignalImpl,
|
nsIInputStream* aBodyStream, AbortSignalImpl* aSignalImpl,
|
||||||
ConsumeType aType, const nsACString& aBodyBlobURISpec,
|
ConsumeType aType, const nsACString& aBodyBlobURISpec,
|
||||||
const nsAString& aBodyLocalPath, const nsACString& aBodyMimeType,
|
const nsAString& aBodyLocalPath, const nsACString& aBodyMimeType,
|
||||||
@@ -359,10 +360,11 @@ void BodyConsumer::ReleaseObject() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BodyConsumer::BodyConsumer(
|
BodyConsumer::BodyConsumer(
|
||||||
nsIEventTarget* aMainThreadEventTarget, nsIGlobalObject* aGlobalObject,
|
nsISerialEventTarget* aMainThreadEventTarget,
|
||||||
nsIInputStream* aBodyStream, Promise* aPromise, ConsumeType aType,
|
nsIGlobalObject* aGlobalObject, nsIInputStream* aBodyStream,
|
||||||
const nsACString& aBodyBlobURISpec, const nsAString& aBodyLocalPath,
|
Promise* aPromise, ConsumeType aType, const nsACString& aBodyBlobURISpec,
|
||||||
const nsACString& aBodyMimeType, const nsACString& aMixedCaseMimeType,
|
const nsAString& aBodyLocalPath, const nsACString& aBodyMimeType,
|
||||||
|
const nsACString& aMixedCaseMimeType,
|
||||||
MutableBlobStorage::MutableBlobStorageType aBlobStorageType)
|
MutableBlobStorage::MutableBlobStorageType aBlobStorageType)
|
||||||
: mTargetThread(NS_GetCurrentThread()),
|
: mTargetThread(NS_GetCurrentThread()),
|
||||||
mMainThreadEventTarget(aMainThreadEventTarget),
|
mMainThreadEventTarget(aMainThreadEventTarget),
|
||||||
@@ -575,7 +577,9 @@ void BodyConsumer::BeginConsumeBodyMainThread(ThreadSafeWorkerRef* aWorkerRef) {
|
|||||||
if (rr) {
|
if (rr) {
|
||||||
nsCOMPtr<nsIEventTarget> sts =
|
nsCOMPtr<nsIEventTarget> sts =
|
||||||
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||||
rv = rr->RetargetDeliveryTo(sts);
|
RefPtr<TaskQueue> queue =
|
||||||
|
TaskQueue::Create(sts.forget(), "BodyConsumer STS Delivery Queue");
|
||||||
|
rv = rr->RetargetDeliveryTo(queue);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
NS_WARNING("Retargeting failed");
|
NS_WARNING("Retargeting failed");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class BodyConsumer final : public nsIObserver,
|
|||||||
* @param aRv An ErrorResult.
|
* @param aRv An ErrorResult.
|
||||||
*/
|
*/
|
||||||
static already_AddRefed<Promise> Create(
|
static already_AddRefed<Promise> Create(
|
||||||
nsIGlobalObject* aGlobal, nsIEventTarget* aMainThreadEventTarget,
|
nsIGlobalObject* aGlobal, nsISerialEventTarget* aMainThreadEventTarget,
|
||||||
nsIInputStream* aBodyStream, AbortSignalImpl* aSignalImpl,
|
nsIInputStream* aBodyStream, AbortSignalImpl* aSignalImpl,
|
||||||
ConsumeType aType, const nsACString& aBodyBlobURISpec,
|
ConsumeType aType, const nsACString& aBodyBlobURISpec,
|
||||||
const nsAString& aBodyLocalPath, const nsACString& aBodyMimeType,
|
const nsAString& aBodyLocalPath, const nsACString& aBodyMimeType,
|
||||||
@@ -94,7 +94,7 @@ class BodyConsumer final : public nsIObserver,
|
|||||||
void RunAbortAlgorithm() override;
|
void RunAbortAlgorithm() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BodyConsumer(nsIEventTarget* aMainThreadEventTarget,
|
BodyConsumer(nsISerialEventTarget* aMainThreadEventTarget,
|
||||||
nsIGlobalObject* aGlobalObject, nsIInputStream* aBodyStream,
|
nsIGlobalObject* aGlobalObject, nsIInputStream* aBodyStream,
|
||||||
Promise* aPromise, ConsumeType aType,
|
Promise* aPromise, ConsumeType aType,
|
||||||
const nsACString& aBodyBlobURISpec,
|
const nsACString& aBodyBlobURISpec,
|
||||||
@@ -109,7 +109,7 @@ class BodyConsumer final : public nsIObserver,
|
|||||||
void AssertIsOnTargetThread() const;
|
void AssertIsOnTargetThread() const;
|
||||||
|
|
||||||
nsCOMPtr<nsIThread> mTargetThread;
|
nsCOMPtr<nsIThread> mTargetThread;
|
||||||
nsCOMPtr<nsIEventTarget> mMainThreadEventTarget;
|
nsCOMPtr<nsISerialEventTarget> mMainThreadEventTarget;
|
||||||
|
|
||||||
// This is nullified when the consuming of the body starts.
|
// This is nullified when the consuming of the body starts.
|
||||||
nsCOMPtr<nsIInputStream> mBodyStream;
|
nsCOMPtr<nsIInputStream> mBodyStream;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class EventSourceImpl final : public nsIObserver,
|
|||||||
public nsIChannelEventSink,
|
public nsIChannelEventSink,
|
||||||
public nsIInterfaceRequestor,
|
public nsIInterfaceRequestor,
|
||||||
public nsSupportsWeakReference,
|
public nsSupportsWeakReference,
|
||||||
public nsIEventTarget,
|
public nsISerialEventTarget,
|
||||||
public nsITimerCallback,
|
public nsITimerCallback,
|
||||||
public nsINamed,
|
public nsINamed,
|
||||||
public nsIThreadRetargetableStreamListener {
|
public nsIThreadRetargetableStreamListener {
|
||||||
@@ -364,8 +364,9 @@ class EventSourceImpl final : public nsIObserver,
|
|||||||
NS_IMPL_ISUPPORTS(EventSourceImpl, nsIObserver, nsIStreamListener,
|
NS_IMPL_ISUPPORTS(EventSourceImpl, nsIObserver, nsIStreamListener,
|
||||||
nsIRequestObserver, nsIChannelEventSink,
|
nsIRequestObserver, nsIChannelEventSink,
|
||||||
nsIInterfaceRequestor, nsISupportsWeakReference,
|
nsIInterfaceRequestor, nsISupportsWeakReference,
|
||||||
nsIEventTarget, nsIThreadRetargetableStreamListener,
|
nsISerialEventTarget, nsIEventTarget,
|
||||||
nsITimerCallback, nsINamed)
|
nsIThreadRetargetableStreamListener, nsITimerCallback,
|
||||||
|
nsINamed)
|
||||||
|
|
||||||
EventSourceImpl::EventSourceImpl(EventSource* aEventSource,
|
EventSourceImpl::EventSourceImpl(EventSource* aEventSource,
|
||||||
nsICookieJarSettings* aCookieJarSettings)
|
nsICookieJarSettings* aCookieJarSettings)
|
||||||
@@ -1056,16 +1057,15 @@ nsresult EventSourceImpl::InitChannelAndRequestEventSource(
|
|||||||
|
|
||||||
MOZ_ASSERT_IF(mIsMainThread, aEventTargetAccessAllowed);
|
MOZ_ASSERT_IF(mIsMainThread, aEventTargetAccessAllowed);
|
||||||
|
|
||||||
nsresult rv = aEventTargetAccessAllowed
|
nsresult rv = aEventTargetAccessAllowed ? [this]() {
|
||||||
? [this]() {
|
// We can't call GetEventSource() because we're not
|
||||||
// We can't call GetEventSource() because we're not
|
// allowed to touch the refcount off the worker thread
|
||||||
// allowed to touch the refcount off the worker thread
|
// due to an assertion, event if it would have otherwise
|
||||||
// due to an assertion, event if it would have otherwise
|
// been safe.
|
||||||
// been safe.
|
auto lock = mSharedData.Lock();
|
||||||
auto lock = mSharedData.Lock();
|
return lock->mEventSource->CheckCurrentGlobalCorrectness();
|
||||||
return lock->mEventSource->CheckCurrentGlobalCorrectness();
|
}()
|
||||||
}()
|
: NS_OK;
|
||||||
: NS_OK;
|
|
||||||
if (NS_FAILED(rv) || !isValidScheme) {
|
if (NS_FAILED(rv) || !isValidScheme) {
|
||||||
DispatchFailConnection();
|
DispatchFailConnection();
|
||||||
return NS_ERROR_DOM_SECURITY_ERR;
|
return NS_ERROR_DOM_SECURITY_ERR;
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ class FetchBody : public FetchBodyBase, public AbortFollower {
|
|||||||
bool mBodyUsed;
|
bool mBodyUsed;
|
||||||
|
|
||||||
// The main-thread event target for runnable dispatching.
|
// The main-thread event target for runnable dispatching.
|
||||||
nsCOMPtr<nsIEventTarget> mMainThreadEventTarget;
|
nsCOMPtr<nsISerialEventTarget> mMainThreadEventTarget;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EmptyBody final : public FetchBody<EmptyBody> {
|
class EmptyBody final : public FetchBody<EmptyBody> {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "js/Value.h"
|
#include "js/Value.h"
|
||||||
#include "mozilla/DebugOnly.h"
|
#include "mozilla/DebugOnly.h"
|
||||||
|
#include "mozilla/TaskQueue.h"
|
||||||
#include "mozilla/dom/FetchDriver.h"
|
#include "mozilla/dom/FetchDriver.h"
|
||||||
|
|
||||||
#include "mozilla/dom/ReferrerInfo.h"
|
#include "mozilla/dom/ReferrerInfo.h"
|
||||||
@@ -1236,7 +1237,9 @@ FetchDriver::OnStartRequest(nsIRequest* aRequest) {
|
|||||||
|
|
||||||
// Try to retarget off main thread.
|
// Try to retarget off main thread.
|
||||||
if (nsCOMPtr<nsIThreadRetargetableRequest> rr = do_QueryInterface(aRequest)) {
|
if (nsCOMPtr<nsIThreadRetargetableRequest> rr = do_QueryInterface(aRequest)) {
|
||||||
Unused << NS_WARN_IF(NS_FAILED(rr->RetargetDeliveryTo(sts)));
|
RefPtr<TaskQueue> queue =
|
||||||
|
TaskQueue::Create(sts.forget(), "FetchDriver STS Delivery Queue");
|
||||||
|
Unused << NS_WARN_IF(NS_FAILED(rr->RetargetDeliveryTo(queue)));
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ already_AddRefed<Promise> Blob::ConsumeBody(
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIEventTarget> mainThreadEventTarget;
|
nsCOMPtr<nsISerialEventTarget> mainThreadEventTarget;
|
||||||
if (!NS_IsMainThread()) {
|
if (!NS_IsMainThread()) {
|
||||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||||
MOZ_ASSERT(workerPrivate);
|
MOZ_ASSERT(workerPrivate);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "js/Array.h" // JS::GetArrayLength
|
#include "js/Array.h" // JS::GetArrayLength
|
||||||
#include "js/PropertyAndElement.h" // JS_GetElement
|
#include "js/PropertyAndElement.h" // JS_GetElement
|
||||||
|
#include "mozilla/TaskQueue.h"
|
||||||
#include "mozilla/Unused.h"
|
#include "mozilla/Unused.h"
|
||||||
#include "mozilla/dom/CacheBinding.h"
|
#include "mozilla/dom/CacheBinding.h"
|
||||||
#include "mozilla/dom/cache/CacheStorage.h"
|
#include "mozilla/dom/cache/CacheStorage.h"
|
||||||
@@ -1278,7 +1279,9 @@ void CompareCache::ManageValueResult(JSContext* aCx,
|
|||||||
if (rr) {
|
if (rr) {
|
||||||
nsCOMPtr<nsIEventTarget> sts =
|
nsCOMPtr<nsIEventTarget> sts =
|
||||||
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||||
rv = rr->RetargetDeliveryTo(sts);
|
RefPtr<TaskQueue> queue =
|
||||||
|
TaskQueue::Create(sts.forget(), "CompareCache STS Delivery Queue");
|
||||||
|
rv = rr->RetargetDeliveryTo(queue);
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
mPump = nullptr;
|
mPump = nullptr;
|
||||||
Finish(rv, false);
|
Finish(rv, false);
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class WebSocketImpl final : public nsIInterfaceRequestor,
|
|||||||
public nsIWebSocketListener,
|
public nsIWebSocketListener,
|
||||||
public nsIObserver,
|
public nsIObserver,
|
||||||
public nsIRequest,
|
public nsIRequest,
|
||||||
public nsIEventTarget,
|
public nsISerialEventTarget,
|
||||||
public nsIWebSocketImpl {
|
public nsIWebSocketImpl {
|
||||||
public:
|
public:
|
||||||
NS_DECL_NSIINTERFACEREQUESTOR
|
NS_DECL_NSIINTERFACEREQUESTOR
|
||||||
@@ -255,7 +255,7 @@ class WebSocketImpl final : public nsIInterfaceRequestor,
|
|||||||
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
|
||||||
|
|
||||||
// For dispatching runnables to main thread.
|
// For dispatching runnables to main thread.
|
||||||
nsCOMPtr<nsIEventTarget> mMainThreadEventTarget;
|
nsCOMPtr<nsISerialEventTarget> mMainThreadEventTarget;
|
||||||
|
|
||||||
RefPtr<WebSocketImplProxy> mImplProxy;
|
RefPtr<WebSocketImplProxy> mImplProxy;
|
||||||
|
|
||||||
@@ -294,7 +294,8 @@ WebSocketImplProxy::SendMessage(const nsAString& aMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(WebSocketImpl, nsIInterfaceRequestor, nsIWebSocketListener,
|
NS_IMPL_ISUPPORTS(WebSocketImpl, nsIInterfaceRequestor, nsIWebSocketListener,
|
||||||
nsIObserver, nsIRequest, nsIEventTarget, nsIWebSocketImpl)
|
nsIObserver, nsIRequest, nsIEventTarget, nsISerialEventTarget,
|
||||||
|
nsIWebSocketImpl)
|
||||||
|
|
||||||
class CallDispatchConnectionCloseEvents final : public DiscardableRunnable {
|
class CallDispatchConnectionCloseEvents final : public DiscardableRunnable {
|
||||||
public:
|
public:
|
||||||
@@ -2826,6 +2827,8 @@ NS_IMETHODIMP_(bool)
|
|||||||
WebSocketImpl::IsOnCurrentThreadInfallible() { return IsTargetThread(); }
|
WebSocketImpl::IsOnCurrentThreadInfallible() { return IsTargetThread(); }
|
||||||
|
|
||||||
bool WebSocketImpl::IsTargetThread() const {
|
bool WebSocketImpl::IsTargetThread() const {
|
||||||
|
// FIXME: This should also check if we're on the worker thread. Code using
|
||||||
|
// `IsOnCurrentThread` could easily misbehave here!
|
||||||
return NS_IsMainThread() == mIsMainThread;
|
return NS_IsMainThread() == mIsMainThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3419,7 +3419,7 @@ void WorkerPrivate::AfterProcessNextEvent() {
|
|||||||
MOZ_ASSERT(GetEffectiveEventLoopRecursionDepth());
|
MOZ_ASSERT(GetEffectiveEventLoopRecursionDepth());
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIEventTarget* WorkerPrivate::MainThreadEventTargetForMessaging() {
|
nsISerialEventTarget* WorkerPrivate::MainThreadEventTargetForMessaging() {
|
||||||
return mMainThreadEventTargetForMessaging;
|
return mMainThreadEventTargetForMessaging;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3435,7 +3435,7 @@ nsresult WorkerPrivate::DispatchToMainThreadForMessaging(
|
|||||||
aFlags);
|
aFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIEventTarget* WorkerPrivate::MainThreadEventTarget() {
|
nsISerialEventTarget* WorkerPrivate::MainThreadEventTarget() {
|
||||||
return mMainThreadEventTarget;
|
return mMainThreadEventTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -560,7 +560,7 @@ class WorkerPrivate final
|
|||||||
// Get the event target to use when dispatching to the main thread
|
// Get the event target to use when dispatching to the main thread
|
||||||
// from this Worker thread. This may be the main thread itself or
|
// from this Worker thread. This may be the main thread itself or
|
||||||
// a ThrottledEventQueue to the main thread.
|
// a ThrottledEventQueue to the main thread.
|
||||||
nsIEventTarget* MainThreadEventTargetForMessaging();
|
nsISerialEventTarget* MainThreadEventTargetForMessaging();
|
||||||
|
|
||||||
nsresult DispatchToMainThreadForMessaging(
|
nsresult DispatchToMainThreadForMessaging(
|
||||||
nsIRunnable* aRunnable, uint32_t aFlags = NS_DISPATCH_NORMAL);
|
nsIRunnable* aRunnable, uint32_t aFlags = NS_DISPATCH_NORMAL);
|
||||||
@@ -569,7 +569,7 @@ class WorkerPrivate final
|
|||||||
already_AddRefed<nsIRunnable> aRunnable,
|
already_AddRefed<nsIRunnable> aRunnable,
|
||||||
uint32_t aFlags = NS_DISPATCH_NORMAL);
|
uint32_t aFlags = NS_DISPATCH_NORMAL);
|
||||||
|
|
||||||
nsIEventTarget* MainThreadEventTarget();
|
nsISerialEventTarget* MainThreadEventTarget();
|
||||||
|
|
||||||
nsresult DispatchToMainThread(nsIRunnable* aRunnable,
|
nsresult DispatchToMainThread(nsIRunnable* aRunnable,
|
||||||
uint32_t aFlags = NS_DISPATCH_NORMAL);
|
uint32_t aFlags = NS_DISPATCH_NORMAL);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "mozilla/dom/Response.h"
|
#include "mozilla/dom/Response.h"
|
||||||
#include "mozilla/dom/ServiceWorkerBinding.h" // ServiceWorkerState
|
#include "mozilla/dom/ServiceWorkerBinding.h" // ServiceWorkerState
|
||||||
#include "mozilla/Result.h"
|
#include "mozilla/Result.h"
|
||||||
|
#include "mozilla/TaskQueue.h"
|
||||||
#include "mozilla/UniquePtr.h"
|
#include "mozilla/UniquePtr.h"
|
||||||
#include "mozilla/dom/Document.h"
|
#include "mozilla/dom/Document.h"
|
||||||
#include "mozilla/dom/WorkerScope.h"
|
#include "mozilla/dom/WorkerScope.h"
|
||||||
@@ -477,7 +478,9 @@ void CacheLoadHandler::ResolvedCallback(JSContext* aCx,
|
|||||||
if (rr) {
|
if (rr) {
|
||||||
nsCOMPtr<nsIEventTarget> sts =
|
nsCOMPtr<nsIEventTarget> sts =
|
||||||
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||||
rv = rr->RetargetDeliveryTo(sts);
|
RefPtr<TaskQueue> queue =
|
||||||
|
TaskQueue::Create(sts.forget(), "CacheLoadHandler STS Delivery Queue");
|
||||||
|
rv = rr->RetargetDeliveryTo(queue);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
NS_WARNING("Failed to dispatch the nsIInputStreamPump to a IO thread.");
|
NS_WARNING("Failed to dispatch the nsIInputStreamPump to a IO thread.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class CacheLoadHandler final : public PromiseNativeHandler,
|
|||||||
nsCString mCSPHeaderValue;
|
nsCString mCSPHeaderValue;
|
||||||
nsCString mCSPReportOnlyHeaderValue;
|
nsCString mCSPReportOnlyHeaderValue;
|
||||||
nsCString mReferrerPolicyHeaderValue;
|
nsCString mReferrerPolicyHeaderValue;
|
||||||
nsCOMPtr<nsIEventTarget> mMainThreadEventTarget;
|
nsCOMPtr<nsISerialEventTarget> mMainThreadEventTarget;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "mozilla/dom/worklet/WorkletModuleLoader.h"
|
#include "mozilla/dom/worklet/WorkletModuleLoader.h"
|
||||||
#include "mozilla/CycleCollectedJSContext.h"
|
#include "mozilla/CycleCollectedJSContext.h"
|
||||||
#include "mozilla/ScopeExit.h"
|
#include "mozilla/ScopeExit.h"
|
||||||
|
#include "mozilla/TaskQueue.h"
|
||||||
#include "nsIInputStreamPump.h"
|
#include "nsIInputStreamPump.h"
|
||||||
#include "nsIThreadRetargetableRequest.h"
|
#include "nsIThreadRetargetableRequest.h"
|
||||||
|
|
||||||
@@ -573,7 +574,9 @@ void WorkletScriptHandler::ResolvedCallback(JSContext* aCx,
|
|||||||
if (rr) {
|
if (rr) {
|
||||||
nsCOMPtr<nsIEventTarget> sts =
|
nsCOMPtr<nsIEventTarget> sts =
|
||||||
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||||
rv = rr->RetargetDeliveryTo(sts);
|
RefPtr<TaskQueue> queue = TaskQueue::Create(
|
||||||
|
sts.forget(), "WorkletScriptHandler STS Delivery Queue");
|
||||||
|
rv = rr->RetargetDeliveryTo(queue);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
NS_WARNING("Failed to dispatch the nsIInputStreamPump to a IO thread.");
|
NS_WARNING("Failed to dispatch the nsIInputStreamPump to a IO thread.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,9 +193,9 @@ void DecodePool::SyncRunIfPossible(IDecodingTask* aTask,
|
|||||||
aTask->Run();
|
aTask->Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIEventTarget> DecodePool::GetIOEventTarget() {
|
already_AddRefed<nsISerialEventTarget> DecodePool::GetIOEventTarget() {
|
||||||
MutexAutoLock threadPoolLock(mMutex);
|
MutexAutoLock threadPoolLock(mMutex);
|
||||||
nsCOMPtr<nsIEventTarget> target = mIOThread;
|
nsCOMPtr<nsISerialEventTarget> target = mIOThread;
|
||||||
return target.forget();
|
return target.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,9 +83,9 @@ class DecodePool final : public nsIObserver {
|
|||||||
* who want to deliver data to workers on the DecodePool can use this event
|
* who want to deliver data to workers on the DecodePool can use this event
|
||||||
* target.
|
* target.
|
||||||
*
|
*
|
||||||
* @return An nsIEventTarget interface to the thread pool's I/O thread.
|
* @return An nsISerialEventTarget interface to the thread pool's I/O thread.
|
||||||
*/
|
*/
|
||||||
already_AddRefed<nsIEventTarget> GetIOEventTarget();
|
already_AddRefed<nsISerialEventTarget> GetIOEventTarget();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class DecodePoolWorker;
|
friend class DecodePoolWorker;
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ nsIconChannel::AsyncOpen(nsIStreamListener* aListener) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init our stream pump
|
// Init our stream pump
|
||||||
nsCOMPtr<nsIEventTarget> target =
|
nsCOMPtr<nsISerialEventTarget> target =
|
||||||
nsContentUtils::GetEventTargetByLoadInfo(mLoadInfo, mozilla::TaskCategory::Other);
|
nsContentUtils::GetEventTargetByLoadInfo(mLoadInfo, mozilla::TaskCategory::Other);
|
||||||
rv = mPump->Init(inStream, 0, 0, false, target);
|
rv = mPump->Init(inStream, 0, 0, false, target);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
|
|||||||
@@ -843,7 +843,7 @@ nsresult nsIconChannel::StartAsyncOpen() {
|
|||||||
|
|
||||||
// Use the main thread for the pumped events unless the load info
|
// Use the main thread for the pumped events unless the load info
|
||||||
// specifies otherwise
|
// specifies otherwise
|
||||||
nsCOMPtr<nsIEventTarget> listenerTarget =
|
nsCOMPtr<nsISerialEventTarget> listenerTarget =
|
||||||
nsContentUtils::GetEventTargetByLoadInfo(mLoadInfo,
|
nsContentUtils::GetEventTargetByLoadInfo(mLoadInfo,
|
||||||
mozilla::TaskCategory::Other);
|
mozilla::TaskCategory::Other);
|
||||||
if (!listenerTarget) {
|
if (!listenerTarget) {
|
||||||
|
|||||||
@@ -711,7 +711,7 @@ imgRequest::OnStartRequest(nsIRequest* aRequest) {
|
|||||||
nsresult rv = channel->GetContentType(mimeType);
|
nsresult rv = channel->GetContentType(mimeType);
|
||||||
if (NS_SUCCEEDED(rv) && !mimeType.EqualsLiteral(IMAGE_SVG_XML)) {
|
if (NS_SUCCEEDED(rv) && !mimeType.EqualsLiteral(IMAGE_SVG_XML)) {
|
||||||
// Retarget OnDataAvailable to the DecodePool's IO thread.
|
// Retarget OnDataAvailable to the DecodePool's IO thread.
|
||||||
nsCOMPtr<nsIEventTarget> target =
|
nsCOMPtr<nsISerialEventTarget> target =
|
||||||
DecodePool::Singleton()->GetIOEventTarget();
|
DecodePool::Singleton()->GetIOEventTarget();
|
||||||
rv = retargetable->RetargetDeliveryTo(target);
|
rv = retargetable->RetargetDeliveryTo(target);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "mozilla/AutoRestore.h"
|
#include "mozilla/AutoRestore.h"
|
||||||
#include "mozilla/Preferences.h"
|
#include "mozilla/Preferences.h"
|
||||||
#include "mozilla/StaticPrefs_layout.h"
|
#include "mozilla/StaticPrefs_layout.h"
|
||||||
|
#include "mozilla/TaskQueue.h"
|
||||||
#include "mozilla/Telemetry.h"
|
#include "mozilla/Telemetry.h"
|
||||||
#include "mozilla/Unused.h"
|
#include "mozilla/Unused.h"
|
||||||
#include "FontFaceSet.h"
|
#include "FontFaceSet.h"
|
||||||
@@ -340,7 +341,9 @@ nsFontFaceLoader::OnStartRequest(nsIRequest* aRequest) {
|
|||||||
if (req) {
|
if (req) {
|
||||||
nsCOMPtr<nsIEventTarget> sts =
|
nsCOMPtr<nsIEventTarget> sts =
|
||||||
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
|
||||||
Unused << NS_WARN_IF(NS_FAILED(req->RetargetDeliveryTo(sts)));
|
RefPtr<TaskQueue> queue =
|
||||||
|
TaskQueue::Create(sts.forget(), "nsFontFaceLoader STS Delivery Queue");
|
||||||
|
Unused << NS_WARN_IF(NS_FAILED(req->RetargetDeliveryTo(queue)));
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1324,7 +1324,7 @@ nsJARChannel::OnDataAvailable(nsIRequest* req, nsIInputStream* stream,
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsJARChannel::RetargetDeliveryTo(nsIEventTarget* aEventTarget) {
|
nsJARChannel::RetargetDeliveryTo(nsISerialEventTarget* aEventTarget) {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
nsCOMPtr<nsIThreadRetargetableRequest> request = do_QueryInterface(mRequest);
|
nsCOMPtr<nsIThreadRetargetableRequest> request = do_QueryInterface(mRequest);
|
||||||
@@ -1336,7 +1336,7 @@ nsJARChannel::RetargetDeliveryTo(nsIEventTarget* aEventTarget) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsJARChannel::GetDeliveryTarget(nsIEventTarget** aEventTarget) {
|
nsJARChannel::GetDeliveryTarget(nsISerialEventTarget** aEventTarget) {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
nsCOMPtr<nsIThreadRetargetableRequest> request = do_QueryInterface(mRequest);
|
nsCOMPtr<nsIThreadRetargetableRequest> request = do_QueryInterface(mRequest);
|
||||||
|
|||||||
@@ -488,7 +488,7 @@ nsresult ProxyAutoConfig::ConfigurePAC(const nsACString& aPACURI,
|
|||||||
const nsACString& aPACScriptData,
|
const nsACString& aPACScriptData,
|
||||||
bool aIncludePath,
|
bool aIncludePath,
|
||||||
uint32_t aExtraHeapSize,
|
uint32_t aExtraHeapSize,
|
||||||
nsIEventTarget* aEventTarget) {
|
nsISerialEventTarget* aEventTarget) {
|
||||||
mShutdown = false; // Shutdown needs to be called prior to destruction
|
mShutdown = false; // Shutdown needs to be called prior to destruction
|
||||||
|
|
||||||
mPACURI = aPACURI;
|
mPACURI = aPACURI;
|
||||||
@@ -904,7 +904,7 @@ nsresult RemoteProxyAutoConfig::ConfigurePAC(const nsACString& aPACURI,
|
|||||||
const nsACString& aPACScriptData,
|
const nsACString& aPACScriptData,
|
||||||
bool aIncludePath,
|
bool aIncludePath,
|
||||||
uint32_t aExtraHeapSize,
|
uint32_t aExtraHeapSize,
|
||||||
nsIEventTarget*) {
|
nsISerialEventTarget*) {
|
||||||
Unused << mProxyAutoConfigParent->SendConfigurePAC(
|
Unused << mProxyAutoConfigParent->SendConfigurePAC(
|
||||||
aPACURI, aPACScriptData, aIncludePath, aExtraHeapSize);
|
aPACURI, aPACScriptData, aIncludePath, aExtraHeapSize);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class ProxyAutoConfigBase {
|
|||||||
virtual nsresult ConfigurePAC(const nsACString& aPACURI,
|
virtual nsresult ConfigurePAC(const nsACString& aPACURI,
|
||||||
const nsACString& aPACScriptData,
|
const nsACString& aPACScriptData,
|
||||||
bool aIncludePath, uint32_t aExtraHeapSize,
|
bool aIncludePath, uint32_t aExtraHeapSize,
|
||||||
nsIEventTarget* aEventTarget) = 0;
|
nsISerialEventTarget* aEventTarget) = 0;
|
||||||
virtual void SetThreadLocalIndex(uint32_t index) {}
|
virtual void SetThreadLocalIndex(uint32_t index) {}
|
||||||
virtual void Shutdown() = 0;
|
virtual void Shutdown() = 0;
|
||||||
virtual void GC() = 0;
|
virtual void GC() = 0;
|
||||||
@@ -55,7 +55,7 @@ class ProxyAutoConfig : public ProxyAutoConfigBase {
|
|||||||
nsresult ConfigurePAC(const nsACString& aPACURI,
|
nsresult ConfigurePAC(const nsACString& aPACURI,
|
||||||
const nsACString& aPACScriptData, bool aIncludePath,
|
const nsACString& aPACScriptData, bool aIncludePath,
|
||||||
uint32_t aExtraHeapSize,
|
uint32_t aExtraHeapSize,
|
||||||
nsIEventTarget* aEventTarget) override;
|
nsISerialEventTarget* aEventTarget) override;
|
||||||
void SetThreadLocalIndex(uint32_t index) override;
|
void SetThreadLocalIndex(uint32_t index) override;
|
||||||
void Shutdown() override;
|
void Shutdown() override;
|
||||||
void GC() override;
|
void GC() override;
|
||||||
@@ -125,7 +125,7 @@ class ProxyAutoConfig : public ProxyAutoConfigBase {
|
|||||||
uint32_t mExtraHeapSize{0};
|
uint32_t mExtraHeapSize{0};
|
||||||
nsCString mRunningHost;
|
nsCString mRunningHost;
|
||||||
nsCOMPtr<nsITimer> mTimer;
|
nsCOMPtr<nsITimer> mTimer;
|
||||||
nsCOMPtr<nsIEventTarget> mMainThreadEventTarget;
|
nsCOMPtr<nsISerialEventTarget> mMainThreadEventTarget;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RemoteProxyAutoConfig : public ProxyAutoConfigBase {
|
class RemoteProxyAutoConfig : public ProxyAutoConfigBase {
|
||||||
@@ -137,7 +137,7 @@ class RemoteProxyAutoConfig : public ProxyAutoConfigBase {
|
|||||||
nsresult ConfigurePAC(const nsACString& aPACURI,
|
nsresult ConfigurePAC(const nsACString& aPACURI,
|
||||||
const nsACString& aPACScriptData, bool aIncludePath,
|
const nsACString& aPACScriptData, bool aIncludePath,
|
||||||
uint32_t aExtraHeapSize,
|
uint32_t aExtraHeapSize,
|
||||||
nsIEventTarget* aEventTarget) override;
|
nsISerialEventTarget* aEventTarget) override;
|
||||||
void Shutdown() override;
|
void Shutdown() override;
|
||||||
void GC() override;
|
void GC() override;
|
||||||
void GetProxyForURIWithCallback(
|
void GetProxyForURIWithCallback(
|
||||||
|
|||||||
@@ -203,7 +203,7 @@ nsresult nsBaseChannel::BeginPumpingData() {
|
|||||||
// and especially when we call into the loadgroup. Our caller takes care to
|
// and especially when we call into the loadgroup. Our caller takes care to
|
||||||
// release mPump if we return an error.
|
// release mPump if we return an error.
|
||||||
|
|
||||||
nsCOMPtr<nsIEventTarget> target = GetNeckoTarget();
|
nsCOMPtr<nsISerialEventTarget> target = GetNeckoTarget();
|
||||||
rv = nsInputStreamPump::Create(getter_AddRefs(mPump), stream, 0, 0, true,
|
rv = nsInputStreamPump::Create(getter_AddRefs(mPump), stream, 0, 0, true,
|
||||||
target);
|
target);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
@@ -227,11 +227,9 @@ nsresult nsBaseChannel::BeginPumpingData() {
|
|||||||
mPump->Suspend();
|
mPump->Suspend();
|
||||||
|
|
||||||
RefPtr<nsBaseChannel> self(this);
|
RefPtr<nsBaseChannel> self(this);
|
||||||
nsCOMPtr<nsISerialEventTarget> serialTarget(do_QueryInterface(target));
|
|
||||||
MOZ_ASSERT(serialTarget);
|
|
||||||
|
|
||||||
promise->Then(
|
promise->Then(
|
||||||
serialTarget, __func__,
|
target, __func__,
|
||||||
[self, this](nsresult rv) {
|
[self, this](nsresult rv) {
|
||||||
MOZ_ASSERT(mPump);
|
MOZ_ASSERT(mPump);
|
||||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||||
@@ -897,7 +895,7 @@ nsBaseChannel::OnRedirectVerifyCallback(nsresult result) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBaseChannel::RetargetDeliveryTo(nsIEventTarget* aEventTarget) {
|
nsBaseChannel::RetargetDeliveryTo(nsISerialEventTarget* aEventTarget) {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
NS_ENSURE_TRUE(mRequest, NS_ERROR_NOT_INITIALIZED);
|
NS_ENSURE_TRUE(mRequest, NS_ERROR_NOT_INITIALIZED);
|
||||||
@@ -913,7 +911,7 @@ nsBaseChannel::RetargetDeliveryTo(nsIEventTarget* aEventTarget) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsBaseChannel::GetDeliveryTarget(nsIEventTarget** aEventTarget) {
|
nsBaseChannel::GetDeliveryTarget(nsISerialEventTarget** aEventTarget) {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
NS_ENSURE_TRUE(mRequest, NS_ERROR_NOT_INITIALIZED);
|
NS_ENSURE_TRUE(mRequest, NS_ERROR_NOT_INITIALIZED);
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
#include "nsIRequest.idl"
|
#include "nsIRequest.idl"
|
||||||
|
|
||||||
interface nsIEventTarget;
|
|
||||||
interface nsIInputStream;
|
interface nsIInputStream;
|
||||||
|
interface nsISerialEventTarget;
|
||||||
interface nsIStreamListener;
|
interface nsIStreamListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,7 +51,7 @@ interface nsIInputStreamPump : nsIRequest
|
|||||||
in unsigned long aSegmentSize,
|
in unsigned long aSegmentSize,
|
||||||
in unsigned long aSegmentCount,
|
in unsigned long aSegmentCount,
|
||||||
in boolean aCloseWhenDone,
|
in boolean aCloseWhenDone,
|
||||||
[optional] in nsIEventTarget aMainThreadTarget);
|
[optional] in nsISerialEventTarget aMainThreadTarget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* asyncRead causes the input stream to be read in chunks and delivered
|
* asyncRead causes the input stream to be read in chunks and delivered
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "nsISupports.idl"
|
#include "nsISupports.idl"
|
||||||
|
|
||||||
interface nsIEventTarget;
|
interface nsISerialEventTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nsIThreadRetargetableRequest
|
* nsIThreadRetargetableRequest
|
||||||
@@ -31,7 +31,7 @@ interface nsIThreadRetargetableRequest : nsISupports
|
|||||||
* should be ready to deal with OnDataAvailable on either the main thread or
|
* should be ready to deal with OnDataAvailable on either the main thread or
|
||||||
* the new target thread.
|
* the new target thread.
|
||||||
*/
|
*/
|
||||||
void retargetDeliveryTo(in nsIEventTarget aNewTarget);
|
void retargetDeliveryTo(in nsISerialEventTarget aNewTarget);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the event target where OnDataAvailable events will be dispatched.
|
* Returns the event target where OnDataAvailable events will be dispatched.
|
||||||
@@ -39,5 +39,5 @@ interface nsIThreadRetargetableRequest : nsISupports
|
|||||||
* This is only valid after OnStartRequest has been called. Any time before
|
* This is only valid after OnStartRequest has been called. Any time before
|
||||||
* that point, the value may be changed by `retargetDeliveryTo` calls.
|
* that point, the value may be changed by `retargetDeliveryTo` calls.
|
||||||
*/
|
*/
|
||||||
readonly attribute nsIEventTarget deliveryTarget;
|
readonly attribute nsISerialEventTarget deliveryTarget;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ nsInputStreamPump::nsInputStreamPump() : mOffMainThread(!NS_IsMainThread()) {}
|
|||||||
nsresult nsInputStreamPump::Create(nsInputStreamPump** result,
|
nsresult nsInputStreamPump::Create(nsInputStreamPump** result,
|
||||||
nsIInputStream* stream, uint32_t segsize,
|
nsIInputStream* stream, uint32_t segsize,
|
||||||
uint32_t segcount, bool closeWhenDone,
|
uint32_t segcount, bool closeWhenDone,
|
||||||
nsIEventTarget* mainThreadTarget) {
|
nsISerialEventTarget* mainThreadTarget) {
|
||||||
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
|
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
|
||||||
RefPtr<nsInputStreamPump> pump = new nsInputStreamPump();
|
RefPtr<nsInputStreamPump> pump = new nsInputStreamPump();
|
||||||
if (pump) {
|
if (pump) {
|
||||||
@@ -99,7 +99,7 @@ nsresult nsInputStreamPump::EnsureWaiting() {
|
|||||||
// Ensure OnStateStop is called on the main thread only when this pump is
|
// Ensure OnStateStop is called on the main thread only when this pump is
|
||||||
// created on main thread.
|
// created on main thread.
|
||||||
if (mState == STATE_STOP && !mOffMainThread) {
|
if (mState == STATE_STOP && !mOffMainThread) {
|
||||||
nsCOMPtr<nsIEventTarget> mainThread =
|
nsCOMPtr<nsISerialEventTarget> mainThread =
|
||||||
mLabeledMainThreadTarget
|
mLabeledMainThreadTarget
|
||||||
? mLabeledMainThreadTarget
|
? mLabeledMainThreadTarget
|
||||||
: do_AddRef(mozilla::GetMainThreadSerialEventTarget());
|
: do_AddRef(mozilla::GetMainThreadSerialEventTarget());
|
||||||
@@ -306,7 +306,7 @@ nsInputStreamPump::SetLoadGroup(nsILoadGroup* aLoadGroup) {
|
|||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInputStreamPump::Init(nsIInputStream* stream, uint32_t segsize,
|
nsInputStreamPump::Init(nsIInputStream* stream, uint32_t segsize,
|
||||||
uint32_t segcount, bool closeWhenDone,
|
uint32_t segcount, bool closeWhenDone,
|
||||||
nsIEventTarget* mainThreadTarget) {
|
nsISerialEventTarget* mainThreadTarget) {
|
||||||
// probably we can't be multithread-accessed yet
|
// probably we can't be multithread-accessed yet
|
||||||
RecursiveMutexAutoLock lock(mMutex);
|
RecursiveMutexAutoLock lock(mMutex);
|
||||||
NS_ENSURE_TRUE(mState == STATE_IDLE, NS_ERROR_IN_PROGRESS);
|
NS_ENSURE_TRUE(mState == STATE_IDLE, NS_ERROR_IN_PROGRESS);
|
||||||
@@ -733,7 +733,7 @@ nsresult nsInputStreamPump::CreateBufferedStreamIfNeeded() {
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInputStreamPump::RetargetDeliveryTo(nsIEventTarget* aNewTarget) {
|
nsInputStreamPump::RetargetDeliveryTo(nsISerialEventTarget* aNewTarget) {
|
||||||
RecursiveMutexAutoLock lock(mMutex);
|
RecursiveMutexAutoLock lock(mMutex);
|
||||||
|
|
||||||
NS_ENSURE_ARG(aNewTarget);
|
NS_ENSURE_ARG(aNewTarget);
|
||||||
@@ -777,10 +777,10 @@ nsInputStreamPump::RetargetDeliveryTo(nsIEventTarget* aNewTarget) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsInputStreamPump::GetDeliveryTarget(nsIEventTarget** aNewTarget) {
|
nsInputStreamPump::GetDeliveryTarget(nsISerialEventTarget** aNewTarget) {
|
||||||
RecursiveMutexAutoLock lock(mMutex);
|
RecursiveMutexAutoLock lock(mMutex);
|
||||||
|
|
||||||
nsCOMPtr<nsIEventTarget> target = mTargetThread;
|
nsCOMPtr<nsISerialEventTarget> target = mTargetThread;
|
||||||
target.forget(aNewTarget);
|
target.forget(aNewTarget);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
# include "MainThreadUtils.h"
|
# include "MainThreadUtils.h"
|
||||||
# include "nsIEventTarget.h"
|
# include "nsISerialEventTarget.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class nsIInputStream;
|
class nsIInputStream;
|
||||||
@@ -49,7 +49,7 @@ class nsInputStreamPump final : public nsIInputStreamPump,
|
|||||||
static nsresult Create(nsInputStreamPump** result, nsIInputStream* stream,
|
static nsresult Create(nsInputStreamPump** result, nsIInputStream* stream,
|
||||||
uint32_t segsize = 0, uint32_t segcount = 0,
|
uint32_t segsize = 0, uint32_t segcount = 0,
|
||||||
bool closeWhenDone = false,
|
bool closeWhenDone = false,
|
||||||
nsIEventTarget* mainThreadTarget = nullptr);
|
nsISerialEventTarget* mainThreadTarget = nullptr);
|
||||||
|
|
||||||
using PeekSegmentFun = void (*)(void*, const uint8_t*, uint32_t);
|
using PeekSegmentFun = void (*)(void*, const uint8_t*, uint32_t);
|
||||||
/**
|
/**
|
||||||
@@ -94,8 +94,9 @@ class nsInputStreamPump final : public nsIInputStreamPump,
|
|||||||
// off-MainThread thread), read from that thread and perhaps others (in
|
// off-MainThread thread), read from that thread and perhaps others (in
|
||||||
// RetargetDeliveryTo)
|
// RetargetDeliveryTo)
|
||||||
nsCOMPtr<nsIStreamListener> mListener MOZ_GUARDED_BY(mMutex);
|
nsCOMPtr<nsIStreamListener> mListener MOZ_GUARDED_BY(mMutex);
|
||||||
nsCOMPtr<nsIEventTarget> mTargetThread MOZ_GUARDED_BY(mMutex);
|
nsCOMPtr<nsISerialEventTarget> mTargetThread MOZ_GUARDED_BY(mMutex);
|
||||||
nsCOMPtr<nsIEventTarget> mLabeledMainThreadTarget MOZ_GUARDED_BY(mMutex);
|
nsCOMPtr<nsISerialEventTarget> mLabeledMainThreadTarget
|
||||||
|
MOZ_GUARDED_BY(mMutex);
|
||||||
nsCOMPtr<nsIInputStream> mStream MOZ_GUARDED_BY(mMutex);
|
nsCOMPtr<nsIInputStream> mStream MOZ_GUARDED_BY(mMutex);
|
||||||
// mAsyncStream is written on a single thread (either MainThread or an
|
// mAsyncStream is written on a single thread (either MainThread or an
|
||||||
// off-MainThread thread), and lives from AsyncRead() to OnStateStop().
|
// off-MainThread thread), and lives from AsyncRead() to OnStateStop().
|
||||||
|
|||||||
@@ -857,7 +857,7 @@ nsresult NS_NewInputStreamPump(
|
|||||||
nsIInputStreamPump** aResult, already_AddRefed<nsIInputStream> aStream,
|
nsIInputStreamPump** aResult, already_AddRefed<nsIInputStream> aStream,
|
||||||
uint32_t aSegsize /* = 0 */, uint32_t aSegcount /* = 0 */,
|
uint32_t aSegsize /* = 0 */, uint32_t aSegcount /* = 0 */,
|
||||||
bool aCloseWhenDone /* = false */,
|
bool aCloseWhenDone /* = false */,
|
||||||
nsIEventTarget* aMainThreadTarget /* = nullptr */) {
|
nsISerialEventTarget* aMainThreadTarget /* = nullptr */) {
|
||||||
nsCOMPtr<nsIInputStream> stream = std::move(aStream);
|
nsCOMPtr<nsIInputStream> stream = std::move(aStream);
|
||||||
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class nsIPersistentProperties;
|
|||||||
class nsIProxyInfo;
|
class nsIProxyInfo;
|
||||||
class nsIRandomAccessStream;
|
class nsIRandomAccessStream;
|
||||||
class nsIRequestObserver;
|
class nsIRequestObserver;
|
||||||
|
class nsISerialEventTarget;
|
||||||
class nsIStreamListener;
|
class nsIStreamListener;
|
||||||
class nsIStreamLoader;
|
class nsIStreamLoader;
|
||||||
class nsIStreamLoaderObserver;
|
class nsIStreamLoaderObserver;
|
||||||
@@ -346,11 +347,10 @@ nsresult NS_NewInputStreamChannel(nsIChannel** outChannel, nsIURI* aUri,
|
|||||||
nsContentPolicyType aContentPolicyType,
|
nsContentPolicyType aContentPolicyType,
|
||||||
bool aIsSrcdocChannel = false);
|
bool aIsSrcdocChannel = false);
|
||||||
|
|
||||||
nsresult NS_NewInputStreamPump(nsIInputStreamPump** aResult,
|
nsresult NS_NewInputStreamPump(
|
||||||
already_AddRefed<nsIInputStream> aStream,
|
nsIInputStreamPump** aResult, already_AddRefed<nsIInputStream> aStream,
|
||||||
uint32_t aSegsize = 0, uint32_t aSegcount = 0,
|
uint32_t aSegsize = 0, uint32_t aSegcount = 0, bool aCloseWhenDone = false,
|
||||||
bool aCloseWhenDone = false,
|
nsISerialEventTarget* aMainThreadTarget = nullptr);
|
||||||
nsIEventTarget* aMainThreadTarget = nullptr);
|
|
||||||
|
|
||||||
nsresult NS_NewLoadGroup(nsILoadGroup** result, nsIRequestObserver* obs);
|
nsresult NS_NewLoadGroup(nsILoadGroup** result, nsIRequestObserver* obs);
|
||||||
|
|
||||||
|
|||||||
@@ -271,7 +271,7 @@ class ExecutePACThreadAction final : public Runnable {
|
|||||||
if (mSetupPAC) {
|
if (mSetupPAC) {
|
||||||
mSetupPAC = false;
|
mSetupPAC = false;
|
||||||
|
|
||||||
nsCOMPtr<nsIEventTarget> target = mPACMan->GetNeckoTarget();
|
nsCOMPtr<nsISerialEventTarget> target = mPACMan->GetNeckoTarget();
|
||||||
mPACMan->mPAC->ConfigurePAC(mSetupPACURI, mSetupPACData,
|
mPACMan->mPAC->ConfigurePAC(mSetupPACURI, mSetupPACData,
|
||||||
mPACMan->mIncludePath, mExtraHeapSize,
|
mPACMan->mIncludePath, mExtraHeapSize,
|
||||||
target);
|
target);
|
||||||
|
|||||||
@@ -2813,7 +2813,7 @@ HttpChannelChild::GetIsLastPart(bool* aIsLastPart) {
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HttpChannelChild::RetargetDeliveryTo(nsIEventTarget* aNewTarget) {
|
HttpChannelChild::RetargetDeliveryTo(nsISerialEventTarget* aNewTarget) {
|
||||||
LOG(("HttpChannelChild::RetargetDeliveryTo [this=%p, aNewTarget=%p]", this,
|
LOG(("HttpChannelChild::RetargetDeliveryTo [this=%p, aNewTarget=%p]", this,
|
||||||
aNewTarget));
|
aNewTarget));
|
||||||
|
|
||||||
@@ -2864,10 +2864,10 @@ HttpChannelChild::RetargetDeliveryTo(nsIEventTarget* aNewTarget) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HttpChannelChild::GetDeliveryTarget(nsIEventTarget** aEventTarget) {
|
HttpChannelChild::GetDeliveryTarget(nsISerialEventTarget** aEventTarget) {
|
||||||
MutexAutoLock lock(mEventTargetMutex);
|
MutexAutoLock lock(mEventTargetMutex);
|
||||||
|
|
||||||
nsCOMPtr<nsIEventTarget> target = mODATarget;
|
nsCOMPtr<nsISerialEventTarget> target = mODATarget;
|
||||||
if (!mODATarget) {
|
if (!mODATarget) {
|
||||||
target = GetCurrentSerialEventTarget();
|
target = GetCurrentSerialEventTarget();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ class HttpChannelChild final : public PHttpChannelChild,
|
|||||||
void CleanupBackgroundChannel();
|
void CleanupBackgroundChannel();
|
||||||
|
|
||||||
// Target thread for delivering ODA.
|
// Target thread for delivering ODA.
|
||||||
nsCOMPtr<nsIEventTarget> mODATarget MOZ_GUARDED_BY(mEventTargetMutex);
|
nsCOMPtr<nsISerialEventTarget> mODATarget MOZ_GUARDED_BY(mEventTargetMutex);
|
||||||
// Used to ensure atomicity of mNeckoTarget / mODATarget;
|
// Used to ensure atomicity of mNeckoTarget / mODATarget;
|
||||||
Mutex mEventTargetMutex{"HttpChannelChild::EventTargetMutex"};
|
Mutex mEventTargetMutex{"HttpChannelChild::EventTargetMutex"};
|
||||||
|
|
||||||
|
|||||||
@@ -200,10 +200,10 @@ void HttpTransactionParent::SetSniffedTypeToChannel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
HttpTransactionParent::GetDeliveryTarget(nsIEventTarget** aEventTarget) {
|
HttpTransactionParent::GetDeliveryTarget(nsISerialEventTarget** aEventTarget) {
|
||||||
MutexAutoLock lock(mEventTargetMutex);
|
MutexAutoLock lock(mEventTargetMutex);
|
||||||
|
|
||||||
nsCOMPtr<nsIEventTarget> target = mODATarget;
|
nsCOMPtr<nsISerialEventTarget> target = mODATarget;
|
||||||
if (!mODATarget) {
|
if (!mODATarget) {
|
||||||
target = mTargetThread;
|
target = mTargetThread;
|
||||||
}
|
}
|
||||||
@@ -211,8 +211,8 @@ HttpTransactionParent::GetDeliveryTarget(nsIEventTarget** aEventTarget) {
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIEventTarget> HttpTransactionParent::GetODATarget() {
|
already_AddRefed<nsISerialEventTarget> HttpTransactionParent::GetODATarget() {
|
||||||
nsCOMPtr<nsIEventTarget> target;
|
nsCOMPtr<nsISerialEventTarget> target;
|
||||||
{
|
{
|
||||||
MutexAutoLock lock(mEventTargetMutex);
|
MutexAutoLock lock(mEventTargetMutex);
|
||||||
target = mODATarget ? mODATarget : mTargetThread;
|
target = mODATarget ? mODATarget : mTargetThread;
|
||||||
@@ -225,7 +225,7 @@ already_AddRefed<nsIEventTarget> HttpTransactionParent::GetODATarget() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP HttpTransactionParent::RetargetDeliveryTo(
|
NS_IMETHODIMP HttpTransactionParent::RetargetDeliveryTo(
|
||||||
nsIEventTarget* aEventTarget) {
|
nsISerialEventTarget* aEventTarget) {
|
||||||
LOG(("HttpTransactionParent::RetargetDeliveryTo [this=%p, aTarget=%p]", this,
|
LOG(("HttpTransactionParent::RetargetDeliveryTo [this=%p, aTarget=%p]", this,
|
||||||
aEventTarget));
|
aEventTarget));
|
||||||
|
|
||||||
|
|||||||
@@ -117,14 +117,14 @@ class HttpTransactionParent final : public PHttpTransactionParent,
|
|||||||
void DoNotifyListener();
|
void DoNotifyListener();
|
||||||
void ContinueDoNotifyListener();
|
void ContinueDoNotifyListener();
|
||||||
// Get event target for ODA.
|
// Get event target for ODA.
|
||||||
already_AddRefed<nsIEventTarget> GetODATarget();
|
already_AddRefed<nsISerialEventTarget> GetODATarget();
|
||||||
void CancelOnMainThread(nsresult aRv);
|
void CancelOnMainThread(nsresult aRv);
|
||||||
void HandleAsyncAbort();
|
void HandleAsyncAbort();
|
||||||
|
|
||||||
nsCOMPtr<nsITransportEventSink> mEventsink;
|
nsCOMPtr<nsITransportEventSink> mEventsink;
|
||||||
nsCOMPtr<nsIStreamListener> mChannel;
|
nsCOMPtr<nsIStreamListener> mChannel;
|
||||||
nsCOMPtr<nsIEventTarget> mTargetThread;
|
nsCOMPtr<nsISerialEventTarget> mTargetThread;
|
||||||
nsCOMPtr<nsIEventTarget> mODATarget;
|
nsCOMPtr<nsISerialEventTarget> mODATarget;
|
||||||
Mutex mEventTargetMutex MOZ_UNANNOTATED{
|
Mutex mEventTargetMutex MOZ_UNANNOTATED{
|
||||||
"HttpTransactionParent::EventTargetMutex"};
|
"HttpTransactionParent::EventTargetMutex"};
|
||||||
nsCOMPtr<nsITransportSecurityInfo> mSecurityInfo;
|
nsCOMPtr<nsITransportSecurityInfo> mSecurityInfo;
|
||||||
|
|||||||
@@ -1196,7 +1196,7 @@ InterceptedHttpChannel::OnDataAvailable(nsIRequest* aRequest,
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
InterceptedHttpChannel::RetargetDeliveryTo(nsIEventTarget* aNewTarget) {
|
InterceptedHttpChannel::RetargetDeliveryTo(nsISerialEventTarget* aNewTarget) {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
NS_ENSURE_ARG(aNewTarget);
|
NS_ENSURE_ARG(aNewTarget);
|
||||||
|
|
||||||
@@ -1215,7 +1215,7 @@ InterceptedHttpChannel::RetargetDeliveryTo(nsIEventTarget* aNewTarget) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
InterceptedHttpChannel::GetDeliveryTarget(nsIEventTarget** aEventTarget) {
|
InterceptedHttpChannel::GetDeliveryTarget(nsISerialEventTarget** aEventTarget) {
|
||||||
if (!mPump) {
|
if (!mPump) {
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8148,7 +8148,7 @@ nsHttpChannel::OnDataAvailable(nsIRequest* request, nsIInputStream* input,
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHttpChannel::RetargetDeliveryTo(nsIEventTarget* aNewTarget) {
|
nsHttpChannel::RetargetDeliveryTo(nsISerialEventTarget* aNewTarget) {
|
||||||
MOZ_ASSERT(NS_IsMainThread(), "Should be called on main thread only");
|
MOZ_ASSERT(NS_IsMainThread(), "Should be called on main thread only");
|
||||||
|
|
||||||
NS_ENSURE_ARG(aNewTarget);
|
NS_ENSURE_ARG(aNewTarget);
|
||||||
@@ -8181,7 +8181,7 @@ nsHttpChannel::RetargetDeliveryTo(nsIEventTarget* aNewTarget) {
|
|||||||
|
|
||||||
// If retarget fails for transaction pump, we must restore mCachePump.
|
// If retarget fails for transaction pump, we must restore mCachePump.
|
||||||
if (NS_FAILED(rv) && retargetableCachePump) {
|
if (NS_FAILED(rv) && retargetableCachePump) {
|
||||||
nsCOMPtr<nsIEventTarget> main = GetMainThreadSerialEventTarget();
|
nsCOMPtr<nsISerialEventTarget> main = GetMainThreadSerialEventTarget();
|
||||||
NS_ENSURE_TRUE(main, NS_ERROR_UNEXPECTED);
|
NS_ENSURE_TRUE(main, NS_ERROR_UNEXPECTED);
|
||||||
rv = retargetableCachePump->RetargetDeliveryTo(main);
|
rv = retargetableCachePump->RetargetDeliveryTo(main);
|
||||||
}
|
}
|
||||||
@@ -8190,7 +8190,7 @@ nsHttpChannel::RetargetDeliveryTo(nsIEventTarget* aNewTarget) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsHttpChannel::GetDeliveryTarget(nsIEventTarget** aEventTarget) {
|
nsHttpChannel::GetDeliveryTarget(nsISerialEventTarget** aEventTarget) {
|
||||||
if (mCachePump) {
|
if (mCachePump) {
|
||||||
return mCachePump->GetDeliveryTarget(aEventTarget);
|
return mCachePump->GetDeliveryTarget(aEventTarget);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ BaseWebSocketChannel::~BaseWebSocketChannel() {
|
|||||||
NS_ReleaseOnMainThread("BaseWebSocketChannel::mLoadGroup",
|
NS_ReleaseOnMainThread("BaseWebSocketChannel::mLoadGroup",
|
||||||
mLoadGroup.forget());
|
mLoadGroup.forget());
|
||||||
NS_ReleaseOnMainThread("BaseWebSocketChannel::mLoadInfo", mLoadInfo.forget());
|
NS_ReleaseOnMainThread("BaseWebSocketChannel::mLoadInfo", mLoadInfo.forget());
|
||||||
nsCOMPtr<nsIEventTarget> target;
|
nsCOMPtr<nsISerialEventTarget> target;
|
||||||
{
|
{
|
||||||
auto lock = mTargetThread.Lock();
|
auto lock = mTargetThread.Lock();
|
||||||
target.swap(*lock);
|
target.swap(*lock);
|
||||||
@@ -310,7 +310,7 @@ BaseWebSocketChannel::AllowPort(int32_t port, const char* scheme,
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
BaseWebSocketChannel::RetargetDeliveryTo(nsIEventTarget* aTargetThread) {
|
BaseWebSocketChannel::RetargetDeliveryTo(nsISerialEventTarget* aTargetThread) {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
MOZ_ASSERT(aTargetThread);
|
MOZ_ASSERT(aTargetThread);
|
||||||
MOZ_ASSERT(!mWasOpened, "Should not be called after AsyncOpen!");
|
MOZ_ASSERT(!mWasOpened, "Should not be called after AsyncOpen!");
|
||||||
@@ -324,10 +324,10 @@ BaseWebSocketChannel::RetargetDeliveryTo(nsIEventTarget* aTargetThread) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
BaseWebSocketChannel::GetDeliveryTarget(nsIEventTarget** aTargetThread) {
|
BaseWebSocketChannel::GetDeliveryTarget(nsISerialEventTarget** aTargetThread) {
|
||||||
MOZ_ASSERT(NS_IsMainThread());
|
MOZ_ASSERT(NS_IsMainThread());
|
||||||
|
|
||||||
nsCOMPtr<nsIEventTarget> target = GetTargetThread();
|
nsCOMPtr<nsISerialEventTarget> target = GetTargetThread();
|
||||||
if (!target) {
|
if (!target) {
|
||||||
target = GetCurrentSerialEventTarget();
|
target = GetCurrentSerialEventTarget();
|
||||||
}
|
}
|
||||||
@@ -335,15 +335,15 @@ BaseWebSocketChannel::GetDeliveryTarget(nsIEventTarget** aTargetThread) {
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<nsIEventTarget> BaseWebSocketChannel::GetTargetThread() {
|
already_AddRefed<nsISerialEventTarget> BaseWebSocketChannel::GetTargetThread() {
|
||||||
nsCOMPtr<nsIEventTarget> target;
|
nsCOMPtr<nsISerialEventTarget> target;
|
||||||
auto lock = mTargetThread.Lock();
|
auto lock = mTargetThread.Lock();
|
||||||
target = *lock;
|
target = *lock;
|
||||||
return target.forget();
|
return target.forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseWebSocketChannel::IsOnTargetThread() {
|
bool BaseWebSocketChannel::IsOnTargetThread() {
|
||||||
nsCOMPtr<nsIEventTarget> target = GetTargetThread();
|
nsCOMPtr<nsISerialEventTarget> target = GetTargetThread();
|
||||||
if (!target) {
|
if (!target) {
|
||||||
MOZ_ASSERT(false);
|
MOZ_ASSERT(false);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class BaseWebSocketChannel : public nsIWebSocketChannel,
|
|||||||
virtual void GetEffectiveURL(nsAString& aEffectiveURL) const = 0;
|
virtual void GetEffectiveURL(nsAString& aEffectiveURL) const = 0;
|
||||||
virtual bool IsEncrypted() const = 0;
|
virtual bool IsEncrypted() const = 0;
|
||||||
|
|
||||||
already_AddRefed<nsIEventTarget> GetTargetThread();
|
already_AddRefed<nsISerialEventTarget> GetTargetThread();
|
||||||
bool IsOnTargetThread();
|
bool IsOnTargetThread();
|
||||||
|
|
||||||
class ListenerAndContextContainer final {
|
class ListenerAndContextContainer final {
|
||||||
@@ -107,7 +107,7 @@ class BaseWebSocketChannel : public nsIWebSocketChannel,
|
|||||||
// Used to ensure atomicity of mTargetThread.
|
// Used to ensure atomicity of mTargetThread.
|
||||||
// Set before AsyncOpen via RetargetDeliveryTo or in AsyncOpen, never changed
|
// Set before AsyncOpen via RetargetDeliveryTo or in AsyncOpen, never changed
|
||||||
// after AsyncOpen
|
// after AsyncOpen
|
||||||
DataMutex<nsCOMPtr<nsIEventTarget>> mTargetThread{
|
DataMutex<nsCOMPtr<nsISerialEventTarget>> mTargetThread{
|
||||||
"BaseWebSocketChannel::EventTargetMutex"};
|
"BaseWebSocketChannel::EventTargetMutex"};
|
||||||
|
|
||||||
nsCString mProtocol;
|
nsCString mProtocol;
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ StreamFilterParent::OnStartRequest(nsIRequest* aRequest) {
|
|||||||
// that we get the final delivery target after any retargeting that it may do.
|
// that we get the final delivery target after any retargeting that it may do.
|
||||||
if (nsCOMPtr<nsIThreadRetargetableRequest> req =
|
if (nsCOMPtr<nsIThreadRetargetableRequest> req =
|
||||||
do_QueryInterface(aRequest)) {
|
do_QueryInterface(aRequest)) {
|
||||||
nsCOMPtr<nsIEventTarget> thread;
|
nsCOMPtr<nsISerialEventTarget> thread;
|
||||||
Unused << req->GetDeliveryTarget(getter_AddRefs(thread));
|
Unused << req->GetDeliveryTarget(getter_AddRefs(thread));
|
||||||
if (thread) {
|
if (thread) {
|
||||||
mIOThread = std::move(thread);
|
mIOThread = std::move(thread);
|
||||||
@@ -748,7 +748,7 @@ bool StreamFilterParent::IsActorThread() {
|
|||||||
|
|
||||||
void StreamFilterParent::AssertIsActorThread() { MOZ_ASSERT(IsActorThread()); }
|
void StreamFilterParent::AssertIsActorThread() { MOZ_ASSERT(IsActorThread()); }
|
||||||
|
|
||||||
nsIEventTarget* StreamFilterParent::IOThread() { return mIOThread; }
|
nsISerialEventTarget* StreamFilterParent::IOThread() { return mIOThread; }
|
||||||
|
|
||||||
bool StreamFilterParent::IsIOThread() { return mIOThread->IsOnCurrentThread(); }
|
bool StreamFilterParent::IsIOThread() { return mIOThread->IsOnCurrentThread(); }
|
||||||
|
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class StreamFilterParent final : public PStreamFilterParent,
|
|||||||
|
|
||||||
inline nsIEventTarget* ActorThread();
|
inline nsIEventTarget* ActorThread();
|
||||||
|
|
||||||
inline nsIEventTarget* IOThread();
|
inline nsISerialEventTarget* IOThread();
|
||||||
|
|
||||||
inline bool IsIOThread();
|
inline bool IsIOThread();
|
||||||
|
|
||||||
@@ -166,8 +166,8 @@ class StreamFilterParent final : public PStreamFilterParent,
|
|||||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||||
nsCOMPtr<nsIStreamListener> mOrigListener;
|
nsCOMPtr<nsIStreamListener> mOrigListener;
|
||||||
|
|
||||||
nsCOMPtr<nsIEventTarget> mMainThread;
|
nsCOMPtr<nsISerialEventTarget> mMainThread;
|
||||||
nsCOMPtr<nsIEventTarget> mIOThread;
|
nsCOMPtr<nsISerialEventTarget> mIOThread;
|
||||||
|
|
||||||
RefPtr<net::ChannelEventQueue> mQueue;
|
RefPtr<net::ChannelEventQueue> mQueue;
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class faviconAsyncLoader : public AsyncStatementCallback, public nsICancelable {
|
|||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
|
nsCOMPtr<nsILoadInfo> loadInfo = mChannel->LoadInfo();
|
||||||
nsCOMPtr<nsIEventTarget> target =
|
nsCOMPtr<nsISerialEventTarget> target =
|
||||||
nsContentUtils::GetEventTargetByLoadInfo(loadInfo, TaskCategory::Other);
|
nsContentUtils::GetEventTargetByLoadInfo(loadInfo, TaskCategory::Other);
|
||||||
if (!mData.IsEmpty()) {
|
if (!mData.IsEmpty()) {
|
||||||
nsCOMPtr<nsIInputStream> stream;
|
nsCOMPtr<nsIInputStream> stream;
|
||||||
|
|||||||
Reference in New Issue
Block a user