Bug 1637500 - P2. Rename methods as they are not always dealing with "threads". r=froydnj

Before P1, GetCurrentThreadSerialEventTarget would have always returned the same data as NS_GetCurrentThread, making the comment incorrect Now it will properly return the running TaskQueue if any.

This change of name more clearly exposes what they are doing, as we aren't always dealing with threads directly; but a nsISerialEventTarget

Differential Revision: https://phabricator.services.mozilla.com/D80354
This commit is contained in:
Jean-Yves Avenard 2020-06-23 05:05:36 +00:00
parent 28c38fcc2b
commit 87438519f0
144 changed files with 597 additions and 318 deletions

View File

@ -1405,7 +1405,7 @@ nsDocShell::GetHasTrackingContentBlocked(Promise** aPromise) {
doc->GetContentBlockingEvents();
if (promise) {
promise->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[retPromise](const Document::GetContentBlockingEventsPromise::
ResolveOrRejectValue& aValue) {
if (aValue.IsResolve()) {

View File

@ -1058,7 +1058,7 @@ already_AddRefed<Promise> ChromeUtils::CollectPerfStats(GlobalObject& aGlobal,
PerfStats::CollectPerfStatsJSON();
extPromise->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[promise](const nsCString& aResult) {
promise->MaybeResolve(NS_ConvertUTF8toUTF16(aResult));
},

View File

@ -1523,7 +1523,7 @@ already_AddRefed<mozilla::dom::Promise> Document::AddCertException(
ContentChild* cc = ContentChild::GetSingleton();
MOZ_ASSERT(cc);
cc->SendAddCertException(certSerialized, flags, host, port, aIsTemporary)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
->Then(GetCurrentSerialEventTarget(), __func__,
[promise](const mozilla::MozPromise<
nsresult, mozilla::ipc::ResponseRejectReason,
true>::ResolveOrRejectValue& aValue) {
@ -15769,7 +15769,7 @@ Document::GetContentBlockingEvents() {
}
return wgc->SendGetContentBlockingEvents()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[](const WindowGlobalChild::GetContentBlockingEventsPromise::
ResolveOrRejectValue& aValue) {
if (aValue.IsResolve()) {
@ -15929,7 +15929,7 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
}
self->AutomaticStorageAccessPermissionCanBeGranted()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[p, pr, sapr,
inner](const AutomaticStorageAccessPermissionGrantPromise::
ResolveOrRejectValue& aValue) -> void {
@ -15964,7 +15964,7 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
p->Resolve(choice, __func__);
} else {
sapr->MaybeDelayAutomaticGrants()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[p, choice] { p->Resolve(choice, __func__); },
[p] { p->Reject(false, __func__); });
}
@ -15985,7 +15985,7 @@ already_AddRefed<mozilla::dom::Promise> Document::RequestStorageAccess(
NodePrincipal(), bc, ContentBlockingNotifier::eStorageAccessAPI,
performFinalChecks)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[outer, promise] {
// Step 10. Grant the document access to cookies and store
// that fact for
@ -16020,7 +16020,7 @@ Document::AutomaticStorageAccessPermissionCanBeGranted() {
return cc
->SendAutomaticStorageAccessPermissionCanBeGranted(
IPC::Principal(NodePrincipal()))
->Then(GetCurrentThreadSerialEventTarget(), __func__,
->Then(GetCurrentSerialEventTarget(), __func__,
[](const ContentChild::
AutomaticStorageAccessPermissionCanBeGrantedPromise::
ResolveOrRejectValue& aValue) {

View File

@ -87,7 +87,7 @@ class EncodingCompleteEvent : public CancelableRunnable {
mEncodeCompleteCallback(aEncodeCompleteCallback),
mFailed(false) {
if (!NS_IsMainThread() && IsCurrentThreadRunningWorker()) {
mCreationEventTarget = GetCurrentThreadEventTarget();
mCreationEventTarget = GetCurrentEventTarget();
} else {
mCreationEventTarget = GetMainThreadEventTarget();
}

View File

@ -1511,7 +1511,7 @@ already_AddRefed<Promise> Navigator::GetVRDisplays(ErrorResult& aRv) {
int browserID = browser->ChromeOuterWindowID();
browser->SendIsWindowSupportingWebVR(browserID)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self, p](bool isSupported) {
self->FinishGetVRDisplays(isSupported, p);
},

View File

@ -300,7 +300,7 @@ StructuredCloneHolder::StructuredCloneHolder(
mGlobal(nullptr)
#ifdef DEBUG
,
mCreationEventTarget(GetCurrentThreadEventTarget())
mCreationEventTarget(GetCurrentEventTarget())
#endif
{
}

View File

@ -4206,7 +4206,7 @@ nsDOMWindowUtils::StartCompositionRecording(Promise** aOutPromise) {
} else {
cbc->SendBeginRecording(TimeStamp::Now())
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[promise](const bool& aSuccess) {
if (aSuccess) {
promise->MaybeResolve(true);
@ -4247,7 +4247,7 @@ nsDOMWindowUtils::StopCompositionRecording(bool aWriteToDisk,
promise->MaybeReject(NS_ERROR_UNEXPECTED);
} else if (aWriteToDisk) {
cbc->SendEndRecordingToDisk()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[promise](const bool& aSuccess) {
if (aSuccess) {
promise->MaybeResolveWithUndefined();
@ -4262,7 +4262,7 @@ nsDOMWindowUtils::StopCompositionRecording(bool aWriteToDisk,
});
} else {
cbc->SendEndRecordingToMemory()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[promise](Maybe<CollectedFramesParams>&& aFrames) {
if (!aFrames) {
promise->MaybeRejectWithUnknownError(

View File

@ -108,7 +108,7 @@ void CacheStreamControlChild::OpenStream(const nsID& aId,
const SafeRefPtr<CacheWorkerRef> holder = GetWorkerRefPtr().clonePtr();
SendOpenStream(aId)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[aResolver,
holder = holder.clonePtr()](RefPtr<nsIInputStream>&& aOptionalStream) {
aResolver(nsCOMPtr<nsIInputStream>(std::move(aOptionalStream)));

View File

@ -97,7 +97,7 @@ class Context::QuotaInitRunnable final : public nsIRunnable,
mData(aData),
mTarget(aTarget),
mInitAction(aInitAction),
mInitiatingEventTarget(GetCurrentThreadEventTarget()),
mInitiatingEventTarget(GetCurrentEventTarget()),
mResult(NS_OK),
mState(STATE_INIT),
mCanceled(false) {
@ -469,7 +469,7 @@ class Context::ActionRunnable final : public nsIRunnable,
mTarget(aTarget),
mAction(aAction),
mQuotaInfo(aQuotaInfo),
mInitiatingThread(GetCurrentThreadEventTarget()),
mInitiatingThread(GetCurrentEventTarget()),
mState(STATE_INIT),
mResult(NS_OK),
mExecutingRunOnTarget(false) {
@ -700,7 +700,7 @@ void Context::ThreadsafeHandle::InvalidateAndAllowToClose() {
Context::ThreadsafeHandle::ThreadsafeHandle(SafeRefPtr<Context> aContext)
: mStrongRef(std::move(aContext)),
mWeakRef(mStrongRef.unsafeGetRawPtr()),
mOwningEventTarget(GetCurrentThreadSerialEventTarget()) {}
mOwningEventTarget(GetCurrentSerialEventTarget()) {}
Context::ThreadsafeHandle::~ThreadsafeHandle() {
// Normally we only touch mStrongRef on the owning thread. This is safe,

View File

@ -717,7 +717,7 @@ class Manager::CachePutAllAction final : public DBAction {
MOZ_DIAGNOSTIC_ASSERT(!mConn);
MOZ_DIAGNOSTIC_ASSERT(!mTarget);
mTarget = GetCurrentThreadSerialEventTarget();
mTarget = GetCurrentSerialEventTarget();
MOZ_DIAGNOSTIC_ASSERT(mTarget);
// We should be pre-initialized to expect one async completion. This is

View File

@ -63,7 +63,7 @@ PrincipalVerifier::PrincipalVerifier(Listener* aListener,
: Runnable("dom::cache::PrincipalVerifier"),
mActor(BackgroundParent::GetContentParent(aActor)),
mPrincipalInfo(aPrincipalInfo),
mInitiatingEventTarget(GetCurrentThreadSerialEventTarget()),
mInitiatingEventTarget(GetCurrentSerialEventTarget()),
mResult(NS_OK) {
AssertIsOnBackgroundThread();
MOZ_DIAGNOSTIC_ASSERT(mInitiatingEventTarget);

View File

@ -179,7 +179,7 @@ ReadStream::Inner::Inner(StreamControl* aControl, const nsID& aId,
nsIInputStream* aStream)
: mControl(aControl),
mId(aId),
mOwningEventTarget(GetCurrentThreadSerialEventTarget()),
mOwningEventTarget(GetCurrentSerialEventTarget()),
mState(Open),
mHasEverBeenRead(false),
mAsyncOpenStarted(false),

View File

@ -27,7 +27,7 @@ void ClientHandleOpParent::Init(ClientOpConstructorArgs&& aArgs) {
auto handle = static_cast<ClientHandleParent*>(Manager());
handle->EnsureSource()
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[this, args = std::move(aArgs)](ClientSourceParent* source) mutable {
mSourcePromiseRequestHolder.Complete();
RefPtr<ClientOpPromise> p;
@ -67,7 +67,7 @@ void ClientHandleOpParent::Init(ClientOpConstructorArgs&& aArgs) {
// in ActorDestroy() which ensures neither lambda is called if the
// actor is destroyed before the source operation completes.
p->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[this](const ClientOpResult& aResult) {
mPromiseRequestHolder.Complete();
Unused << PClientHandleOpParent::Send__delete__(this,

View File

@ -25,7 +25,7 @@ void ClientManagerOpParent::DoServiceOp(Method aMethod, Args&&... aArgs) {
// ActorDestroy() which ensures neither lambda is called if the actor
// is destroyed before the source operation completes.
p->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[this](const mozilla::dom::ClientOpResult& aResult) {
mPromiseRequestHolder.Complete();
Unused << PClientManagerOpParent::Send__delete__(this, aResult);

View File

@ -124,7 +124,7 @@ ClientManagerService::ClientManagerService() : mShutdown(false) {
// shutdown at the first sign it has begun. Since we handle normal shutdown
// gracefully we don't really need to block anything here. We just begin
// destroying our IPC actors immediately.
OnShutdown()->Then(GetCurrentThreadSerialEventTarget(), __func__, []() {
OnShutdown()->Then(GetCurrentSerialEventTarget(), __func__, []() {
// Look up the latest service instance, if it exists. This may
// be different from the instance that registered the shutdown
// handler.
@ -356,7 +356,7 @@ class PromiseListHolder final {
RefPtr<ClientOpPromise> GetResultPromise() {
RefPtr<PromiseListHolder> kungFuDeathGrip = this;
return mResultPromise->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[kungFuDeathGrip](const ClientOpPromise::ResolveOrRejectValue& aValue) {
return ClientOpPromise::CreateAndResolveOrReject(aValue, __func__);
});
@ -369,7 +369,7 @@ class PromiseListHolder final {
RefPtr<PromiseListHolder> self(this);
mPromiseList.LastElement()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self](const ClientOpResult& aResult) {
// TODO: This is pretty clunky. Try to figure out a better
// wait for MatchAll() and Claim() to share this code
@ -560,7 +560,7 @@ RefPtr<ClientOpPromise> ClientManagerService::GetInfoAndState(
// rejection ultimately converted to `undefined` in Clients::Get
return source->ExecutionReadyPromise()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self, aArgs]() -> RefPtr<ClientOpPromise> {
ClientSourceParent* source =
self->FindSource(aArgs.id(), aArgs.principalInfo());

View File

@ -310,7 +310,7 @@ void ClientNavigateOpChild::Init(const ClientNavigateOpConstructorArgs& aArgs) {
// failure occurred, though, we may need to fall back to the current thread
// target.
if (!mSerialEventTarget) {
mSerialEventTarget = GetCurrentThreadSerialEventTarget();
mSerialEventTarget = GetCurrentSerialEventTarget();
}
// Capturing `this` is safe here since we clear the mPromiseRequestHolder in

View File

@ -122,7 +122,7 @@ class WebProgressListener final : public nsIWebProgressListener,
const nsID& id = info.ref().Id();
const mozilla::ipc::PrincipalInfo& principal = info.ref().PrincipalInfo();
ClientManager::GetInfoAndState(ClientGetInfoAndStateArgs(id, principal),
GetCurrentThreadSerialEventTarget())
GetCurrentSerialEventTarget())
->ChainTo(mPromise.forget(), __func__);
return NS_OK;
@ -415,7 +415,7 @@ RefPtr<ClientOpPromise> ClientOpenWindow(const ClientOpenWindowArgs& aArgs) {
}
browsingContextReadyPromise->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[argsValidated, promise](const RefPtr<BrowsingContext>& aBC) {
WaitForLoad(argsValidated, aBC, promise);
},

View File

@ -317,7 +317,7 @@ void WebCryptoTask::DispatchWithPromise(Promise* aResultPromise) {
}
// Store calling thread
mOriginalEventTarget = GetCurrentThreadSerialEventTarget();
mOriginalEventTarget = GetCurrentSerialEventTarget();
// If we are running on a worker thread we must hold the worker
// alive while we work on the thread pool. Otherwise the worker

View File

@ -129,7 +129,7 @@ FileReader::FileReader(nsIGlobalObject* aGlobal, WeakWorkerRef* aWorkerRef)
if (NS_IsMainThread()) {
mTarget = aGlobal->EventTargetFor(TaskCategory::Other);
} else {
mTarget = GetCurrentThreadSerialEventTarget();
mTarget = GetCurrentSerialEventTarget();
}
SetDOMStringToNull(mResult);

View File

@ -13,7 +13,7 @@ namespace mozilla {
namespace dom {
FileCreatorParent::FileCreatorParent()
: mBackgroundEventTarget(GetCurrentThreadEventTarget()), mIPCActive(true) {}
: mBackgroundEventTarget(GetCurrentEventTarget()), mIPCActive(true) {}
FileCreatorParent::~FileCreatorParent() = default;

View File

@ -129,7 +129,7 @@ IPCBlobInputStreamChild::IPCBlobInputStreamChild(const nsID& aID,
mID(aID),
mSize(aSize),
mState(eActive),
mOwningEventTarget(GetCurrentThreadSerialEventTarget()) {
mOwningEventTarget(GetCurrentSerialEventTarget()) {
// If we are running in a worker, we need to send a Close() to the parent side
// before the thread is released.
if (!NS_IsMainThread()) {
@ -408,7 +408,7 @@ void IPCBlobInputStreamChild::Migrated() {
mWorkerRef = nullptr;
mOwningEventTarget = GetCurrentThreadSerialEventTarget();
mOwningEventTarget = GetCurrentSerialEventTarget();
MOZ_ASSERT(IPCBlobInputStreamThread::IsOnFileEventTarget(mOwningEventTarget));
// Maybe we have no reasons to keep this actor alive.

View File

@ -335,7 +335,7 @@ class FileHandleOp {
protected:
FileHandleOp(FileHandle* aFileHandle)
: mOwningEventTarget(GetCurrentThreadSerialEventTarget()),
: mOwningEventTarget(GetCurrentSerialEventTarget()),
mFileHandle(aFileHandle)
#ifdef DEBUG
,
@ -608,7 +608,7 @@ nsresult ClampResultCode(nsresult aResultCode) {
******************************************************************************/
FileHandleThreadPool::FileHandleThreadPool()
: mOwningEventTarget(GetCurrentThreadSerialEventTarget()),
: mOwningEventTarget(GetCurrentSerialEventTarget()),
mShutdownRequested(false),
mShutdownComplete(false) {
AssertIsOnBackgroundThread();

View File

@ -80,7 +80,7 @@ class CheckPermissionRunnable final : public Runnable {
mActor(aActor),
mTask(aTask),
mPath(aPath),
mBackgroundEventTarget(GetCurrentThreadEventTarget()) {
mBackgroundEventTarget(GetCurrentEventTarget()) {
AssertIsInMainProcess();
AssertIsOnBackgroundThread();

View File

@ -188,7 +188,7 @@ FileSystemTaskParentBase::FileSystemTaskParentBase(
mErrorValue(NS_OK),
mFileSystem(aFileSystem),
mRequestParent(aParent),
mBackgroundEventTarget(GetCurrentThreadEventTarget()) {
mBackgroundEventTarget(GetCurrentEventTarget()) {
MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!");
MOZ_ASSERT(aFileSystem, "aFileSystem should not be null.");
MOZ_ASSERT(aParent);

View File

@ -45,7 +45,7 @@ GamepadEventChannelParent::GamepadEventChannelParent()
GamepadPlatformService::GetParentService();
MOZ_ASSERT(service);
mBackgroundEventTarget = GetCurrentThreadEventTarget();
mBackgroundEventTarget = GetCurrentEventTarget();
service->AddChannelParent(this);
}

View File

@ -7775,9 +7775,9 @@ RefPtr<GenericPromise> HTMLMediaElement::SetSrcMediaStreamSink(
}
RefPtr<GenericPromise> p =
GenericPromise::All(GetCurrentThreadSerialEventTarget(), promises)
GenericPromise::All(GetCurrentSerialEventTarget(), promises)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[](const nsTArray<bool>&) {
return GenericPromise::CreateAndResolve(true, __func__);
},

View File

@ -822,7 +822,7 @@ class WorkerPermissionChallenge final : public Runnable {
RefPtr<WorkerPermissionChallenge> self(this);
browserChild->SendIndexedDBPermissionRequest(principal)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self](const uint32_t& aPermission) { self->OperationCompleted(); },
[](const mozilla::ipc::ResponseRejectReason) {});
return false;
@ -1516,7 +1516,7 @@ mozilla::ipc::IPCResult BackgroundFactoryRequestChild::RecvPermissionChallenge(
MOZ_ASSERT(browserChild);
browserChild->SendIndexedDBPermissionRequest(principal)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[this](const uint32_t& aPermission) {
this->AssertIsOnOwningThread();
MaybeCollectGarbageOnIPCMessage();

View File

@ -5472,7 +5472,7 @@ class DatabaseOperationBase : public Runnable,
DatabaseOperationBase(const nsID& aBackgroundChildLoggingId,
uint64_t aLoggingSerialNumber)
: Runnable("dom::indexedDB::DatabaseOperationBase"),
mOwningEventTarget(GetCurrentThreadEventTarget()),
mOwningEventTarget(GetCurrentEventTarget()),
mBackgroundChildLoggingId(aBackgroundChildLoggingId),
mLoggingSerialNumber(aLoggingSerialNumber),
mOperationMayProceed(true) {
@ -12852,7 +12852,7 @@ ConnectionPool::ConnectionRunnable::ConnectionRunnable(
DatabaseInfo* aDatabaseInfo)
: Runnable("dom::indexedDB::ConnectionPool::ConnectionRunnable"),
mDatabaseInfo(aDatabaseInfo),
mOwningEventTarget(GetCurrentThreadEventTarget()) {
mOwningEventTarget(GetCurrentEventTarget()) {
AssertIsOnBackgroundThread();
MOZ_ASSERT(aDatabaseInfo);
MOZ_ASSERT(aDatabaseInfo->mConnectionPool);
@ -12994,7 +12994,7 @@ ConnectionPool::FinishCallbackWrapper::FinishCallbackWrapper(
: Runnable("dom::indexedDB::ConnectionPool::FinishCallbackWrapper"),
mConnectionPool(aConnectionPool),
mCallback(aCallback),
mOwningEventTarget(GetCurrentThreadEventTarget()),
mOwningEventTarget(GetCurrentEventTarget()),
mTransactionId(aTransactionId),
mHasRunOnce(false) {
AssertIsOnBackgroundThread();
@ -13663,7 +13663,7 @@ Database::Database(SafeRefPtr<Factory> aFactory,
mPersistenceType(mMetadata->mCommonMetadata.persistenceType()),
mFileHandleDisabled(aFileHandleDisabled),
mChromeWriteAccessAllowed(aChromeWriteAccessAllowed),
mBackgroundThread(GetCurrentThreadEventTarget())
mBackgroundThread(GetCurrentEventTarget())
#ifdef DEBUG
,
mAllBlobsUnmapped(false)
@ -17453,7 +17453,7 @@ void QuotaClient::StartIdleMaintenance() {
AssertIsOnBackgroundThread();
MOZ_ASSERT(!mShutdownRequested);
mBackgroundThread = GetCurrentThreadEventTarget();
mBackgroundThread = GetCurrentEventTarget();
mMaintenanceQueue.EmplaceBack(MakeRefPtr<Maintenance>(this));
ProcessMaintenanceQueue();
@ -17747,7 +17747,7 @@ void QuotaClient::ProcessMaintenanceQueue() {
DeleteFilesRunnable::DeleteFilesRunnable(SafeRefPtr<FileManager> aFileManager,
nsTArray<int64_t>&& aFileIds)
: Runnable("dom::indexeddb::DeleteFilesRunnable"),
mOwningEventTarget(GetCurrentThreadEventTarget()),
mOwningEventTarget(GetCurrentEventTarget()),
mFileManager(std::move(aFileManager)),
mFileIds(std::move(aFileIds)),
mState(State_Initial) {}

View File

@ -265,7 +265,7 @@ Result<RefPtr<IDBFactory>, nsresult> IDBFactory::CreateInternal(
auto factory = MakeRefPtr<IDBFactory>(IDBFactoryGuard{});
factory->mPrincipalInfo = std::move(aPrincipalInfo);
factory->mGlobal = aGlobal;
factory->mEventTarget = GetCurrentThreadSerialEventTarget();
factory->mEventTarget = GetCurrentSerialEventTarget();
factory->mInnerWindowID = aInnerWindowID;
return factory;

View File

@ -3865,7 +3865,7 @@ BrowserChild::DoesWindowSupportProtectedMedia() {
// the result and use that for future calls.
return SendIsWindowSupportingProtectedMedia(ChromeOuterWindowID())
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self](bool isSupported) {
// If a result was cached while this check was inflight, ensure the
// results match.

View File

@ -1079,7 +1079,7 @@ RefPtr<ContentParent::LaunchPromise> ContentParent::WaitForLaunchAsync(
// against whoever launched it (and whoever else is already racing). Once
// the race is complete, the winner will finish the initialization.
return mSubprocess->WhenProcessHandleReady()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
// On resolve.
[self = RefPtr{this}, aPriority]() {
if (self->IsLaunching()) {
@ -2435,7 +2435,7 @@ RefPtr<ContentParent::LaunchPromise> ContentParent::LaunchSubprocessAsync(
mLaunchYieldTS = TimeStamp::Now();
return ready->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self, aInitialPriority](
const ProcessHandlePromise::ResolveOrRejectValue& aValue) {
if (aValue.IsResolve() &&
@ -3875,7 +3875,7 @@ mozilla::ipc::IPCResult ContentParent::RecvInitStreamFilter(
InitStreamFilterResolver&& aResolver) {
extensions::StreamFilterParent::Create(this, aChannelId, aAddonId)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[aResolver](mozilla::ipc::Endpoint<PStreamFilterChild>&& aEndpoint) {
aResolver(std::move(aEndpoint));
},
@ -6057,7 +6057,7 @@ ContentParent::RecvStorageAccessPermissionGrantedForOrigin(
aTopLevelWindowId, aParentContext.get_canonical(), aTrackingPrincipal,
aTrackingOrigin, aAllowMode)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[aResolver = std::move(aResolver)](
ContentBlocking::ParentAccessGrantPromise::ResolveOrRejectValue&&
aValue) {
@ -6082,7 +6082,7 @@ mozilla::ipc::IPCResult ContentParent::RecvCompleteAllowAccessFor(
ContentBlocking::CompleteAllowAccessFor(
aParentContext.get_canonical(), aTopLevelWindowId, aTrackingPrincipal,
aTrackingOrigin, aCookieBehavior, aReason, nullptr)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
->Then(GetCurrentSerialEventTarget(), __func__,
[aResolver = std::move(aResolver)](
ContentBlocking::StorageAccessPermissionGrantPromise::
ResolveOrRejectValue&& aValue) {

View File

@ -335,7 +335,7 @@ void PreallocatedProcessManagerImpl::AllocateNow() {
mLaunchInProgress = true;
ContentParent::PreallocateProcess()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self, this](const RefPtr<ContentParent>& process) {
mLaunchInProgress = false;

View File

@ -1355,7 +1355,7 @@ class DatastoreOperationBase : public Runnable {
protected:
DatastoreOperationBase()
: Runnable("dom::DatastoreOperationBase"),
mOwningEventTarget(GetCurrentThreadEventTarget()),
mOwningEventTarget(GetCurrentEventTarget()),
mResultCode(NS_OK),
mMayProceedOnNonOwningThread(true),
mMayProceed(true) {}

View File

@ -157,7 +157,7 @@ class RequestHelper final : public Runnable, public LSRequestChildCallback {
RequestHelper(LSObject* aObject, const LSRequestParams& aParams)
: Runnable("dom::RequestHelper"),
mObject(aObject),
mOwningEventTarget(GetCurrentThreadEventTarget()),
mOwningEventTarget(GetCurrentEventTarget()),
mActor(nullptr),
mParams(aParams),
mResultCode(NS_OK),

View File

@ -64,7 +64,7 @@ class AsyncRequestHelper final : public Runnable,
const LSRequestParams& aParams)
: Runnable("dom::LocalStorageManager2::AsyncRequestHelper"),
mManager(aManager),
mOwningEventTarget(GetCurrentThreadEventTarget()),
mOwningEventTarget(GetCurrentEventTarget()),
mActor(nullptr),
mPromise(aPromise),
mParams(aParams),

View File

@ -66,7 +66,7 @@ already_AddRefed<Promise> MediaDevices::GetUserMedia(
MediaManager::Get()
->GetUserMedia(GetOwner(), aConstraints, aCallerType)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[this, self, p](RefPtr<DOMMediaStream>&& aStream) {
if (!GetWindowIfCurrent()) {
return; // Leave Promise pending after navigation by design.
@ -107,7 +107,7 @@ already_AddRefed<Promise> MediaDevices::EnumerateDevices(CallerType aCallerType,
MediaManager::Get()
->EnumerateDevices(GetOwner(), aCallerType)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[this, self,
p](RefPtr<MediaManager::MediaDeviceSetRefCnt>&& aDevices) {
nsPIDOMWindowInner* window = GetWindowIfCurrent();
@ -165,7 +165,7 @@ already_AddRefed<Promise> MediaDevices::GetDisplayMedia(
MediaManager::Get()
->GetDisplayMedia(GetOwner(), aConstraints, aCallerType)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[this, self, p](RefPtr<DOMMediaStream>&& aStream) {
if (!GetWindowIfCurrent()) {
return; // leave promise pending after navigation.

View File

@ -1340,7 +1340,7 @@ class GetUserMediaStreamRunnable : public Runnable {
// Call GetPrincipalKey again, this time w/persist = true, to promote
// deviceIds to persistent, in case they're not already. Fire'n'forget.
media::GetPrincipalKey(mPrincipalInfo, true)
->Then(GetCurrentThreadSerialEventTarget(), __func__,
->Then(GetCurrentSerialEventTarget(), __func__,
[](const media::PrincipalKeyPromise::ResolveOrRejectValue&
aValue) {
if (aValue.IsReject()) {
@ -2207,7 +2207,7 @@ void MediaManager::DeviceListChanged() {
MediaSinkEnum::Speaker, DeviceEnumerationType::Normal,
DeviceEnumerationType::Normal, false, devices)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self = RefPtr<MediaManager>(this), this, devices](bool) {
if (!MediaManager::GetIfExists()) {
return;
@ -2687,7 +2687,7 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
MediaSinkEnum::Other, videoEnumerationType,
audioEnumerationType, true, devices)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self, windowID, c, windowListener, isChrome, devices](bool) {
LOG("GetUserMedia: post enumeration promise success callback "
"starting");
@ -2712,7 +2712,7 @@ RefPtr<MediaManager::StreamPromise> MediaManager::GetUserMedia(
__func__);
})
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self, windowID, c, windowListener, sourceListener, askPermission,
prefs, isSecure, isHandlingUserInput, callID, principalInfo,
isChrome, devices,
@ -3232,7 +3232,7 @@ RefPtr<MediaManager::DevicesPromise> MediaManager::EnumerateDevices(
videoEnumerationType, audioEnumerationType, false,
devices)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self = RefPtr<MediaManager>(this), this, windowListener,
sourceListener, devices](bool) {
if (!IsWindowListenerStillActive(windowListener)) {
@ -3319,7 +3319,7 @@ RefPtr<SinkInfoPromise> MediaManager::GetSinkDevice(nsPIDOMWindowInner* aWindow,
DeviceEnumerationType::Normal,
DeviceEnumerationType::Normal, true, devices)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[aDeviceId, isSecure, devices](bool) {
for (RefPtr<MediaDevice>& device : *devices) {
if (aDeviceId.IsEmpty() && device->mSinkInfo->Preferred()) {

View File

@ -99,10 +99,9 @@ class MediaRecorderReporter final : public nsIMemoryReporter {
nsCOMPtr<nsIHandleReportCallback> handleReport = aHandleReport;
nsCOMPtr<nsISupports> data = aData;
MediaRecorder::SizeOfPromise::All(GetCurrentThreadSerialEventTarget(),
promises)
MediaRecorder::SizeOfPromise::All(GetCurrentSerialEventTarget(), promises)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[handleReport, data](const nsTArray<size_t>& sizes) {
nsCOMPtr<nsIMemoryReporterManager> manager =
do_GetService("@mozilla.org/memory-reporter-manager;1");
@ -2055,9 +2054,9 @@ RefPtr<MediaRecorder::SizeOfPromise> MediaRecorder::SizeOfExcludingThis(
promises.AppendElement(session->SizeOfExcludingThis(aMallocSizeOf));
}
SizeOfPromise::All(GetCurrentThreadSerialEventTarget(), promises)
SizeOfPromise::All(GetCurrentSerialEventTarget(), promises)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[holder](const nsTArray<size_t>& sizes) {
size_t total = 0;
for (const size_t& size : sizes) {

View File

@ -361,7 +361,7 @@ already_AddRefed<Promise> MediaStreamTrack::ApplyConstraints(
GetSource()
.ApplyConstraints(aConstraints, aCallerType)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[this, self, promise, aConstraints](bool aDummy) {
if (!mWindow || !mWindow->IsCurrentInnerWindow()) {
return; // Leave Promise pending after navigation by design.

View File

@ -163,7 +163,7 @@ void MediaKeySystemAccessManager::CheckDoesWindowSupportProtectedMedia(
MKSAM_LOG_DEBUG(
"Checking with browser if this window supports protected media.");
browser->DoesWindowSupportProtectedMedia()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self, request = std::move(aRequest)](
const BrowserChild::IsWindowSupportingProtectedMediaPromise::
ResolveOrRejectValue& value) mutable {
@ -271,7 +271,7 @@ void MediaKeySystemAccessManager::CheckDoesAppAllowProtectedMedia(
RefPtr<MediaKeySystemAccessPermissionRequest::RequestPromise> p =
appApprovalRequest->GetPromise();
p->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
// Allow callback
[this,
self = RefPtr<MediaKeySystemAccessManager>(this)](bool aRequestResult) {

View File

@ -17,8 +17,7 @@ class DriftCompensatorTest : public ::testing::Test {
DriftCompensatorTest()
: mStart(TimeStamp::Now()),
mComp(MakeRefPtr<DriftCompensator>(GetCurrentThreadEventTarget(),
mRate)) {
mComp(MakeRefPtr<DriftCompensator>(GetCurrentEventTarget(), mRate)) {
mComp->NotifyAudioStart(mStart);
// NotifyAudioStart dispatched a runnable to update the audio mStart time on
// the video thread. Because this is a test, the video thread is the current

View File

@ -26,14 +26,14 @@ TEST(TestKeyValueStorage, BasicPutGet)
kvs->Put(name, key, value)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[&](bool) { return kvs->Get(name, key); },
[](nsresult rv) {
EXPECT_TRUE(false) << "Put promise has been rejected";
return KeyValueStorage::GetPromise::CreateAndReject(rv, __func__);
})
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[&](int32_t aValue) {
EXPECT_EQ(aValue, value) << "Values are the same";
mon.SetFinished();
@ -56,7 +56,7 @@ TEST(TestKeyValueStorage, GetNonExistedKey)
GMPTestMonitor mon;
kvs->Get(name, key)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[&mon](int32_t aValue) {
EXPECT_EQ(aValue, -1) << "When key does not exist return -1";
mon.SetFinished();
@ -81,21 +81,21 @@ TEST(TestKeyValueStorage, Clear)
kvs->Put(name, key, value)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[&](bool) { return kvs->Clear(name); },
[](nsresult rv) {
EXPECT_TRUE(false) << "Put promise has been rejected";
return GenericPromise::CreateAndReject(rv, __func__);
})
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[&](bool) { return kvs->Get(name, key); },
[](nsresult rv) {
EXPECT_TRUE(false) << "Clear promise has been rejected";
return KeyValueStorage::GetPromise::CreateAndReject(rv, __func__);
})
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[&](int32_t aValue) {
EXPECT_EQ(aValue, -1) << "After clear the key does not exist";
mon.SetFinished();

View File

@ -36,7 +36,7 @@ struct InitParam {
class MockDriftCompensator : public DriftCompensator {
public:
MockDriftCompensator()
: DriftCompensator(GetCurrentThreadEventTarget(), VIDEO_TRACK_RATE) {
: DriftCompensator(GetCurrentEventTarget(), VIDEO_TRACK_RATE) {
ON_CALL(*this, GetVideoTime(_, _))
.WillByDefault(Invoke([](TimeStamp, TimeStamp t) { return t; }));
}

View File

@ -71,7 +71,7 @@ IPCResult BenchmarkStorageParent::RecvPut(const nsCString& aDbName,
// then to store the new aggregated value.
mStorage->Get(aDbName, aKey)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[storage = mStorage, aDbName, aKey, aValue](int32_t aResult) {
int32_t window = 0;
int32_t average = 0;
@ -97,7 +97,7 @@ IPCResult BenchmarkStorageParent::RecvGet(const nsCString& aDbName,
GetResolver&& aResolve) {
mStorage->Get(aDbName, aKey)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[aResolve](int32_t aResult) {
int32_t window = 0; // not used
aResolve(aResult < 0 ? -1 : ParseStoredValue(aResult, window));
@ -111,11 +111,11 @@ IPCResult BenchmarkStorageParent::RecvCheckVersion(const nsCString& aDbName,
int32_t aVersion) {
mStorage->Get(aDbName, NS_LITERAL_CSTRING("Version"))
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[storage = mStorage, aDbName, aVersion](int32_t aResult) {
if (aVersion != aResult) {
storage->Clear(aDbName)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[storage, aDbName, aVersion](bool) {
storage->Put(aDbName, NS_LITERAL_CSTRING("Version"),
aVersion);

View File

@ -71,7 +71,7 @@ RefPtr<BenchmarkScorePromise> DecoderBenchmark::Get(
const nsCString name(aDecoderName);
const nsCString key(aKey);
return BenchmarkStorageChild::Instance()->SendGet(name, key)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[](int32_t aResult) {
return BenchmarkScorePromise::CreateAndResolve(aResult, __func__);
},

View File

@ -134,7 +134,7 @@ RefPtr<GenericPromise> KeyValueStorage::Put(const nsACString& aName,
RefPtr<KeyValueStorage> self = this;
const nsCString key(aKey);
return Init()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self, key, aValue](bool) { return self->Put(key, aValue); },
[](nsresult rv) {
return GenericPromise::CreateAndReject(rv, __func__);
@ -196,7 +196,7 @@ RefPtr<KeyValueStorage::GetPromise> KeyValueStorage::Get(
RefPtr<KeyValueStorage> self = this;
const nsCString key(aKey);
return Init()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self, key](bool) { return self->Get(key); },
[](nsresult rv) {
return KeyValueStorage::GetPromise::CreateAndReject(rv, __func__);
@ -223,7 +223,7 @@ RefPtr<GenericPromise> KeyValueStorage::Clear(const nsACString& aName) {
mDatabaseName = aName;
RefPtr<KeyValueStorage> self = this;
return Init()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self](bool) { return self->Clear(); },
[](nsresult rv) {
return GenericPromise::CreateAndReject(rv, __func__);

View File

@ -1079,7 +1079,7 @@ CamerasParent::CamerasParent()
sThreadMonitor = new Monitor("CamerasParent::sThreadMonitor");
}
mPBackgroundEventTarget = GetCurrentThreadSerialEventTarget();
mPBackgroundEventTarget = GetCurrentSerialEventTarget();
MOZ_ASSERT(mPBackgroundEventTarget != nullptr,
"GetCurrentThreadEventTarget failed");

View File

@ -454,7 +454,7 @@ mozilla::ipc::IPCResult Parent<Super>::RecvGetPrincipalKey(
return PrincipalKeyPromise::CreateAndResolve(result, __func__);
})
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[aResolve](const PrincipalKeyPromise::ResolveOrRejectValue& aValue) {
if (aValue.IsReject()) {
aResolve(NS_LITERAL_CSTRING(""));

View File

@ -738,7 +738,7 @@ nsISerialEventTarget* AudioContext::GetMainThread() const {
return window->AsGlobal()->EventTargetFor(TaskCategory::Other);
}
return GetCurrentThreadSerialEventTarget();
return GetCurrentSerialEventTarget();
}
void AudioContext::DisconnectFromOwner() {

View File

@ -511,7 +511,7 @@ void SpeechRecognition::StopRecordingAndRecognize(SpeechEvent* aEvent) {
// This will run SoundEnd on the service just before StopRecording begins
// shutting the encode thread down.
mSpeechListener->mRemovedPromise->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[service = mRecognitionService] { service->SoundEnd(); });
StopRecording();
@ -580,7 +580,7 @@ void SpeechRecognition::AbortSilently(SpeechEvent* aEvent) {
// This will run Abort on the service just before StopRecording begins
// shutting the encode thread down.
mSpeechListener->mRemovedPromise->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[service = mRecognitionService] { service->Abort(); });
} else {
// Recording hasn't started yet. We can just call Abort().
@ -589,7 +589,7 @@ void SpeechRecognition::AbortSilently(SpeechEvent* aEvent) {
}
StopRecording()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self = RefPtr<SpeechRecognition>(this), this] { ResetAndEnd(); });
SetState(STATE_ABORTING);
@ -661,7 +661,7 @@ RefPtr<GenericNonExclusivePromise> SpeechRecognition::StopRecording() {
mStopRecordingPromise =
mSpeechListener->mRemovedPromise
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self = RefPtr<SpeechRecognition>(this), this] {
SR_LOG("Shutting down encoding thread");
return mEncodeTaskQueue->BeginShutdown();
@ -671,7 +671,7 @@ RefPtr<GenericNonExclusivePromise> SpeechRecognition::StopRecording() {
return ShutdownPromise::CreateAndResolve(false, __func__);
})
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self = RefPtr<SpeechRecognition>(this), this] {
RefPtr<nsIAsyncShutdownClient> shutdown =
media::GetShutdownBarrier();
@ -817,7 +817,7 @@ void SpeechRecognition::Start(const Optional<NonNull<DOMMediaStream>>& aStream,
MediaManager::Get()
->GetUserMedia(GetOwner(), constraints, aCallerType)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[this, self,
generation = mStreamGeneration](RefPtr<DOMMediaStream>&& aStream) {
nsTArray<RefPtr<AudioStreamTrack>> tracks;

View File

@ -17,7 +17,7 @@ SpeechTrackListener::SpeechTrackListener(SpeechRecognition* aRecognition)
mRemovedPromise(
mRemovedHolder.Ensure("SpeechTrackListener::mRemovedPromise")) {
MOZ_ASSERT(NS_IsMainThread());
mRemovedPromise->Then(GetCurrentThreadSerialEventTarget(), __func__,
mRemovedPromise->Then(GetCurrentSerialEventTarget(), __func__,
[self = RefPtr<SpeechTrackListener>(this), this] {
mRecognition = nullptr;
});

View File

@ -215,7 +215,7 @@ static void CheckSTSThread() {
// should be done there.
mozilla::ipc::IPCResult UDPSocketParent::RecvConnect(
const UDPAddressInfo& aAddressInfo) {
nsCOMPtr<nsIEventTarget> target = GetCurrentThreadEventTarget();
nsCOMPtr<nsIEventTarget> target = GetCurrentEventTarget();
Unused << NS_WARN_IF(NS_FAILED(GetSTSThread()->Dispatch(
WrapRunnable(RefPtr<UDPSocketParent>(this), &UDPSocketParent::DoConnect,
mSocket, target, aAddressInfo),

View File

@ -23,7 +23,7 @@ QuotaChild::QuotaChild(QuotaManagerService* aService)
: mService(aService)
#ifdef DEBUG
,
mOwningThread(GetCurrentThreadEventTarget())
mOwningThread(GetCurrentEventTarget())
#endif
{
AssertIsOnOwningThread();

View File

@ -1154,7 +1154,7 @@ class OriginOperationBase : public BackgroundThreadObject, public Runnable {
protected:
explicit OriginOperationBase(
nsIEventTarget* aOwningThread = GetCurrentThreadEventTarget())
nsIEventTarget* aOwningThread = GetCurrentEventTarget())
: BackgroundThreadObject(aOwningThread),
Runnable("dom::quota::OriginOperationBase"),
mResultCode(NS_OK),
@ -1911,7 +1911,7 @@ nsresult MaybeUpdateGroupForOrigin(const nsACString& aOrigin,
} // namespace
BackgroundThreadObject::BackgroundThreadObject()
: mOwningThread(GetCurrentThreadEventTarget()) {
: mOwningThread(GetCurrentEventTarget()) {
AssertIsOnOwningThread();
}

View File

@ -89,7 +89,7 @@ void FetchEventOpProxyChild::Initialize(
mOp = op;
op->GetRespondWithPromise()
->Then(GetCurrentThreadSerialEventTarget(), __func__,
->Then(GetCurrentSerialEventTarget(), __func__,
[self = std::move(self)](
FetchEventRespondWithPromise::ResolveOrRejectValue&& aResult) {
self->mRespondWithPromiseRequestHolder.Complete();

View File

@ -19,7 +19,7 @@ ServiceWorkerCloneData::~ServiceWorkerCloneData() {
}
ServiceWorkerCloneData::ServiceWorkerCloneData()
: mEventTarget(GetCurrentThreadSerialEventTarget()) {
: mEventTarget(GetCurrentSerialEventTarget()) {
MOZ_DIAGNOSTIC_ASSERT(mEventTarget);
}

View File

@ -39,7 +39,7 @@ IPCResult ServiceWorkerContainerParent::RecvRegister(
->Register(ClientInfo(aClientInfo), aScopeURL, aScriptURL,
aUpdateViaCache)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[aResolver](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
aResolver(aDescriptor.ToIPC());
},
@ -60,7 +60,7 @@ IPCResult ServiceWorkerContainerParent::RecvGetRegistration(
mProxy->GetRegistration(ClientInfo(aClientInfo), aURL)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[aResolver](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
aResolver(aDescriptor.ToIPC());
},
@ -80,7 +80,7 @@ IPCResult ServiceWorkerContainerParent::RecvGetRegistrations(
mProxy->GetRegistrations(ClientInfo(aClientInfo))
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[aResolver](
const nsTArray<ServiceWorkerRegistrationDescriptor>& aList) {
IPCServiceWorkerRegistrationDescriptorList ipcList;
@ -105,7 +105,7 @@ IPCResult ServiceWorkerContainerParent::RecvGetReady(
mProxy->GetReady(ClientInfo(aClientInfo))
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[aResolver](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
aResolver(aDescriptor.ToIPC());
},

View File

@ -131,7 +131,7 @@ class CheckPrincipalWithCallbackRunnable final : public Runnable {
mContentParent(aParent),
mPrincipalInfo(aPrincipalInfo),
mCallback(aCallback),
mBackgroundEventTarget(GetCurrentThreadEventTarget()) {
mBackgroundEventTarget(GetCurrentEventTarget()) {
AssertIsInMainProcess();
AssertIsOnBackgroundThread();

View File

@ -332,7 +332,7 @@ bool ServiceWorkerOp::MaybeStart(RemoteWorkerChild* aOwner,
if (IsTerminationOp()) {
aOwner->GetTerminationPromise()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self](
const GenericNonExclusivePromise::ResolveOrRejectValue& aResult) {
MaybeReportServiceWorkerShutdownProgress(self->mArgs, true);
@ -398,7 +398,7 @@ ServiceWorkerOp::ServiceWorkerOp(
RefPtr<ServiceWorkerOpPromise> promise = mPromiseHolder.Ensure(__func__);
promise->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[callback = std::move(aCallback)](
ServiceWorkerOpPromise::ResolveOrRejectValue&& aResult) mutable {
if (NS_WARN_IF(aResult.IsReject())) {

View File

@ -401,7 +401,7 @@ nsresult ServiceWorkerPrivateImpl::CheckScriptEvaluation(
// If a termination operation was already issued using `holder`...
if (self->mControllerChild != holder) {
holder->OnDestructor()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[callback = std::move(callback)](
const GenericPromise::ResolveOrRejectValue&) {
callback->SetResult(false);
@ -422,7 +422,7 @@ nsresult ServiceWorkerPrivateImpl::CheckScriptEvaluation(
swm->BlockShutdownOn(promise, shutdownStateId);
promise->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[callback = std::move(callback)](
const GenericNonExclusivePromise::ResolveOrRejectValue&) {
callback->SetResult(false);
@ -854,7 +854,7 @@ nsresult ServiceWorkerPrivateImpl::SendFetchEventInternal(
FetchEventOpChild::SendFetchEvent(
mControllerChild->get(), std::move(aArgs), std::move(aChannel),
std::move(aRegistration), mOuter->CreateEventKeepAliveToken())
->Then(GetCurrentThreadSerialEventTarget(), __func__,
->Then(GetCurrentSerialEventTarget(), __func__,
[holder = std::move(holder)](
const GenericPromise::ResolveOrRejectValue& aResult) {
Unused << NS_WARN_IF(aResult.IsReject());
@ -1048,7 +1048,7 @@ nsresult ServiceWorkerPrivateImpl::ExecServiceWorkerOp(
* can accept rvalue references rather than just const references.
*/
mControllerChild->get()->SendExecServiceWorkerOp(aArgs)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self = std::move(self), holder = std::move(holder),
token = std::move(token), onSuccess = std::move(aSuccessCallback),
onFailure = std::move(aFailureCallback)](

View File

@ -67,7 +67,7 @@ void ServiceWorkerProxy::StopListeningOnMainThread() {
ServiceWorkerProxy::ServiceWorkerProxy(
const ServiceWorkerDescriptor& aDescriptor)
: mActor(nullptr),
mEventTarget(GetCurrentThreadSerialEventTarget()),
mEventTarget(GetCurrentSerialEventTarget()),
mDescriptor(aDescriptor) {}
void ServiceWorkerProxy::Init(ServiceWorkerParent* aActor) {

View File

@ -806,7 +806,7 @@ class ServiceWorkerRegistrarSaveDataRunnable final : public Runnable {
ServiceWorkerRegistrarSaveDataRunnable(
nsTArray<ServiceWorkerRegistrationData>&& aData, uint32_t aGeneration)
: Runnable("dom::ServiceWorkerRegistrarSaveDataRunnable"),
mEventTarget(GetCurrentThreadEventTarget()),
mEventTarget(GetCurrentEventTarget()),
mData(std::move(aData)),
mGeneration(aGeneration) {
AssertIsOnBackgroundThread();

View File

@ -773,7 +773,7 @@ void ServiceWorkerRegistrationInfo::ClearWhenIdle() {
* Registration".
*/
GetActive()->WorkerPrivate()->GetIdlePromise()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self = RefPtr<ServiceWorkerRegistrationInfo>(this)](
const GenericPromise::ResolveOrRejectValue& aResult) {
MOZ_ASSERT(aResult.IsResolve());

View File

@ -47,7 +47,7 @@ IPCResult ServiceWorkerRegistrationParent::RecvUnregister(
}
mProxy->Unregister()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[aResolver](bool aSuccess) mutable {
ResolveUnregister(std::move(aResolver), aSuccess, NS_OK);
},
@ -67,7 +67,7 @@ IPCResult ServiceWorkerRegistrationParent::RecvUpdate(
mProxy->Update(aNewestWorkerScriptUrl)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[aResolver](const ServiceWorkerRegistrationDescriptor& aDescriptor) {
aResolver(aDescriptor.ToIPC());
},

View File

@ -167,7 +167,7 @@ bool ServiceWorkerRegistrationProxy::MatchesDescriptor(
ServiceWorkerRegistrationProxy::ServiceWorkerRegistrationProxy(
const ServiceWorkerRegistrationDescriptor& aDescriptor)
: mActor(nullptr),
mEventTarget(GetCurrentThreadSerialEventTarget()),
mEventTarget(GetCurrentSerialEventTarget()),
mDescriptor(aDescriptor) {}
void ServiceWorkerRegistrationProxy::Init(

View File

@ -117,7 +117,7 @@ void ServiceWorkerShutdownBlocker::WaitOnPromise(
RefPtr<ServiceWorkerShutdownBlocker> self = this;
aPromise->Then(GetCurrentThreadSerialEventTarget(), __func__,
aPromise->Then(GetCurrentSerialEventTarget(), __func__,
[self = std::move(self), shutdownStateId = aShutdownStateId](
const GenericNonExclusivePromise::ResolveOrRejectValue&) {
// Progress reporting might race with aPromise settling.

View File

@ -226,7 +226,7 @@ class ConnectionOperationBase : public Runnable,
protected:
ConnectionOperationBase(Connection* aConnection)
: Runnable("dom::ConnectionOperationBase"),
mOwningEventTarget(GetCurrentThreadEventTarget()),
mOwningEventTarget(GetCurrentEventTarget()),
mConnection(aConnection),
mResultCode(NS_OK),
mOperationMayProceed(true),
@ -557,7 +557,7 @@ already_AddRefed<mozilla::dom::quota::Client> CreateQuotaClient() {
StreamHelper::StreamHelper(nsIFileStream* aFileStream, nsIRunnable* aCallback)
: Runnable("dom::StreamHelper"),
mOwningEventTarget(GetCurrentThreadEventTarget()),
mOwningEventTarget(GetCurrentEventTarget()),
mFileStream(aFileStream),
mCallback(aCallback) {
AssertIsOnBackgroundThread();

View File

@ -76,7 +76,7 @@ class StorageDBThread::InitHelper final : public Runnable {
public:
InitHelper()
: Runnable("dom::StorageDBThread::InitHelper"),
mOwningThread(GetCurrentThreadEventTarget()),
mOwningThread(GetCurrentEventTarget()),
mMutex("InitHelper::mMutex"),
mCondVar(mMutex, "InitHelper::mCondVar"),
mMainThreadResultCode(NS_OK),
@ -101,7 +101,7 @@ class StorageDBThread::NoteBackgroundThreadRunnable final : public Runnable {
public:
NoteBackgroundThreadRunnable()
: Runnable("dom::StorageDBThread::NoteBackgroundThreadRunnable"),
mOwningThread(GetCurrentThreadEventTarget()) {}
mOwningThread(GetCurrentEventTarget()) {}
private:
~NoteBackgroundThreadRunnable() override = default;

View File

@ -550,7 +550,7 @@ class StorageDBParent::ObserverSink : public StorageObserverSink {
public:
explicit ObserverSink(StorageDBParent* aActor)
: mOwningEventTarget(GetCurrentThreadEventTarget()), mActor(aActor) {
: mOwningEventTarget(GetCurrentEventTarget()), mActor(aActor) {
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
}

View File

@ -270,7 +270,7 @@ class StorageDBParent final : public PBackgroundStorageParent {
CacheParentBridge(StorageDBParent* aParentDB,
const nsACString& aOriginSuffix,
const nsACString& aOriginNoSuffix)
: mOwningEventTarget(GetCurrentThreadSerialEventTarget()),
: mOwningEventTarget(GetCurrentSerialEventTarget()),
mParent(aParentDB),
mOriginSuffix(aOriginSuffix),
mOriginNoSuffix(aOriginNoSuffix),
@ -312,7 +312,7 @@ class StorageDBParent final : public PBackgroundStorageParent {
public:
UsageParentBridge(StorageDBParent* aParentDB,
const nsACString& aOriginScope)
: mOwningEventTarget(GetCurrentThreadSerialEventTarget()),
: mOwningEventTarget(GetCurrentSerialEventTarget()),
mParent(aParentDB),
mOriginScope(aOriginScope) {}
virtual ~UsageParentBridge() = default;

View File

@ -361,7 +361,7 @@ void U2FTokenManager::DoRegister(const WebAuthnMakeCredentialInfo& aInfo,
mTokenManagerImpl->Register(aInfo, aForceNoneAttestation)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[tid, startTime](WebAuthnMakeCredentialResult&& aResult) {
U2FTokenManager* mgr = U2FTokenManager::Get();
mgr->MaybeConfirmRegister(tid, aResult);
@ -420,7 +420,7 @@ void U2FTokenManager::Sign(PWebAuthnTransactionParent* aTransactionParent,
mTokenManagerImpl->Sign(aTransactionInfo)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[tid, startTime](WebAuthnGetAssertionResult&& aResult) {
U2FTokenManager* mgr = U2FTokenManager::Get();
mgr->MaybeConfirmSign(tid, aResult);

View File

@ -47,7 +47,7 @@ RefPtr<RawIdPromise> WebGPUChild::InstanceRequestAdapter(
return SendInstanceRequestAdapter(aOptions, sharedIds)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[](const RawId& aId) {
if (aId == 0) {
return RawIdPromise::CreateAndReject(Nothing(), __func__);

View File

@ -922,7 +922,7 @@ already_AddRefed<Promise> ServiceWorkerGlobalScope::SkipWaiting(
auto holder = MakeRefPtr<DOMMozPromiseRequestHolder<MozPromiseType>>(this);
mWorkerPrivate->SetServiceWorkerSkipWaitingFlag()
->Then(GetCurrentThreadSerialEventTarget(), __func__,
->Then(GetCurrentSerialEventTarget(), __func__,
[holder, promise](const MozPromiseType::ResolveOrRejectValue&) {
holder->Complete();
promise->MaybeResolveWithUndefined();

View File

@ -251,7 +251,7 @@ RemoteWorkerChild::RemoteWorkerChild(const RemoteWorkerData& aData)
: mState(VariantType<Pending>(), "RemoteWorkerChild::mState"),
mIsServiceWorker(aData.serviceWorkerData().type() ==
OptionalServiceWorkerData::TServiceWorkerData),
mOwningEventTarget(GetCurrentThreadSerialEventTarget()) {
mOwningEventTarget(GetCurrentSerialEventTarget()) {
MOZ_ASSERT(RemoteWorkerService::Thread()->IsOnCurrentThread());
MOZ_ASSERT(mOwningEventTarget);
}
@ -1019,7 +1019,7 @@ RemoteWorkerChild::MaybeSendSetServiceWorkerSkipWaitingFlag() {
}
self->SendSetServiceWorkerSkipWaitingFlag()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[promise](
const SetServiceWorkerSkipWaitingFlagPromise::ResolveOrRejectValue&
aResult) {

View File

@ -439,7 +439,7 @@ bool RemoteWorkerController::PendingServiceWorkerOp::MaybeStart(
MaybeReportServiceWorkerShutdownProgress(args);
aOwner->mActor->SendExecServiceWorkerOp(args)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[promise = std::move(mPromise)](
PRemoteWorkerParent::ExecServiceWorkerOpPromise::
ResolveOrRejectValue&& aResult) {

View File

@ -104,7 +104,7 @@ IPCResult RemoteWorkerControllerChild::RecvSetServiceWorkerSkipWaitingFlag(
if (mObserver) {
static_cast<ServiceWorkerPrivateImpl*>(mObserver.get())
->SetSkipWaitingFlag()
->Then(GetCurrentThreadSerialEventTarget(), __func__,
->Then(GetCurrentSerialEventTarget(), __func__,
[resolve = std::move(aResolve)](
const GenericPromise::ResolveOrRejectValue& aResult) {
resolve(aResult.IsResolve() ? aResult.ResolveValue() : false);
@ -137,7 +137,7 @@ void RemoteWorkerControllerChild::MaybeSendDelete() {
RefPtr<RemoteWorkerControllerChild> self = this;
SendShutdown()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[self = std::move(self)](const ShutdownPromise::ResolveOrRejectValue&) {
if (self->mIPCActive) {
Unused << self->Send__delete__(self);

View File

@ -53,7 +53,7 @@ void RemoteWorkerControllerParent::MaybeSendSetServiceWorkerSkipWaitingFlag(
}
SendSetServiceWorkerSkipWaitingFlag()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[callback = std::move(aCallback)](
const SetServiceWorkerSkipWaitingFlagPromise::ResolveOrRejectValue&
aResult) {
@ -102,7 +102,7 @@ IPCResult RemoteWorkerControllerParent::RecvExecServiceWorkerOp(
MOZ_ASSERT(mRemoteWorkerController);
mRemoteWorkerController->ExecServiceWorkerOp(std::move(aArgs))
->Then(GetCurrentThreadSerialEventTarget(), __func__,
->Then(GetCurrentSerialEventTarget(), __func__,
[resolve = std::move(aResolve)](
ServiceWorkerOpPromise::ResolveOrRejectValue&& aResult) {
if (NS_WARN_IF(aResult.IsReject())) {

View File

@ -387,8 +387,7 @@ void RemoteWorkerManager::LaunchNewContentProcess(
AssertIsInMainProcess();
AssertIsOnBackgroundThread();
nsCOMPtr<nsISerialEventTarget> bgEventTarget =
GetCurrentThreadSerialEventTarget();
nsCOMPtr<nsISerialEventTarget> bgEventTarget = GetCurrentSerialEventTarget();
using CallbackParamType = ContentParent::LaunchPromise::ResolveOrRejectValue;
@ -431,7 +430,7 @@ void RemoteWorkerManager::LaunchNewContentProcess(
ContentParent::GetNewOrUsedBrowserProcessAsync(
/* aFrameElement = */ nullptr,
/* aRemoteType = */ NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE))
->Then(GetCurrentThreadSerialEventTarget(), __func__,
->Then(GetCurrentSerialEventTarget(), __func__,
[callback = std::move(callback)](
const CallbackParamType& aValue) mutable {
callback(aValue);

View File

@ -169,7 +169,7 @@ IPCResult RemoteWorkerParent::RecvSetServiceWorkerSkipWaitingFlag(
if (mController) {
mController->SetServiceWorkerSkipWaitingFlag()->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
[resolve = aResolve](bool /* unused */) { resolve(true); },
[resolve = aResolve](nsresult /* unused */) { resolve(false); });
} else {

View File

@ -19,7 +19,7 @@ using namespace ipc;
namespace dom {
SharedWorkerParent::SharedWorkerParent()
: mBackgroundEventTarget(GetCurrentThreadEventTarget()),
: mBackgroundEventTarget(GetCurrentEventTarget()),
mStatus(eInit),
mSuspended(false),
mFrozen(false) {

View File

@ -33,7 +33,7 @@ class GetOrCreateWorkerManagerRunnable final : public Runnable {
uint64_t aWindowID,
const MessagePortIdentifier& aPortIdentifier)
: Runnable("GetOrCreateWorkerManagerRunnable"),
mBackgroundEventTarget(GetCurrentThreadEventTarget()),
mBackgroundEventTarget(GetCurrentEventTarget()),
mService(aService),
mActor(aActor),
mData(aData),

View File

@ -0,0 +1,301 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 "AsyncCanvasRenderer.h"
#include "gfxUtils.h"
#include "GLContext.h"
#include "GLReadTexImageHelper.h"
#include "GLScreenBuffer.h"
#include "Layers.h"
#include "mozilla/dom/HTMLCanvasElement.h"
#include "nsICanvasRenderingContextInternal.h"
#include "mozilla/layers/BufferTexture.h"
#include "mozilla/layers/CanvasClient.h"
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/TextureClient.h"
#include "mozilla/layers/TextureClientSharedSurface.h"
#include "mozilla/layers/ShadowLayers.h"
#include "mozilla/ReentrantMonitor.h"
#include "nsIRunnable.h"
#include "nsThreadUtils.h"
namespace mozilla {
namespace layers {
AsyncCanvasRenderer::AsyncCanvasRenderer()
: mHTMLCanvasElement(nullptr),
mContext(nullptr),
mGLContext(nullptr),
mIsAlphaPremultiplied(true),
mWidth(0),
mHeight(0),
mCanvasClient(nullptr),
mMutex("AsyncCanvasRenderer::mMutex"),
mContextType(dom::CanvasContextType::NoContext) {
MOZ_COUNT_CTOR(AsyncCanvasRenderer);
}
AsyncCanvasRenderer::~AsyncCanvasRenderer() {
MOZ_COUNT_DTOR(AsyncCanvasRenderer);
}
void AsyncCanvasRenderer::NotifyElementAboutAttributesChanged() {
class Runnable final : public mozilla::Runnable {
public:
explicit Runnable(AsyncCanvasRenderer* aRenderer)
: mozilla::Runnable("Runnable"), mRenderer(aRenderer) {}
NS_IMETHOD Run() override {
if (mRenderer) {
dom::HTMLCanvasElement::SetAttrFromAsyncCanvasRenderer(mRenderer);
}
return NS_OK;
}
private:
RefPtr<AsyncCanvasRenderer> mRenderer;
};
nsCOMPtr<nsIRunnable> runnable = new Runnable(this);
nsresult rv = NS_DispatchToMainThread(runnable);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch a runnable to the main-thread.");
}
}
void AsyncCanvasRenderer::NotifyElementAboutInvalidation() {
class Runnable final : public mozilla::Runnable {
public:
explicit Runnable(AsyncCanvasRenderer* aRenderer)
: mozilla::Runnable("Runnable"), mRenderer(aRenderer) {}
NS_IMETHOD Run() override {
if (mRenderer) {
dom::HTMLCanvasElement::InvalidateFromAsyncCanvasRenderer(mRenderer);
}
return NS_OK;
}
private:
RefPtr<AsyncCanvasRenderer> mRenderer;
};
nsCOMPtr<nsIRunnable> runnable = new Runnable(this);
nsresult rv = NS_DispatchToMainThread(runnable);
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch a runnable to the main-thread.");
}
}
void AsyncCanvasRenderer::SetCanvasClient(CanvasClient* aClient) {
mCanvasClient = aClient;
if (aClient) {
mCanvasClientAsyncHandle = aClient->GetAsyncHandle();
if (mContext) {
MOZ_ASSERT(mCanvasClient->GetForwarder() &&
mCanvasClient->GetForwarder()->AsLayerForwarder() &&
mCanvasClient->GetForwarder()
->AsLayerForwarder()
->GetShadowManager());
LayerTransactionChild* ltc =
mCanvasClient->GetForwarder()->AsLayerForwarder()->GetShadowManager();
DebugOnly<bool> success =
mContext->UpdateCompositableHandle(ltc, mCanvasClientAsyncHandle);
MOZ_ASSERT(success);
}
} else {
mCanvasClientAsyncHandle = CompositableHandle();
}
}
void AsyncCanvasRenderer::SetActiveEventTarget() {
MutexAutoLock lock(mMutex);
mActiveEventTarget = GetCurrentSerialEventTarget();
}
void AsyncCanvasRenderer::ResetActiveEventTarget() {
MutexAutoLock lock(mMutex);
mActiveEventTarget = nullptr;
}
already_AddRefed<nsISerialEventTarget>
AsyncCanvasRenderer::GetActiveEventTarget() {
MutexAutoLock lock(mMutex);
nsCOMPtr<nsISerialEventTarget> result = mActiveEventTarget;
return result.forget();
}
ImageContainer* AsyncCanvasRenderer::GetImageContainer() {
MOZ_ASSERT(mContextType == dom::CanvasContextType::ImageBitmap);
MutexAutoLock lock(mMutex);
if (!mImageContainer) {
mImageContainer =
LayerManager::CreateImageContainer(ImageContainer::ASYNCHRONOUS);
}
return mImageContainer;
}
dom::CanvasContextType AsyncCanvasRenderer::GetContextType() {
MutexAutoLock lock(mMutex);
return mContextType;
}
void AsyncCanvasRenderer::SetContextType(dom::CanvasContextType aContextType) {
MutexAutoLock lock(mMutex);
mContextType = aContextType;
}
void AsyncCanvasRenderer::CopyFromTextureClient(TextureClient* aTextureClient) {
MutexAutoLock lock(mMutex);
if (!aTextureClient) {
mSurfaceForBasic = nullptr;
return;
}
TextureClientAutoLock texLock(aTextureClient, layers::OpenMode::OPEN_READ);
if (!texLock.Succeeded()) {
return;
}
const gfx::IntSize& size = aTextureClient->GetSize();
// This buffer would be used later for content rendering. So we choose
// B8G8R8A8 format here.
const gfx::SurfaceFormat format = gfx::SurfaceFormat::B8G8R8A8;
// Avoid to create buffer every time.
if (!mSurfaceForBasic || size != mSurfaceForBasic->GetSize() ||
format != mSurfaceForBasic->GetFormat()) {
uint32_t stride =
gfx::GetAlignedStride<8>(size.width, BytesPerPixel(format));
mSurfaceForBasic =
gfx::Factory::CreateDataSourceSurfaceWithStride(size, format, stride);
if (!mSurfaceForBasic) {
return;
}
}
MappedTextureData mapped;
if (!aTextureClient->BorrowMappedData(mapped)) {
return;
}
const uint8_t* lockedBytes = mapped.data;
gfx::DataSourceSurface::ScopedMap map(mSurfaceForBasic,
gfx::DataSourceSurface::MapType::WRITE);
if (!map.IsMapped()) {
return;
}
MOZ_ASSERT(map.GetStride() == mapped.stride);
memcpy(map.GetData(), lockedBytes,
map.GetStride() * mSurfaceForBasic->GetSize().height);
if (mSurfaceForBasic->GetFormat() == gfx::SurfaceFormat::R8G8B8A8 ||
mSurfaceForBasic->GetFormat() == gfx::SurfaceFormat::R8G8B8X8) {
gl::SwapRAndBComponents(mSurfaceForBasic);
}
}
already_AddRefed<gfx::DataSourceSurface> AsyncCanvasRenderer::UpdateTarget() {
if (!mGLContext) {
return nullptr;
}
gl::SharedSurface* frontbuffer = nullptr;
gl::GLScreenBuffer* screen = mGLContext->Screen();
const auto& front = screen->Front();
if (front) {
frontbuffer = front->Surf();
}
if (!frontbuffer) {
return nullptr;
}
if (frontbuffer->mType == gl::SharedSurfaceType::Basic) {
return nullptr;
}
const gfx::IntSize& size = frontbuffer->mSize;
// This buffer would be used later for content rendering. So we choose
// B8G8R8A8 format here.
const gfx::SurfaceFormat format = gfx::SurfaceFormat::B8G8R8A8;
uint32_t stride = gfx::GetAlignedStride<8>(size.width, BytesPerPixel(format));
RefPtr<gfx::DataSourceSurface> surface =
gfx::Factory::CreateDataSourceSurfaceWithStride(size, format, stride);
if (NS_WARN_IF(!surface)) {
return nullptr;
}
if (!frontbuffer->ReadbackBySharedHandle(surface)) {
return nullptr;
}
bool needsPremult = frontbuffer->mHasAlpha && !mIsAlphaPremultiplied;
if (needsPremult) {
gfxUtils::PremultiplyDataSurface(surface, surface);
}
return surface.forget();
}
already_AddRefed<gfx::DataSourceSurface> AsyncCanvasRenderer::GetSurface() {
MOZ_ASSERT(NS_IsMainThread());
MutexAutoLock lock(mMutex);
if (mSurfaceForBasic) {
// Since SourceSurface isn't thread-safe, we need copy to a new
// SourceSurface.
gfx::DataSourceSurface::ScopedMap srcMap(mSurfaceForBasic,
gfx::DataSourceSurface::READ);
RefPtr<gfx::DataSourceSurface> result =
gfx::Factory::CreateDataSourceSurfaceWithStride(
mSurfaceForBasic->GetSize(), mSurfaceForBasic->GetFormat(),
srcMap.GetStride());
if (NS_WARN_IF(!result)) {
return nullptr;
}
gfx::DataSourceSurface::ScopedMap dstMap(result,
gfx::DataSourceSurface::WRITE);
if (NS_WARN_IF(!srcMap.IsMapped()) || NS_WARN_IF(!dstMap.IsMapped())) {
return nullptr;
}
memcpy(dstMap.GetData(), srcMap.GetData(),
srcMap.GetStride() * mSurfaceForBasic->GetSize().height);
return result.forget();
} else {
return UpdateTarget();
}
}
nsresult AsyncCanvasRenderer::GetInputStream(const char* aMimeType,
const nsAString& aEncoderOptions,
nsIInputStream** aStream) {
MOZ_ASSERT(NS_IsMainThread());
RefPtr<gfx::DataSourceSurface> surface = GetSurface();
if (!surface) {
return NS_ERROR_FAILURE;
}
gfx::DataSourceSurface::ScopedMap map(surface, gfx::DataSourceSurface::READ);
// Handle y flip.
RefPtr<gfx::DataSourceSurface> dataSurf =
gl::YInvertImageSurface(surface, map.GetStride());
return gfxUtils::GetInputStream(dataSurf, false, aMimeType, aEncoderOptions,
aStream);
}
} // namespace layers
} // namespace mozilla

View File

@ -116,7 +116,7 @@ class nsAutoRefTraits<nsOwningThreadSourceSurfaceRef> {
}
void AddRef(RawRef aRawRef) {
MOZ_ASSERT(!mOwningEventTarget);
mOwningEventTarget = mozilla::GetCurrentThreadSerialEventTarget();
mOwningEventTarget = mozilla::GetCurrentSerialEventTarget();
aRawRef->AddRef();
}

View File

@ -1020,7 +1020,7 @@ void LayerScopeWebSocketManager::SocketHandler::OpenStream(
nsCOMPtr<nsIInputStream> debugInputStream;
mTransport->OpenInputStream(0, 0, 0, getter_AddRefs(debugInputStream));
mInputStream = do_QueryInterface(debugInputStream);
mInputStream->AsyncWait(this, 0, 0, GetCurrentThreadEventTarget());
mInputStream->AsyncWait(this, 0, 0, GetCurrentEventTarget());
}
bool LayerScopeWebSocketManager::SocketHandler::WriteToStream(void* aPtr,
@ -1091,7 +1091,7 @@ LayerScopeWebSocketManager::SocketHandler::OnInputStreamReady(
if (WebSocketHandshake(protocolString)) {
mState = HandshakeSuccess;
mConnected = true;
mInputStream->AsyncWait(this, 0, 0, GetCurrentThreadEventTarget());
mInputStream->AsyncWait(this, 0, 0, GetCurrentEventTarget());
} else {
mState = HandshakeFailed;
}
@ -1218,7 +1218,7 @@ nsresult LayerScopeWebSocketManager::SocketHandler::HandleSocketMessage(
// TODO: combine packets if we have to read more than once
if (rv == NS_BASE_STREAM_WOULD_BLOCK) {
mInputStream->AsyncWait(this, 0, 0, GetCurrentThreadEventTarget());
mInputStream->AsyncWait(this, 0, 0, GetCurrentEventTarget());
return NS_OK;
}

View File

@ -468,7 +468,7 @@ class ChildImpl final : public BackgroundChildImpl {
explicit ChildImpl()
#if defined(DEBUG) || !defined(RELEASE_OR_BETA)
: mOwningEventTarget(GetCurrentThreadSerialEventTarget())
: mOwningEventTarget(GetCurrentSerialEventTarget())
#endif
#ifdef DEBUG
,
@ -615,7 +615,7 @@ class ChildImpl::SendInitBackgroundRunnable final : public CancelableRunnable {
std::function<void(Endpoint<PBackgroundParent>&& aParent)>&& aFunc,
unsigned int aThreadLocalIndex)
: CancelableRunnable("Background::ChildImpl::SendInitBackgroundRunnable"),
mOwningEventTarget(GetCurrentThreadSerialEventTarget()),
mOwningEventTarget(GetCurrentSerialEventTarget()),
mParent(std::move(aParent)),
mMutex("SendInitBackgroundRunnable::mMutex"),
mSentInitBackground(false),
@ -1334,7 +1334,7 @@ void ParentImpl::ShutdownTimerCallback(nsITimer* aTimer, void* aClosure) {
}
return GenericPromise::CreateAndResolve(true, __func__);
})
->Then(GetCurrentThreadSerialEventTarget(), __func__, []() {
->Then(GetCurrentSerialEventTarget(), __func__, []() {
MOZ_ASSERT(sLiveActorCount);
sLiveActorCount--;
});

View File

@ -25,8 +25,7 @@ class IPCStreamSource::Callback final : public nsIInputStreamCallback,
public nsICancelableRunnable {
public:
explicit Callback(IPCStreamSource* aSource)
: mSource(aSource),
mOwningEventTarget(GetCurrentThreadSerialEventTarget()) {
: mSource(aSource), mOwningEventTarget(GetCurrentSerialEventTarget()) {
MOZ_ASSERT(mSource);
}

View File

@ -76,7 +76,7 @@ class AudioConduitTest : public ::testing::Test {
AudioConduitTest() : mCall(new MockCall()) {
mAudioConduit = new AudioConduitWithMockChannelProxy(
WebRtcCallWrapper::Create(UniquePtr<MockCall>(mCall)),
GetCurrentThreadSerialEventTarget());
GetCurrentSerialEventTarget());
mAudioConduit->Init();
}

View File

@ -45,7 +45,7 @@ class VideoConduitTest : public ::testing::Test {
mVideoConduit = new WebrtcVideoConduit(
WebRtcCallWrapper::Create(UniquePtr<MockCall>(mCall)),
GetCurrentThreadSerialEventTarget());
GetCurrentSerialEventTarget());
mVideoConduit->SetLocalSSRCs({42}, {43});
}

View File

@ -15,8 +15,7 @@ namespace mozilla {
class MediaTransportParent::Impl : public sigslot::has_slots<> {
public:
explicit Impl(MediaTransportParent* aParent)
: mHandler(
MediaTransportHandler::Create(GetCurrentThreadSerialEventTarget())),
: mHandler(MediaTransportHandler::Create(GetCurrentSerialEventTarget())),
mParent(aParent) {
mHandler->SignalCandidate.connect(this,
&MediaTransportParent::Impl::OnCandidate);
@ -94,7 +93,7 @@ MediaTransportParent::~MediaTransportParent() {}
mozilla::ipc::IPCResult MediaTransportParent::RecvGetIceLog(
const nsCString& pattern, GetIceLogResolver&& aResolve) {
mImpl->mHandler->GetIceLog(pattern)->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
// IPDL doesn't give us a reject function, so we cannot reject async, so
// we are forced to resolve with an empty result. Laaaaaaame.
[aResolve = std::move(aResolve)](
@ -217,7 +216,7 @@ mozilla::ipc::IPCResult MediaTransportParent::RecvGetIceStats(
GetIceStatsResolver&& aResolve) {
mImpl->mHandler->GetIceStats(transportId, now)
->Then(
GetCurrentThreadSerialEventTarget(), __func__,
GetCurrentSerialEventTarget(), __func__,
// IPDL doesn't give us a reject function, so we cannot reject async,
// so we are forced to resolve with an unmodified result. Laaaaaaame.
[aResolve = std::move(aResolve)](

View File

@ -122,7 +122,7 @@ nsresult BackgroundFileSaver::Init() {
HasInfiniteBuffer() ? UINT32_MAX : 0);
NS_ENSURE_SUCCESS(rv, rv);
mControlEventTarget = GetCurrentThreadEventTarget();
mControlEventTarget = GetCurrentEventTarget();
NS_ENSURE_TRUE(mControlEventTarget, NS_ERROR_NOT_INITIALIZED);
rv = NS_CreateBackgroundTaskQueue("BgFileSaver",

View File

@ -315,7 +315,7 @@ Dashboard::RequestSockets(nsINetDashboardCallback* aCallback) {
RefPtr<SocketData> socketData = new SocketData();
socketData->mCallback = new nsMainThreadPtrHolder<nsINetDashboardCallback>(
"nsINetDashboardCallback", aCallback, true);
socketData->mEventTarget = GetCurrentThreadEventTarget();
socketData->mEventTarget = GetCurrentEventTarget();
gSocketTransportService->Dispatch(
NewRunnableMethod<RefPtr<SocketData>>(
"net::Dashboard::GetSocketsDispatch", this,
@ -381,7 +381,7 @@ Dashboard::RequestHttpConnections(nsINetDashboardCallback* aCallback) {
RefPtr<HttpData> httpData = new HttpData();
httpData->mCallback = new nsMainThreadPtrHolder<nsINetDashboardCallback>(
"nsINetDashboardCallback", aCallback, true);
httpData->mEventTarget = GetCurrentThreadEventTarget();
httpData->mEventTarget = GetCurrentEventTarget();
gSocketTransportService->Dispatch(NewRunnableMethod<RefPtr<HttpData>>(
"net::Dashboard::GetHttpDispatch", this,
@ -546,7 +546,7 @@ Dashboard::RequestWebsocketConnections(nsINetDashboardCallback* aCallback) {
RefPtr<WebSocketRequest> wsRequest = new WebSocketRequest();
wsRequest->mCallback = new nsMainThreadPtrHolder<nsINetDashboardCallback>(
"nsINetDashboardCallback", aCallback, true);
wsRequest->mEventTarget = GetCurrentThreadEventTarget();
wsRequest->mEventTarget = GetCurrentEventTarget();
wsRequest->mEventTarget->Dispatch(
NewRunnableMethod<RefPtr<WebSocketRequest>>(
@ -599,7 +599,7 @@ Dashboard::RequestDNSInfo(nsINetDashboardCallback* aCallback) {
nsresult rv;
dnsData->mData.Clear();
dnsData->mEventTarget = GetCurrentThreadEventTarget();
dnsData->mEventTarget = GetCurrentEventTarget();
if (!mDnsService) {
mDnsService = do_GetService("@mozilla.org/network/dns-service;1", &rv);
@ -699,7 +699,7 @@ Dashboard::RequestDNSLookup(const nsACString& aHost,
RefPtr<LookupHelper> helper = new LookupHelper();
helper->mCallback = new nsMainThreadPtrHolder<nsINetDashboardCallback>(
"nsINetDashboardCallback", aCallback, true);
helper->mEventTarget = GetCurrentThreadEventTarget();
helper->mEventTarget = GetCurrentEventTarget();
OriginAttributes attrs;
rv = mDnsService->AsyncResolveNative(aHost, 0, helper.get(),
NS_GetCurrentThread(), attrs,
@ -710,7 +710,7 @@ Dashboard::RequestDNSLookup(const nsACString& aHost,
NS_IMETHODIMP
Dashboard::RequestRcwnStats(nsINetDashboardCallback* aCallback) {
RefPtr<RcwnData> rcwnData = new RcwnData();
rcwnData->mEventTarget = GetCurrentThreadEventTarget();
rcwnData->mEventTarget = GetCurrentEventTarget();
rcwnData->mCallback = new nsMainThreadPtrHolder<nsINetDashboardCallback>(
"nsINetDashboardCallback", aCallback, true);
@ -806,7 +806,7 @@ Dashboard::RequestConnection(const nsACString& aHost, uint32_t aPort,
connectionData->mCallback =
new nsMainThreadPtrHolder<nsINetDashboardCallback>(
"nsINetDashboardCallback", aCallback, true);
connectionData->mEventTarget = GetCurrentThreadEventTarget();
connectionData->mEventTarget = GetCurrentEventTarget();
rv = TestNewConnection(connectionData);
if (NS_FAILED(rv)) {
@ -861,7 +861,7 @@ nsresult Dashboard::TestNewConnection(ConnectionData* aConnectionData) {
}
rv = connectionData->mSocket->SetEventSink(connectionData,
GetCurrentThreadEventTarget());
GetCurrentEventTarget());
if (NS_FAILED(rv)) {
return rv;
}

View File

@ -449,7 +449,7 @@ bool ProxyAutoConfig::ResolveAddress(const nsCString& aHostName,
nsIDNSService::GetFlagsFromTRRMode(nsIRequest::TRR_DISABLED_MODE);
if (NS_FAILED(dns->AsyncResolveNative(aHostName, flags, helper,
GetCurrentThreadEventTarget(), attrs,
GetCurrentEventTarget(), attrs,
getter_AddRefs(helper->mRequest)))) {
return false;
}

View File

@ -70,7 +70,7 @@ nsresult nsAsyncRedirectVerifyHelper::Init(
mFlags = flags;
mCallbackEventTarget = NS_IsMainThread() && mainThreadEventTarget
? mainThreadEventTarget
: GetCurrentThreadEventTarget();
: GetCurrentEventTarget();
if (!(flags & (nsIChannelEventSink::REDIRECT_INTERNAL |
nsIChannelEventSink::REDIRECT_STS_UPGRADE))) {

View File

@ -35,7 +35,7 @@ class AsyncApplyBufferingPolicyEvent final : public Runnable {
explicit AsyncApplyBufferingPolicyEvent(nsAsyncStreamCopier* aCopier)
: mozilla::Runnable("AsyncApplyBufferingPolicyEvent"),
mCopier(aCopier),
mTarget(GetCurrentThreadEventTarget()) {}
mTarget(GetCurrentEventTarget()) {}
NS_IMETHOD Run() override {
nsresult rv = mCopier->ApplyBufferingPolicy();

View File

@ -71,7 +71,7 @@ nsresult nsDNSPrefetch::Prefetch(uint32_t flags) {
// then our timing will be useless. However, in such a case,
// mEndTimestamp will be a null timestamp and callers should check
// TimingsValid() before using the timing.
nsCOMPtr<nsIEventTarget> target = mozilla::GetCurrentThreadEventTarget();
nsCOMPtr<nsIEventTarget> target = mozilla::GetCurrentEventTarget();
flags |= nsIDNSService::GetFlagsFromTRRMode(mTRRMode);

View File

@ -336,7 +336,7 @@ nsInputStreamPump::AsyncRead(nsIStreamListener* listener, nsISupports* ctxt) {
if (NS_IsMainThread() && mLabeledMainThreadTarget) {
mTargetThread = mLabeledMainThreadTarget;
} else {
mTargetThread = GetCurrentThreadEventTarget();
mTargetThread = GetCurrentEventTarget();
}
NS_ENSURE_STATE(mTargetThread);

View File

@ -525,10 +525,9 @@ nsresult nsPACMan::LoadPACFromURI(const nsACString& aSpec,
if (!mLoadPending) {
nsCOMPtr<nsIRunnable> runnable = NewRunnableMethod(
"nsPACMan::StartLoading", this, &nsPACMan::StartLoading);
nsresult rv =
NS_IsMainThread()
? Dispatch(runnable.forget())
: GetCurrentThreadEventTarget()->Dispatch(runnable.forget());
nsresult rv = NS_IsMainThread()
? Dispatch(runnable.forget())
: GetCurrentEventTarget()->Dispatch(runnable.forget());
if (NS_FAILED(rv)) return rv;
mLoadPending = true;
}

View File

@ -424,7 +424,7 @@ class ServerSocketListenerProxy final : public nsIServerSocketListener {
explicit ServerSocketListenerProxy(nsIServerSocketListener* aListener)
: mListener(new nsMainThreadPtrHolder<nsIServerSocketListener>(
"ServerSocketListenerProxy::mListener", aListener)),
mTarget(GetCurrentThreadEventTarget()) {}
mTarget(GetCurrentEventTarget()) {}
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSISERVERSOCKETLISTENER
@ -510,7 +510,7 @@ nsServerSocket::AsyncListen(nsIServerSocketListener* aListener) {
{
MutexAutoLock lock(mLock);
mListener = new ServerSocketListenerProxy(aListener);
mListenerTarget = GetCurrentThreadEventTarget();
mListenerTarget = GetCurrentEventTarget();
}
// Child classes may need to do additional setup just before listening begins

View File

@ -2649,7 +2649,7 @@ NS_IMETHODIMP
nsSocketTransport::SetSecurityCallbacks(nsIInterfaceRequestor* callbacks) {
nsCOMPtr<nsIInterfaceRequestor> threadsafeCallbacks;
NS_NewNotificationCallbacksAggregation(callbacks, nullptr,
GetCurrentThreadEventTarget(),
GetCurrentEventTarget(),
getter_AddRefs(threadsafeCallbacks));
nsCOMPtr<nsISupports> secinfo;

View File

@ -357,7 +357,7 @@ class AvailableEvent final : public Runnable {
mDoingCallback(false),
mSize(0),
mResultForCallback(NS_OK) {
mCallbackTarget = GetCurrentThreadEventTarget();
mCallbackTarget = GetCurrentEventTarget();
}
NS_IMETHOD Run() override {

Some files were not shown because too many files have changed in this diff Show More