From 8cdf70553591d3bd5ac75cffa91cc81f66c66326 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Mon, 5 Feb 2018 19:55:07 +0100 Subject: [PATCH] Bug 1435174 - Remove the renaming 'using namespace workers', r=bkelly --- caps/nsJSPrincipals.cpp | 2 +- dom/base/EventSource.cpp | 2 -- dom/base/ImageEncoder.cpp | 2 +- dom/base/nsContentUtils.cpp | 10 +++--- dom/base/nsGlobalWindowInner.cpp | 10 +++--- dom/base/nsJSTimeoutHandler.cpp | 1 - dom/bindings/BindingUtils.cpp | 2 -- dom/broadcastchannel/BroadcastChannel.cpp | 1 - .../BroadcastChannelChild.cpp | 2 -- dom/canvas/ImageBitmap.cpp | 2 -- dom/canvas/ImageBitmap.h | 4 --- dom/clients/api/Client.cpp | 1 - dom/clients/api/ClientDOMUtil.h | 4 +-- dom/clients/api/Clients.cpp | 1 - dom/clients/manager/ClientManager.cpp | 2 +- dom/console/Console.cpp | 1 - dom/crypto/WebCryptoTask.cpp | 2 +- dom/events/Event.cpp | 4 +-- dom/events/EventDispatcher.cpp | 2 +- dom/events/JSEventHandler.cpp | 2 +- dom/fetch/Fetch.cpp | 2 -- dom/fetch/FetchConsumer.cpp | 2 -- dom/fetch/FetchDriver.cpp | 14 ++++---- dom/fetch/FetchStream.cpp | 2 -- dom/fetch/FetchStreamReader.cpp | 2 -- dom/file/FileBlobImpl.cpp | 2 +- dom/file/FileReader.cpp | 2 +- dom/file/FileReaderSync.cpp | 2 +- dom/file/ipc/IPCBlobInputStreamChild.cpp | 2 -- dom/indexedDB/ActorsChild.cpp | 2 -- dom/indexedDB/IDBObjectStore.cpp | 1 - dom/indexedDB/IDBRequest.cpp | 1 - dom/indexedDB/IDBTransaction.cpp | 1 - dom/indexedDB/IndexedDatabaseManager.cpp | 1 - dom/ipc/ContentChild.cpp | 1 - dom/ipc/TabChild.cpp | 1 - dom/messagechannel/MessagePort.cpp | 2 -- dom/notification/Notification.cpp | 2 -- dom/notification/Notification.h | 2 +- dom/performance/Performance.cpp | 2 +- dom/performance/PerformanceObserver.cpp | 2 +- dom/promise/Promise.cpp | 6 ++-- dom/push/PushManager.cpp | 3 -- dom/push/PushNotifier.cpp | 2 -- dom/push/PushSubscription.cpp | 2 -- dom/quota/StorageManager.cpp | 2 -- dom/script/ScriptSettings.cpp | 6 ++-- dom/serviceworkers/ServiceWorkerEvents.cpp | 1 - .../ServiceWorkerRegistration.cpp | 2 -- dom/url/URLWorker.cpp | 3 -- dom/websocket/WebSocket.cpp | 1 - dom/workers/MessageEventRunnable.cpp | 2 +- dom/workers/RuntimeService.cpp | 30 +++++----------- dom/workers/RuntimeService.h | 8 ++--- dom/workers/ScriptLoader.cpp | 2 -- dom/workers/WorkerCommon.h | 18 ++-------- dom/workers/WorkerError.cpp | 4 +-- dom/workers/WorkerPrivate.cpp | 1 - dom/workers/WorkerPrivate.h | 30 ++++++++-------- dom/workers/WorkerRunnable.cpp | 8 ++--- dom/workers/WorkerRunnable.h | 35 ++++++++++--------- dom/workers/WorkerScope.cpp | 9 ++--- dom/xhr/XMLHttpRequestWorker.cpp | 30 ++++++++-------- gfx/thebes/gfxUtils.cpp | 3 +- ipc/glue/BackgroundParentImpl.cpp | 7 +--- ipc/glue/IPCStreamSource.cpp | 2 +- js/src/devtools/rootAnalysis/annotations.js | 2 +- js/xpconnect/src/nsXPConnect.cpp | 4 +-- xpcom/threads/MainThreadUtils.h | 14 ++++++++ xpcom/threads/nsThreadManager.cpp | 14 ++++++++ 70 files changed, 146 insertions(+), 210 deletions(-) diff --git a/caps/nsJSPrincipals.cpp b/caps/nsJSPrincipals.cpp index 118bbe2f9f07..db90c29d4159 100644 --- a/caps/nsJSPrincipals.cpp +++ b/caps/nsJSPrincipals.cpp @@ -15,7 +15,7 @@ #include "nsStringBuffer.h" #include "mozilla/dom/StructuredCloneTags.h" -// for mozilla::dom::workers::kJSPrincipalsDebugToken +// for mozilla::dom::workerinternals::kJSPrincipalsDebugToken #include "mozilla/dom/workerinternals/JSSettings.h" #include "mozilla/ipc/BackgroundUtils.h" diff --git a/dom/base/EventSource.cpp b/dom/base/EventSource.cpp index d048240c678c..2b10236dfdcc 100644 --- a/dom/base/EventSource.cpp +++ b/dom/base/EventSource.cpp @@ -50,8 +50,6 @@ namespace mozilla { namespace dom { -using namespace workers; - static LazyLogModule gEventSourceLog("EventSource"); #define SPACE_CHAR (char16_t)0x0020 diff --git a/dom/base/ImageEncoder.cpp b/dom/base/ImageEncoder.cpp index 0301953faa44..90db0c55cb01 100644 --- a/dom/base/ImageEncoder.cpp +++ b/dom/base/ImageEncoder.cpp @@ -89,7 +89,7 @@ public: , mEncodeCompleteCallback(aEncodeCompleteCallback) , mFailed(false) { - if (!NS_IsMainThread() && workers::GetCurrentThreadWorkerPrivate()) { + if (!NS_IsMainThread() && GetCurrentThreadWorkerPrivate()) { mCreationEventTarget = GetCurrentThreadEventTarget(); } else { mCreationEventTarget = GetMainThreadEventTarget(); diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 43742169deba..4a3968281c79 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -2444,9 +2444,9 @@ nsContentUtils::CalcRoundedWindowSizeForResistingFingerprinting(int32_t aChrome bool nsContentUtils::ThreadsafeIsCallerChrome() { - return NS_IsMainThread() ? - IsCallerChrome() : - workers::IsCurrentThreadRunningChromeWorker(); + return NS_IsMainThread() + ? IsCallerChrome() + : IsCurrentThreadRunningChromeWorker(); } bool @@ -2485,7 +2485,7 @@ nsContentUtils::ThreadsafeIsSystemCaller(JSContext* aCx) return IsSystemCaller(aCx); } - return workers::GetWorkerPrivateFromContext(aCx)->UsesSystemPrincipal(); + return GetWorkerPrivateFromContext(aCx)->UsesSystemPrincipal(); } // static @@ -6144,7 +6144,7 @@ nsContentUtils::GetCurrentJSContextForThread() if (MOZ_LIKELY(NS_IsMainThread())) { return GetCurrentJSContext(); } - return workers::GetCurrentThreadJSContext(); + return GetCurrentWorkerThreadJSContext(); } template diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index 233f754058b2..15a119de1b4e 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -1268,7 +1268,7 @@ nsGlobalWindowInner::FreeInnerObjects() mInnerObjectsFreed = true; // Kill all of the workers for this window. - mozilla::dom::workers::CancelWorkersForWindow(this); + CancelWorkersForWindow(this); if (mTimeoutManager) { mTimeoutManager->ClearAllTimeouts(); @@ -6100,7 +6100,7 @@ nsGlobalWindowInner::Suspend() DisableGamepadUpdates(); DisableVRUpdates(); - mozilla::dom::workers::SuspendWorkersForWindow(this); + SuspendWorkersForWindow(this); SuspendIdleRequests(); @@ -6162,7 +6162,7 @@ nsGlobalWindowInner::Resume() // Resume all of the workers for this window. We must do this // after timeouts since workers may have queued events that can trigger // a setTimeout(). - mozilla::dom::workers::ResumeWorkersForWindow(this); + ResumeWorkersForWindow(this); } bool @@ -6195,7 +6195,7 @@ nsGlobalWindowInner::FreezeInternal() return; } - mozilla::dom::workers::FreezeWorkersForWindow(this); + FreezeWorkersForWindow(this); mTimeoutManager->Freeze(); if (mClientSource) { @@ -6234,7 +6234,7 @@ nsGlobalWindowInner::ThawInternal() } mTimeoutManager->Thaw(); - mozilla::dom::workers::ThawWorkersForWindow(this); + ThawWorkersForWindow(this); NotifyDOMWindowThawed(this); } diff --git a/dom/base/nsJSTimeoutHandler.cpp b/dom/base/nsJSTimeoutHandler.cpp index 5cefc193d885..7261edbe5a1e 100644 --- a/dom/base/nsJSTimeoutHandler.cpp +++ b/dom/base/nsJSTimeoutHandler.cpp @@ -23,7 +23,6 @@ using namespace mozilla; using namespace mozilla::dom; -using namespace mozilla::dom::workers; // Our JS nsIScriptTimeoutHandler implementation. class nsJSScriptTimeoutHandler final : public nsIScriptTimeoutHandler diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index c8165254819a..30283116d0e1 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -64,8 +64,6 @@ namespace mozilla { namespace dom { -using namespace workers; - // Forward declare GetConstructorObject methods. #define HTML_TAG(_tag, _classname, _interfacename) \ namespace HTML##_interfacename##ElementBinding { \ diff --git a/dom/broadcastchannel/BroadcastChannel.cpp b/dom/broadcastchannel/BroadcastChannel.cpp index ad9af3201d9d..5f2134b48844 100644 --- a/dom/broadcastchannel/BroadcastChannel.cpp +++ b/dom/broadcastchannel/BroadcastChannel.cpp @@ -32,7 +32,6 @@ using namespace ipc; namespace dom { -using namespace workers; using namespace ipc; class BroadcastChannelMessage final : public StructuredCloneDataNoTransfers diff --git a/dom/broadcastchannel/BroadcastChannelChild.cpp b/dom/broadcastchannel/BroadcastChannelChild.cpp index 1ab5a971919c..bf7098bc3f97 100644 --- a/dom/broadcastchannel/BroadcastChannelChild.cpp +++ b/dom/broadcastchannel/BroadcastChannelChild.cpp @@ -23,8 +23,6 @@ using namespace ipc; namespace dom { -using namespace workers; - BroadcastChannelChild::BroadcastChannelChild(const nsACString& aOrigin) : mBC(nullptr) , mActorDestroyed(false) diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp index aaf389ee5cec..de71609f0a90 100644 --- a/dom/canvas/ImageBitmap.cpp +++ b/dom/canvas/ImageBitmap.cpp @@ -26,8 +26,6 @@ using namespace mozilla::layers; namespace mozilla { namespace dom { -using namespace workers; - NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ImageBitmap, mParent) NS_IMPL_CYCLE_COLLECTING_ADDREF(ImageBitmap) NS_IMPL_CYCLE_COLLECTING_RELEASE(ImageBitmap) diff --git a/dom/canvas/ImageBitmap.h b/dom/canvas/ImageBitmap.h index 29b72d6d705d..75d88c9df374 100644 --- a/dom/canvas/ImageBitmap.h +++ b/dom/canvas/ImageBitmap.h @@ -39,10 +39,6 @@ class Image; namespace dom { class OffscreenCanvas; -namespace workers { -class WorkerStructuredCloneClosure; -} - class ArrayBufferViewOrArrayBuffer; class CanvasRenderingContext2D; struct ChannelPixelLayout; diff --git a/dom/clients/api/Client.cpp b/dom/clients/api/Client.cpp index d8f2a6043dfc..1563bf53f766 100644 --- a/dom/clients/api/Client.cpp +++ b/dom/clients/api/Client.cpp @@ -19,7 +19,6 @@ namespace mozilla { namespace dom { -using namespace workers; using mozilla::dom::ipc::StructuredCloneData; NS_IMPL_CYCLE_COLLECTING_ADDREF(mozilla::dom::Client); diff --git a/dom/clients/api/ClientDOMUtil.h b/dom/clients/api/ClientDOMUtil.h index 5972a5b96166..8c24051a5282 100644 --- a/dom/clients/api/ClientDOMUtil.h +++ b/dom/clients/api/ClientDOMUtil.h @@ -26,8 +26,8 @@ StartClientManagerOp(Func aFunc, const Arg& aArg, nsISerialEventTarget* aTarget, { RefPtr token; if (!NS_IsMainThread()) { - token = WorkerHolderToken::Create(workers::GetCurrentThreadWorkerPrivate(), - mozilla::dom::WorkerStatus::Closing); + token = WorkerHolderToken::Create(GetCurrentThreadWorkerPrivate(), + WorkerStatus::Closing); } RefPtr promise = aFunc(aArg, aTarget); diff --git a/dom/clients/api/Clients.cpp b/dom/clients/api/Clients.cpp index 4c252c07d8f5..b02cc3c7d60f 100644 --- a/dom/clients/api/Clients.cpp +++ b/dom/clients/api/Clients.cpp @@ -21,7 +21,6 @@ namespace mozilla { namespace dom { -using namespace workers; using mozilla::ipc::PrincipalInfo; NS_IMPL_CYCLE_COLLECTING_ADDREF(Clients); diff --git a/dom/clients/manager/ClientManager.cpp b/dom/clients/manager/ClientManager.cpp index 9ed5fba0f768..a0e764b1eaff 100644 --- a/dom/clients/manager/ClientManager.cpp +++ b/dom/clients/manager/ClientManager.cpp @@ -42,7 +42,7 @@ ClientManager::ClientManager() RefPtr workerHolderToken; if (!NS_IsMainThread()) { - WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate(); + WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate(); MOZ_DIAGNOSTIC_ASSERT(workerPrivate); workerHolderToken = diff --git a/dom/console/Console.cpp b/dom/console/Console.cpp index 0f88e5df5820..41bff11a19ea 100644 --- a/dom/console/Console.cpp +++ b/dom/console/Console.cpp @@ -63,7 +63,6 @@ #define STORAGE_MAX_EVENTS 1000 using namespace mozilla::dom::exceptions; -using namespace mozilla::dom::workers; namespace mozilla { namespace dom { diff --git a/dom/crypto/WebCryptoTask.cpp b/dom/crypto/WebCryptoTask.cpp index a24edc9cf14b..99195176f1f8 100644 --- a/dom/crypto/WebCryptoTask.cpp +++ b/dom/crypto/WebCryptoTask.cpp @@ -153,7 +153,7 @@ public: Create() { MOZ_ASSERT(!NS_IsMainThread()); - WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate(); + WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(workerPrivate); RefPtr ref = new InternalWorkerHolder(); if (NS_WARN_IF(!ref->HoldWorker(workerPrivate, Canceling))) { diff --git a/dom/events/Event.cpp b/dom/events/Event.cpp index 91566cc4fb79..8edf9a5491a5 100644 --- a/dom/events/Event.cpp +++ b/dom/events/Event.cpp @@ -334,7 +334,7 @@ bool Event::Init(mozilla::dom::EventTarget* aGlobal) { if (!mIsMainThreadEvent) { - return workers::IsCurrentThreadRunningChromeWorker(); + return IsCurrentThreadRunningChromeWorker(); } bool trusted = false; nsCOMPtr w = do_QueryInterface(aGlobal); @@ -1118,7 +1118,7 @@ Event::TimeStampImpl() const return perf->GetDOMTiming()->TimeStampToDOMHighRes(mEvent->mTimeStamp); } - WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate(); + WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(workerPrivate); return workerPrivate->TimeStampToDOMHighRes(mEvent->mTimeStamp); diff --git a/dom/events/EventDispatcher.cpp b/dom/events/EventDispatcher.cpp index 4a0b96ea6b39..e2159f022ddb 100644 --- a/dom/events/EventDispatcher.cpp +++ b/dom/events/EventDispatcher.cpp @@ -919,7 +919,7 @@ EventDispatcher::DispatchDOMEvent(nsISupports* aTarget, if (!dontResetTrusted) { //Check security state to determine if dispatcher is trusted bool trusted = NS_IsMainThread() ? nsContentUtils::LegacyIsCallerChromeOrNativeCode() - : mozilla::dom::workers::IsCurrentThreadRunningChromeWorker(); + : IsCurrentThreadRunningChromeWorker(); aDOMEvent->SetTrusted(trusted); } diff --git a/dom/events/JSEventHandler.cpp b/dom/events/JSEventHandler.cpp index 0c68087e3e91..6877f4e81e04 100644 --- a/dom/events/JSEventHandler.cpp +++ b/dom/events/JSEventHandler.cpp @@ -126,7 +126,7 @@ JSEventHandler::HandleEvent(nsIDOMEvent* aEvent) nsContentUtils::ObjectPrincipal( GetTypedEventHandler().Ptr()->CallbackPreserveColor()) == nsContentUtils::GetSystemPrincipal() : - mozilla::dom::workers::IsCurrentThreadRunningChromeWorker(); + mozilla::dom::IsCurrentThreadRunningChromeWorker(); if (mTypedHandler.Type() == TypedEventHandler::eOnError) { MOZ_ASSERT_IF(mEventName, mEventName == nsGkAtoms::onerror); diff --git a/dom/fetch/Fetch.cpp b/dom/fetch/Fetch.cpp index ace27100b607..bd86e1c592ec 100644 --- a/dom/fetch/Fetch.cpp +++ b/dom/fetch/Fetch.cpp @@ -53,8 +53,6 @@ namespace mozilla { namespace dom { -using namespace workers; - namespace { void diff --git a/dom/fetch/FetchConsumer.cpp b/dom/fetch/FetchConsumer.cpp index e09b874ae9b5..eafd0735edf8 100644 --- a/dom/fetch/FetchConsumer.cpp +++ b/dom/fetch/FetchConsumer.cpp @@ -18,8 +18,6 @@ namespace mozilla { namespace dom { -using namespace workers; - namespace { template diff --git a/dom/fetch/FetchDriver.cpp b/dom/fetch/FetchDriver.cpp index 0d8d8944f623..2132f13a9e7f 100644 --- a/dom/fetch/FetchDriver.cpp +++ b/dom/fetch/FetchDriver.cpp @@ -198,7 +198,7 @@ NS_IMETHODIMP AlternativeDataStreamListener::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); MOZ_ASSERT(!mAlternativeDataType.IsEmpty()); // Checking the alternative data type is the same between we asked and the // saved in the channel. @@ -274,7 +274,7 @@ AlternativeDataStreamListener::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext, nsresult aStatusCode) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); // Alternative data loading is going to finish, breaking the reference cycle // here by taking the ownership to a loacl variable. @@ -363,7 +363,7 @@ FetchDriver::~FetchDriver() nsresult FetchDriver::Fetch(AbortSignal* aSignal, FetchDriverObserver* aObserver) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); #ifdef DEBUG MOZ_ASSERT(!mFetchCalled); mFetchCalled = true; @@ -771,7 +771,7 @@ FetchDriver::BeginAndGetFilteredResponse(InternalResponse* aResponse, void FetchDriver::FailWithNetworkError(nsresult rv) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); RefPtr error = InternalResponse::NetworkError(rv); if (mObserver) { mObserver->OnResponseAvailable(error); @@ -789,7 +789,7 @@ NS_IMETHODIMP FetchDriver::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); // Note, this can be called multiple times if we are doing an opaqueredirect. // In that case we will get a simulated OnStartRequest() and then the real @@ -1151,7 +1151,7 @@ FetchDriver::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext, nsresult aStatusCode) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); MOZ_DIAGNOSTIC_ASSERT(!mOnStopRequestCalled); mOnStopRequestCalled = true; @@ -1217,7 +1217,7 @@ FetchDriver::OnStopRequest(nsIRequest* aRequest, nsresult FetchDriver::FinishOnStopRequest(AlternativeDataStreamListener* aAltDataListener) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); // OnStopRequest is not called from channel, that means the main data loading // does not finish yet. Reaching here since alternative data loading finishes. if (!mOnStopRequestCalled) { diff --git a/dom/fetch/FetchStream.cpp b/dom/fetch/FetchStream.cpp index 50311810e720..6afec80b1914 100644 --- a/dom/fetch/FetchStream.cpp +++ b/dom/fetch/FetchStream.cpp @@ -20,8 +20,6 @@ static NS_DEFINE_CID(kStreamTransportServiceCID, namespace mozilla { namespace dom { -using namespace workers; - namespace { class FetchStreamWorkerHolder final : public WorkerHolder diff --git a/dom/fetch/FetchStreamReader.cpp b/dom/fetch/FetchStreamReader.cpp index 9be7210cce74..82bf0c5425be 100644 --- a/dom/fetch/FetchStreamReader.cpp +++ b/dom/fetch/FetchStreamReader.cpp @@ -16,8 +16,6 @@ namespace mozilla { namespace dom { -using namespace workers; - namespace { class FetchStreamReaderWorkerHolder final : public WorkerHolder diff --git a/dom/file/FileBlobImpl.cpp b/dom/file/FileBlobImpl.cpp index b365a8a997b5..b063cdbe7c0e 100644 --- a/dom/file/FileBlobImpl.cpp +++ b/dom/file/FileBlobImpl.cpp @@ -169,7 +169,7 @@ FileBlobImpl::GetType(nsAString& aType) "Should only use lazy ContentType when using the whole file"); if (!NS_IsMainThread()) { - WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate(); + WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate(); if (!workerPrivate) { // I have no idea in which thread this method is called. We cannot // return any valid value. diff --git a/dom/file/FileReader.cpp b/dom/file/FileReader.cpp index 7984807bec2b..5bacf529da00 100644 --- a/dom/file/FileReader.cpp +++ b/dom/file/FileReader.cpp @@ -139,7 +139,7 @@ FileReader::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) if (!NS_IsMainThread()) { JSContext* cx = aGlobal.Context(); - workerPrivate = workers::GetWorkerPrivateFromContext(cx); + workerPrivate = GetWorkerPrivateFromContext(cx); MOZ_ASSERT(workerPrivate); } diff --git a/dom/file/FileReaderSync.cpp b/dom/file/FileReaderSync.cpp index 4972205f7611..fb9ef3ed83b1 100644 --- a/dom/file/FileReaderSync.cpp +++ b/dom/file/FileReaderSync.cpp @@ -441,7 +441,7 @@ FileReaderSync::SyncRead(nsIInputStream* aStream, char* aBuffer, return rv; } - WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate(); + WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(workerPrivate); AutoSyncLoopHolder syncLoop(workerPrivate, Closing); diff --git a/dom/file/ipc/IPCBlobInputStreamChild.cpp b/dom/file/ipc/IPCBlobInputStreamChild.cpp index a25af14533a6..09d587bcecbc 100644 --- a/dom/file/ipc/IPCBlobInputStreamChild.cpp +++ b/dom/file/ipc/IPCBlobInputStreamChild.cpp @@ -15,8 +15,6 @@ namespace mozilla { namespace dom { -using namespace workers; - namespace { // This runnable is used in case the last stream is forgotten on the 'wrong' diff --git a/dom/indexedDB/ActorsChild.cpp b/dom/indexedDB/ActorsChild.cpp index 271a7db2d608..63e4f6cbe1b3 100644 --- a/dom/indexedDB/ActorsChild.cpp +++ b/dom/indexedDB/ActorsChild.cpp @@ -72,8 +72,6 @@ using ipc::PrincipalInfo; namespace dom { -using namespace workers; - namespace indexedDB { /******************************************************************************* diff --git a/dom/indexedDB/IDBObjectStore.cpp b/dom/indexedDB/IDBObjectStore.cpp index f63e3a4f1cc7..0bccf9d45cee 100644 --- a/dom/indexedDB/IDBObjectStore.cpp +++ b/dom/indexedDB/IDBObjectStore.cpp @@ -63,7 +63,6 @@ namespace dom { using namespace mozilla::dom::indexedDB; using namespace mozilla::dom::quota; -using namespace mozilla::dom::workers; using namespace mozilla::ipc; struct IDBObjectStore::StructuredCloneWriteInfo diff --git a/dom/indexedDB/IDBRequest.cpp b/dom/indexedDB/IDBRequest.cpp index bf898fce0128..26c1dec073b9 100644 --- a/dom/indexedDB/IDBRequest.cpp +++ b/dom/indexedDB/IDBRequest.cpp @@ -40,7 +40,6 @@ namespace mozilla { namespace dom { using namespace mozilla::dom::indexedDB; -using namespace mozilla::dom::workers; using namespace mozilla::ipc; namespace { diff --git a/dom/indexedDB/IDBTransaction.cpp b/dom/indexedDB/IDBTransaction.cpp index 87b39c492094..530f61f46991 100644 --- a/dom/indexedDB/IDBTransaction.cpp +++ b/dom/indexedDB/IDBTransaction.cpp @@ -33,7 +33,6 @@ namespace mozilla { namespace dom { using namespace mozilla::dom::indexedDB; -using namespace mozilla::dom::workers; using namespace mozilla::ipc; class IDBTransaction::WorkerHolder final : public mozilla::dom::WorkerHolder diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index 4dccd9abb86a..93346d385245 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -73,7 +73,6 @@ namespace dom { namespace indexedDB { using namespace mozilla::dom::quota; -using namespace mozilla::dom::workers; using namespace mozilla::ipc; class FileManagerInfo diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 2874710befdf..5f923b364ff9 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -234,7 +234,6 @@ using namespace mozilla; using namespace mozilla::docshell; using namespace mozilla::dom::ipc; -using namespace mozilla::dom::workers; using namespace mozilla::media; using namespace mozilla::embedding; using namespace mozilla::gmp; diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 7305f3a90242..a5633fb0ad2c 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -147,7 +147,6 @@ using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::dom::ipc; -using namespace mozilla::dom::workers; using namespace mozilla::ipc; using namespace mozilla::layers; using namespace mozilla::layout; diff --git a/dom/messagechannel/MessagePort.cpp b/dom/messagechannel/MessagePort.cpp index dbd30da85d6f..38e6806fb6df 100644 --- a/dom/messagechannel/MessagePort.cpp +++ b/dom/messagechannel/MessagePort.cpp @@ -42,8 +42,6 @@ #undef PostMessage #endif -using namespace mozilla::dom::workers; - namespace mozilla { namespace dom { diff --git a/dom/notification/Notification.cpp b/dom/notification/Notification.cpp index 450607531a1d..a22bc0c03157 100644 --- a/dom/notification/Notification.cpp +++ b/dom/notification/Notification.cpp @@ -61,8 +61,6 @@ namespace mozilla { namespace dom { -using namespace workers; - struct NotificationStrings { const nsString mID; diff --git a/dom/notification/Notification.h b/dom/notification/Notification.h index 6ea6bbdbd8e6..4526b8f0d605 100644 --- a/dom/notification/Notification.h +++ b/dom/notification/Notification.h @@ -370,7 +370,7 @@ protected: void GetAlertName(nsAString& aRetval) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); if (mAlertName.IsEmpty()) { SetAlertName(); } diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp index e31e2a5d1514..20a4c79249a8 100644 --- a/dom/performance/Performance.cpp +++ b/dom/performance/Performance.cpp @@ -541,7 +541,7 @@ Performance::IsObserverEnabled(JSContext* aCx, JSObject* aGlobal) return Preferences::GetBool("dom.enable_performance_observer", false); } - WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate(); + WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(workerPrivate); workerPrivate->AssertIsOnWorkerThread(); diff --git a/dom/performance/PerformanceObserver.cpp b/dom/performance/PerformanceObserver.cpp index 1c3853c60f23..860df104e266 100644 --- a/dom/performance/PerformanceObserver.cpp +++ b/dom/performance/PerformanceObserver.cpp @@ -88,7 +88,7 @@ PerformanceObserver::Constructor(const GlobalObject& aGlobal, } JSContext* cx = aGlobal.Context(); - WorkerPrivate* workerPrivate = workers::GetWorkerPrivateFromContext(cx); + WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx); MOZ_ASSERT(workerPrivate); RefPtr observer = diff --git a/dom/promise/Promise.cpp b/dom/promise/Promise.cpp index ed950d67348a..b4f48353b150 100644 --- a/dom/promise/Promise.cpp +++ b/dom/promise/Promise.cpp @@ -494,7 +494,7 @@ Promise::ReportRejectedPromise(JSContext* aCx, JS::HandleObject aPromise) RefPtr xpcReport = new xpc::ErrorReport(); bool isMainThread = MOZ_LIKELY(NS_IsMainThread()); bool isChrome = isMainThread ? nsContentUtils::IsSystemPrincipal(nsContentUtils::ObjectPrincipal(aPromise)) - : workers::GetCurrentThreadWorkerPrivate()->IsChromeWorker(); + : GetCurrentThreadWorkerPrivate()->IsChromeWorker(); nsGlobalWindowInner* win = isMainThread ? xpc::WindowGlobalOrNull(aPromise) : nullptr; @@ -762,7 +762,7 @@ void PromiseWorkerProxy::CleanProperties() { #ifdef DEBUG - WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate(); + WorkerPrivate* worker = GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(worker); worker->AssertIsOnWorkerThread(); #endif @@ -815,7 +815,7 @@ Promise* PromiseWorkerProxy::WorkerPromise() const { #ifdef DEBUG - WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate(); + WorkerPrivate* worker = GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(worker); worker->AssertIsOnWorkerThread(); #endif diff --git a/dom/push/PushManager.cpp b/dom/push/PushManager.cpp index f291bd027731..e260bb54088f 100644 --- a/dom/push/PushManager.cpp +++ b/dom/push/PushManager.cpp @@ -32,9 +32,6 @@ namespace mozilla { namespace dom { -using namespace workers; -using workers::AssertIsOnMainThread; - namespace { nsresult diff --git a/dom/push/PushNotifier.cpp b/dom/push/PushNotifier.cpp index be292451cac7..00860a4b6778 100644 --- a/dom/push/PushNotifier.cpp +++ b/dom/push/PushNotifier.cpp @@ -24,8 +24,6 @@ namespace mozilla { namespace dom { -using workers::AssertIsOnMainThread; - PushNotifier::PushNotifier() {} diff --git a/dom/push/PushSubscription.cpp b/dom/push/PushSubscription.cpp index dae636c99953..ce37e081590c 100644 --- a/dom/push/PushSubscription.cpp +++ b/dom/push/PushSubscription.cpp @@ -23,8 +23,6 @@ namespace mozilla { namespace dom { -using namespace workers; - namespace { class UnsubscribeResultCallback final : public nsIUnsubscribeResultCallback diff --git a/dom/quota/StorageManager.cpp b/dom/quota/StorageManager.cpp index aaa18d361820..16e4dd8c92a0 100644 --- a/dom/quota/StorageManager.cpp +++ b/dom/quota/StorageManager.cpp @@ -19,8 +19,6 @@ #include "nsIQuotaRequests.h" #include "nsPIDOMWindow.h" -using namespace mozilla::dom::workers; - namespace mozilla { namespace dom { diff --git a/dom/script/ScriptSettings.cpp b/dom/script/ScriptSettings.cpp index 1ea4fcf94597..f23f68724d77 100644 --- a/dom/script/ScriptSettings.cpp +++ b/dom/script/ScriptSettings.cpp @@ -544,7 +544,7 @@ WarningOnlyErrorReporter(JSContext* aCx, JSErrorReport* aRep) // That said, it feels like we should be able to short-circuit things a bit // here by posting an appropriate runnable to the main thread directly... // Worth looking into sometime. - WorkerPrivate* worker = workers::GetWorkerPrivateFromContext(aCx); + WorkerPrivate* worker = GetWorkerPrivateFromContext(aCx); MOZ_ASSERT(worker); worker->ReportError(aCx, JS::ConstUTF8CharsZ(), aRep); @@ -581,7 +581,7 @@ AutoJSAPI::ReportException() if (mIsMainThread) { errorGlobal = xpc::PrivilegedJunkScope(); } else { - errorGlobal = workers::GetCurrentThreadWorkerGlobal(); + errorGlobal = GetCurrentThreadWorkerGlobal(); } } JSAutoCompartment ac(cx(), errorGlobal); @@ -617,7 +617,7 @@ AutoJSAPI::ReportException() // bother with xpc::ErrorReport. This will ensure that all the right // events (which are a lot more complicated than in the window case) get // fired. - WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate(); + WorkerPrivate* worker = GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(worker); MOZ_ASSERT(worker->GetJSContext() == cx()); // Before invoking ReportError, put the exception back on the context, diff --git a/dom/serviceworkers/ServiceWorkerEvents.cpp b/dom/serviceworkers/ServiceWorkerEvents.cpp index 669ff2623896..049901ded9c6 100644 --- a/dom/serviceworkers/ServiceWorkerEvents.cpp +++ b/dom/serviceworkers/ServiceWorkerEvents.cpp @@ -51,7 +51,6 @@ using namespace mozilla; using namespace mozilla::dom; -using namespace mozilla::dom::workers; namespace { diff --git a/dom/serviceworkers/ServiceWorkerRegistration.cpp b/dom/serviceworkers/ServiceWorkerRegistration.cpp index b152de7255b7..aa5e2e07d0f9 100644 --- a/dom/serviceworkers/ServiceWorkerRegistration.cpp +++ b/dom/serviceworkers/ServiceWorkerRegistration.cpp @@ -32,8 +32,6 @@ #include "nsPIDOMWindow.h" #include "nsContentUtils.h" -using namespace mozilla::dom::workers; - namespace mozilla { namespace dom { diff --git a/dom/url/URLWorker.cpp b/dom/url/URLWorker.cpp index 3a3120f19ec1..7da2f5d970e4 100644 --- a/dom/url/URLWorker.cpp +++ b/dom/url/URLWorker.cpp @@ -20,9 +20,6 @@ using net::nsStandardURL; namespace dom { -using namespace workers; -using workers::AssertIsOnMainThread; - // Proxy class to forward all the requests to a URLMainThread object. class URLWorker::URLProxy final { diff --git a/dom/websocket/WebSocket.cpp b/dom/websocket/WebSocket.cpp index f56b3754e3fb..f5a2a11f0360 100644 --- a/dom/websocket/WebSocket.cpp +++ b/dom/websocket/WebSocket.cpp @@ -68,7 +68,6 @@ #define CLOSE_EVENT_STRING NS_LITERAL_STRING("close") using namespace mozilla::net; -using namespace mozilla::dom::workers; namespace mozilla { namespace dom { diff --git a/dom/workers/MessageEventRunnable.cpp b/dom/workers/MessageEventRunnable.cpp index a0d1327a7e1e..a1804b2093b7 100644 --- a/dom/workers/MessageEventRunnable.cpp +++ b/dom/workers/MessageEventRunnable.cpp @@ -130,7 +130,7 @@ MessageEventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) !aWorkerPrivate->GetParent()); } - MOZ_ASSERT(aWorkerPrivate == workers::GetWorkerPrivateFromContext(aCx)); + MOZ_ASSERT(aWorkerPrivate == GetWorkerPrivateFromContext(aCx)); return DispatchDOMEvent(aCx, aWorkerPrivate, aWorkerPrivate->GlobalScope(), false); diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 151b9e4c2ba0..37c7e51eee44 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -84,7 +84,6 @@ using namespace ipc; namespace dom { -using namespace workers; using namespace workerinternals; namespace workerinternals { @@ -135,7 +134,7 @@ static_assert(MAX_WORKERS_PER_DOMAIN >= 1, PR_BEGIN_MACRO \ AssertIsOnMainThread(); \ \ - AutoTArray workers; \ + AutoTArray workers; \ { \ MutexAutoLock lock(mMutex); \ \ @@ -935,14 +934,16 @@ JSObject* Wrap(JSContext *cx, JS::HandleObject existing, JS::HandleObject obj) { JSObject* targetGlobal = JS::CurrentGlobalOrNull(cx); - if (!IsDebuggerGlobal(targetGlobal) && !IsDebuggerSandbox(targetGlobal)) { + if (!IsWorkerDebuggerGlobal(targetGlobal) && + !IsWorkerDebuggerSandbox(targetGlobal)) { MOZ_CRASH("There should be no edges from the debuggee to the debugger."); } JSObject* originGlobal = js::GetGlobalForObjectCrossCompartment(obj); const js::Wrapper* wrapper = nullptr; - if (IsDebuggerGlobal(originGlobal) || IsDebuggerSandbox(originGlobal)) { + if (IsWorkerDebuggerGlobal(originGlobal) || + IsWorkerDebuggerSandbox(originGlobal)) { wrapper = &js::CrossCompartmentWrapper::singleton; } else { wrapper = &js::OpaqueCrossCompartmentWrapper::singleton; @@ -1123,7 +1124,7 @@ public: std::queue>* microTaskQueue = nullptr; - JSContext* cx = GetCurrentThreadJSContext(); + JSContext* cx = GetCurrentWorkerThreadJSContext(); NS_ASSERTION(cx, "This should never be null!"); JS::Rooted global(cx, JS::CurrentGlobalOrNull(cx)); @@ -1136,7 +1137,8 @@ public: if (IsWorkerGlobal(global)) { microTaskQueue = &mPromiseMicroTaskQueue; } else { - MOZ_ASSERT(IsDebuggerGlobal(global) || IsDebuggerSandbox(global)); + MOZ_ASSERT(IsWorkerDebuggerGlobal(global) || + IsWorkerDebuggerSandbox(global)); microTaskQueue = &mDebuggerPromiseMicroTaskQueue; } @@ -2812,8 +2814,6 @@ WorkerThreadPrimaryRunnable::FinishedRunnable::Run() } // workerinternals namespace -namespace workers { - void CancelWorkersForWindow(nsPIDOMWindowInner* aWindow) { @@ -2906,7 +2906,7 @@ IsCurrentThreadRunningChromeWorker() } JSContext* -GetCurrentThreadJSContext() +GetCurrentWorkerThreadJSContext() { WorkerPrivate* wp = GetCurrentThreadWorkerPrivate(); if (!wp) { @@ -2929,17 +2929,5 @@ GetCurrentThreadWorkerGlobal() return scope->GetGlobalJSObject(); } -#ifdef DEBUG - -void -AssertIsOnMainThread() -{ - MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); -} - -#endif - -} // workers namespace - } // dom namespace } // mozilla namespace diff --git a/dom/workers/RuntimeService.h b/dom/workers/RuntimeService.h index c4d977939225..c557c2ab5a00 100644 --- a/dom/workers/RuntimeService.h +++ b/dom/workers/RuntimeService.h @@ -173,14 +173,14 @@ public: static void GetDefaultJSSettings(workerinternals::JSSettings& aSettings) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); aSettings = sDefaultJSSettings; } static void SetDefaultContextOptions(const JS::ContextOptions& aContextOptions) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); sDefaultJSSettings.contextOptions = aContextOptions; } @@ -202,7 +202,7 @@ public: static void SetDefaultJSGCSettings(JSGCParamKey aKey, uint32_t aValue) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); sDefaultJSSettings.ApplyGCSetting(aKey, aValue); } @@ -213,7 +213,7 @@ public: static void SetDefaultGCZeal(uint8_t aGCZeal, uint32_t aFrequency) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); sDefaultJSSettings.gcZeal = aGCZeal; sDefaultJSSettings.gcZealFrequency = aFrequency; } diff --git a/dom/workers/ScriptLoader.cpp b/dom/workers/ScriptLoader.cpp index 70ab449ce64f..a37576145d9a 100644 --- a/dom/workers/ScriptLoader.cpp +++ b/dom/workers/ScriptLoader.cpp @@ -80,8 +80,6 @@ using mozilla::ipc::PrincipalInfo; namespace mozilla { namespace dom { -using namespace workers; - namespace { nsIURI* diff --git a/dom/workers/WorkerCommon.h b/dom/workers/WorkerCommon.h index 6ae01fefa888..c5faa79beab5 100644 --- a/dom/workers/WorkerCommon.h +++ b/dom/workers/WorkerCommon.h @@ -18,19 +18,8 @@ namespace dom { class WorkerPrivate; -namespace workers { - // All of these are implemented in RuntimeService.cpp -#ifdef DEBUG -void -AssertIsOnMainThread(); -#else -inline void -AssertIsOnMainThread() -{ } -#endif - WorkerPrivate* GetWorkerPrivateFromContext(JSContext* aCx); @@ -41,7 +30,7 @@ bool IsCurrentThreadRunningChromeWorker(); JSContext* -GetCurrentThreadJSContext(); +GetCurrentWorkerThreadJSContext(); JSObject* GetCurrentThreadWorkerGlobal(); @@ -67,12 +56,11 @@ bool IsWorkerGlobal(JSObject* global); bool -IsDebuggerGlobal(JSObject* global); +IsWorkerDebuggerGlobal(JSObject* global); bool -IsDebuggerSandbox(JSObject* object); +IsWorkerDebuggerSandbox(JSObject* object); -} // workers namespace } // dom namespace } // mozilla namespace diff --git a/dom/workers/WorkerError.cpp b/dom/workers/WorkerError.cpp index 56c47ed29156..e7603ccd5ee1 100644 --- a/dom/workers/WorkerError.cpp +++ b/dom/workers/WorkerError.cpp @@ -100,7 +100,7 @@ public: UNWRAP_OBJECT(WorkerDebuggerGlobalScope, &global, globalScope); MOZ_ASSERT_IF(globalScope, globalScope->GetWrapperPreserveColor() == global); - if (globalScope || IsDebuggerSandbox(global)) { + if (globalScope || IsWorkerDebuggerSandbox(global)) { aWorkerPrivate->ReportErrorToDebugger(aReport.mFilename, aReport.mLineNumber, aReport.mMessage); return; @@ -356,7 +356,7 @@ WorkerErrorReport::ReportError(JSContext* aCx, WorkerPrivate* aWorkerPrivate, UNWRAP_OBJECT(WorkerDebuggerGlobalScope, &global, globalScope); MOZ_ASSERT_IF(globalScope, globalScope->GetWrapperPreserveColor() == global); - if (globalScope || IsDebuggerSandbox(global)) { + if (globalScope || IsWorkerDebuggerSandbox(global)) { aWorkerPrivate->ReportErrorToDebugger(aReport.mFilename, aReport.mLineNumber, aReport.mMessage); return; diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index ea88fb9048af..99c240b848e1 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -96,7 +96,6 @@ using namespace ipc; namespace dom { -using namespace workers; using namespace workerinternals; MOZ_DEFINE_MALLOC_SIZE_OF(JsWorkerMallocSizeOf) diff --git a/dom/workers/WorkerPrivate.h b/dom/workers/WorkerPrivate.h index 1e1e7869440d..f9702650af10 100644 --- a/dom/workers/WorkerPrivate.h +++ b/dom/workers/WorkerPrivate.h @@ -406,7 +406,7 @@ public: nsIScriptContext* GetScriptContext() const { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return mLoadInfo.mScriptContext; } @@ -455,7 +455,7 @@ public: nsIURI* GetBaseURI() const { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return mLoadInfo.mBaseURI; } @@ -465,7 +465,7 @@ public: nsIURI* GetResolvedScriptURI() const { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return mLoadInfo.mResolvedScriptURI; } @@ -473,7 +473,7 @@ public: ServiceWorkerCacheName() const { MOZ_DIAGNOSTIC_ASSERT(IsServiceWorker()); - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return mLoadInfo.mServiceWorkerCacheName; } @@ -508,7 +508,7 @@ public: void SetChannelInfo(const ChannelInfo& aChannelInfo) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); MOZ_ASSERT(!mLoadInfo.mChannelInfo.IsInitialized()); MOZ_ASSERT(aChannelInfo.IsInitialized()); mLoadInfo.mChannelInfo = aChannelInfo; @@ -569,14 +569,14 @@ public: nsIPrincipal* GetPrincipal() const { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return mLoadInfo.mPrincipal; } nsIPrincipal* GetLoadingPrincipal() const { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return mLoadInfo.mLoadingPrincipal; } @@ -588,7 +588,7 @@ public: nsILoadGroup* GetLoadGroup() const { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return mLoadInfo.mLoadGroup; } @@ -630,7 +630,7 @@ public: already_AddRefed ForgetWorkerChannel() { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return mLoadInfo.mChannel.forget(); } @@ -639,14 +639,14 @@ public: nsPIDOMWindowInner* GetWindow() { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return mLoadInfo.mWindow; } nsIContentSecurityPolicy* GetCSP() const { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return mLoadInfo.mCSP; } @@ -1007,7 +1007,7 @@ public: bool IsDebuggerRegistered() { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); // No need to lock here since this is only ever modified by the same thread. return mDebuggerRegistered; @@ -1016,7 +1016,7 @@ public: void SetIsDebuggerRegistered(bool aDebuggerRegistered) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); MutexAutoLock lock(mMutex); @@ -1043,7 +1043,7 @@ public: WorkerDebugger* Debugger() const { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); MOZ_ASSERT(mDebugger); return mDebugger; @@ -1052,7 +1052,7 @@ public: void SetDebugger(WorkerDebugger* aDebugger) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); MOZ_ASSERT(mDebugger != aDebugger); mDebugger = aDebugger; diff --git a/dom/workers/WorkerRunnable.cpp b/dom/workers/WorkerRunnable.cpp index 32761c1a4dbc..305be9284044 100644 --- a/dom/workers/WorkerRunnable.cpp +++ b/dom/workers/WorkerRunnable.cpp @@ -284,7 +284,7 @@ WorkerRunnable::Run() MOZ_ASSERT(isMainThread == NS_IsMainThread()); RefPtr kungFuDeathGrip; if (targetIsWorkerThread) { - JSContext* cx = GetCurrentThreadJSContext(); + JSContext* cx = GetCurrentWorkerThreadJSContext(); if (NS_WARN_IF(!cx)) { return NS_ERROR_FAILURE; } @@ -473,7 +473,7 @@ MainThreadStopSyncLoopRunnable::MainThreadStopSyncLoopRunnable( bool aResult) : WorkerSyncRunnable(aWorkerPrivate, Move(aSyncLoopTarget)), mResult(aResult) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); #ifdef DEBUG mWorkerPrivate->AssertValidSyncLoop(mSyncLoopTarget); #endif @@ -607,7 +607,7 @@ WorkerMainThreadRunnable::Dispatch(WorkerStatus aFailStatus, NS_IMETHODIMP WorkerMainThreadRunnable::Run() { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); bool runResult = MainThreadRun(); @@ -699,7 +699,7 @@ WorkerProxyToMainThreadRunnable::Dispatch() NS_IMETHODIMP WorkerProxyToMainThreadRunnable::Run() { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); RunOnMainThread(); PostDispatchOnMainThread(); return NS_OK; diff --git a/dom/workers/WorkerRunnable.h b/dom/workers/WorkerRunnable.h index 161bdd72053e..29b570e29683 100644 --- a/dom/workers/WorkerRunnable.h +++ b/dom/workers/WorkerRunnable.h @@ -145,13 +145,14 @@ protected: // parent global (which is the compartment reflector would have been in), or // in the null compartment if there is no parent global. For other mBehavior // values, we're running on the worker thread and aCx is in whatever - // compartment GetCurrentThreadJSContext() was in when nsIRunnable::Run() got - // called. This is actually important for cases when a runnable spins a - // syncloop and wants everything that happens during the syncloop to happen in - // the compartment that runnable set up (which may, for example, be a debugger - // sandbox compartment!). If aCx wasn't in a compartment to start with, aCx - // will be in either the debugger global's compartment or the worker's - // global's compartment depending on whether IsDebuggerRunnable() is true. + // compartment GetCurrentWorkerThreadJSContext() was in when + // nsIRunnable::Run() got called. This is actually important for cases when a + // runnable spins a syncloop and wants everything that happens during the + // syncloop to happen in the compartment that runnable set up (which may, for + // example, be a debugger sandbox compartment!). If aCx wasn't in a + // compartment to start with, aCx will be in either the debugger global's + // compartment or the worker's global's compartment depending on whether + // IsDebuggerRunnable() is true. // // Immediately after WorkerRun returns, the caller will assert that either it // returns false or there is no exception pending on aCx. Then it will report @@ -201,7 +202,7 @@ private: virtual bool PreDispatch(WorkerPrivate* aWorkerPrivate) override final { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return true; } @@ -243,14 +244,14 @@ protected: nsIEventTarget* aSyncLoopTarget) : WorkerSyncRunnable(aWorkerPrivate, aSyncLoopTarget) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); } MainThreadWorkerSyncRunnable(WorkerPrivate* aWorkerPrivate, already_AddRefed&& aSyncLoopTarget) : WorkerSyncRunnable(aWorkerPrivate, Move(aSyncLoopTarget)) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); } virtual ~MainThreadWorkerSyncRunnable() @@ -260,7 +261,7 @@ private: virtual bool PreDispatch(WorkerPrivate* aWorkerPrivate) override { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return true; } @@ -313,7 +314,7 @@ protected: explicit MainThreadWorkerRunnable(WorkerPrivate* aWorkerPrivate) : WorkerRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); } virtual ~MainThreadWorkerRunnable() @@ -322,7 +323,7 @@ protected: virtual bool PreDispatch(WorkerPrivate* aWorkerPrivate) override { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return true; } @@ -330,7 +331,7 @@ protected: PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); } }; @@ -349,7 +350,7 @@ protected: virtual bool PreDispatch(WorkerPrivate* aWorkerPrivate) override { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return true; } @@ -357,7 +358,7 @@ protected: PostDispatch(WorkerPrivate* aWorkerPrivate, bool aDispatchResult) override { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); } }; @@ -505,7 +506,7 @@ private: virtual bool PreDispatch(WorkerPrivate* aWorkerPrivate) override final { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); return true; } diff --git a/dom/workers/WorkerScope.cpp b/dom/workers/WorkerScope.cpp index 0ada073861db..e7460e573e7b 100644 --- a/dom/workers/WorkerScope.cpp +++ b/dom/workers/WorkerScope.cpp @@ -984,7 +984,7 @@ WorkerDebuggerGlobalScope::LoadSubScript(JSContext* aCx, Maybe ac; if (aSandbox.WasPassed()) { JS::Rooted sandbox(aCx, js::CheckedUnwrap(aSandbox.Value())); - if (!IsDebuggerSandbox(sandbox)) { + if (!IsWorkerDebuggerSandbox(sandbox)) { aRv.Throw(NS_ERROR_INVALID_ARG); return; } @@ -1117,8 +1117,6 @@ WorkerDebuggerGlobalScope::AbstractMainThreadFor(TaskCategory aCategory) MOZ_CRASH("AbstractMainThreadFor not supported for workers."); } -namespace workers { - bool IsWorkerGlobal(JSObject* object) { @@ -1126,18 +1124,17 @@ IsWorkerGlobal(JSObject* object) } bool -IsDebuggerGlobal(JSObject* object) +IsWorkerDebuggerGlobal(JSObject* object) { return IS_INSTANCE_OF(WorkerDebuggerGlobalScope, object); } bool -IsDebuggerSandbox(JSObject* object) +IsWorkerDebuggerSandbox(JSObject* object) { return SimpleGlobalObject::SimpleGlobalType(object) == SimpleGlobalObject::GlobalType::WorkerDebuggerSandbox; } -} // workers namespace } // dom namespace } // mozilla namespace diff --git a/dom/xhr/XMLHttpRequestWorker.cpp b/dom/xhr/XMLHttpRequestWorker.cpp index bfc57e8ec7f6..eba4589c0da6 100644 --- a/dom/xhr/XMLHttpRequestWorker.cpp +++ b/dom/xhr/XMLHttpRequestWorker.cpp @@ -161,7 +161,7 @@ public: void Reset() { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); if (mUploadEventListenersAttached) { AddRemoveEventListeners(true, false); @@ -171,7 +171,7 @@ public: already_AddRefed GetEventTarget() { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); nsCOMPtr target = mSyncEventResponseTarget ? mSyncEventResponseTarget : @@ -372,7 +372,7 @@ private: NS_IMETHOD Run() override { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); // This means the XHR was GC'd, so we can't be pinned, and we don't need to // try to unpin. @@ -449,7 +449,7 @@ public: , mChannelId(mProxy->mInnerChannelId) , mReceivedLoadStart(false) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); CopyASCIItoUTF16(sEventStrings[STRING_loadstart], mEventType); } @@ -460,7 +460,7 @@ public: bool RegisterAndDispatch() { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); if (NS_FAILED(mXHR->AddEventListener(mEventType, this, false, false, 2))) { NS_WARNING("Failed to add event listener!"); @@ -473,7 +473,7 @@ public: private: ~LoadStartDetectionRunnable() { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); } }; @@ -852,7 +852,7 @@ public: bool Proxy::Init() { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); MOZ_ASSERT(mWorkerPrivate); if (mXHR) { @@ -895,7 +895,7 @@ Proxy::Init() void Proxy::Teardown(bool aSendUnpin) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); if (mXHR) { Reset(); @@ -945,7 +945,7 @@ Proxy::Teardown(bool aSendUnpin) bool Proxy::AddRemoveEventListeners(bool aUpload, bool aAdd) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); NS_ASSERTION(!aUpload || (mUploadEventListenersAttached && !aAdd) || @@ -985,7 +985,7 @@ NS_IMPL_ISUPPORTS(Proxy, nsIDOMEventListener) NS_IMETHODIMP Proxy::HandleEvent(nsIDOMEvent* aEvent) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); if (!mWorkerPrivate || !mXMLHttpRequestPrivate) { NS_ERROR("Shouldn't get here!"); @@ -1066,7 +1066,7 @@ NS_IMPL_ISUPPORTS_INHERITED(LoadStartDetectionRunnable, Runnable, NS_IMETHODIMP LoadStartDetectionRunnable::Run() { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); if (NS_FAILED(mXHR->RemoveEventListener(mEventType, this, false))) { NS_WARNING("Failed to remove event listener!"); @@ -1098,7 +1098,7 @@ LoadStartDetectionRunnable::Run() NS_IMETHODIMP LoadStartDetectionRunnable::HandleEvent(nsIDOMEvent* aEvent) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); #ifdef DEBUG { @@ -1119,7 +1119,7 @@ LoadStartDetectionRunnable::HandleEvent(nsIDOMEvent* aEvent) bool EventRunnable::PreDispatch(WorkerPrivate* /* unused */) { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); AutoJSAPI jsapi; DebugOnly ok = jsapi.Init(xpc::NativeGlobal(mScopeObj)); @@ -1374,7 +1374,7 @@ EventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) bool WorkerThreadProxySyncRunnable::MainThreadRun() { - workers::AssertIsOnMainThread(); + AssertIsOnMainThread(); nsCOMPtr tempTarget = mSyncLoopTarget; @@ -1589,7 +1589,7 @@ XMLHttpRequestWorker::Construct(const GlobalObject& aGlobal, ErrorResult& aRv) { JSContext* cx = aGlobal.Context(); - WorkerPrivate* workerPrivate = workers::GetWorkerPrivateFromContext(cx); + WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(cx); MOZ_ASSERT(workerPrivate); RefPtr xhr = new XMLHttpRequestWorker(workerPrivate); diff --git a/gfx/thebes/gfxUtils.cpp b/gfx/thebes/gfxUtils.cpp index 294f8fbe357c..09b1a26e7a91 100644 --- a/gfx/thebes/gfxUtils.cpp +++ b/gfx/thebes/gfxUtils.cpp @@ -1458,8 +1458,7 @@ gfxUtils::ThreadSafeGetFeatureStatus(const nsCOMPtr& gfxInfo, int32_t* status) { if (!NS_IsMainThread()) { - dom::WorkerPrivate* workerPrivate = - dom::workers::GetCurrentThreadWorkerPrivate(); + dom::WorkerPrivate* workerPrivate = dom::GetCurrentThreadWorkerPrivate(); RefPtr runnable = new GetFeatureStatusRunnable(workerPrivate, gfxInfo, feature, failureId, diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.cpp index a05770efd64f..7dfd293debff 100644 --- a/ipc/glue/BackgroundParentImpl.cpp +++ b/ipc/glue/BackgroundParentImpl.cpp @@ -70,15 +70,10 @@ using mozilla::dom::MessagePortParent; using mozilla::dom::PMessagePortParent; using mozilla::dom::UDPSocketParent; using mozilla::dom::WebAuthnTransactionParent; +using mozilla::AssertIsOnMainThread; namespace { -void -AssertIsOnMainThread() -{ - MOZ_ASSERT(NS_IsMainThread()); -} - class TestParent final : public mozilla::ipc::PBackgroundTestParent { friend class mozilla::ipc::BackgroundParentImpl; diff --git a/ipc/glue/IPCStreamSource.cpp b/ipc/glue/IPCStreamSource.cpp index 5ecd9548b9a5..f58cbf8261c2 100644 --- a/ipc/glue/IPCStreamSource.cpp +++ b/ipc/glue/IPCStreamSource.cpp @@ -137,7 +137,7 @@ IPCStreamSource::Initialize() // do not need anything special in order to be kept alive. WorkerPrivate* workerPrivate = nullptr; if (!NS_IsMainThread()) { - workerPrivate = mozilla::dom::workers::GetCurrentThreadWorkerPrivate(); + workerPrivate = mozilla::dom::GetCurrentThreadWorkerPrivate(); if (workerPrivate) { bool result = HoldWorker(workerPrivate, WorkerStatus::Canceling); if (!result) { diff --git a/js/src/devtools/rootAnalysis/annotations.js b/js/src/devtools/rootAnalysis/annotations.js index 3853b9c01c91..b0c42566d5a0 100644 --- a/js/src/devtools/rootAnalysis/annotations.js +++ b/js/src/devtools/rootAnalysis/annotations.js @@ -226,7 +226,7 @@ var ignoreFunctions = { "void js::AutoEnterOOMUnsafeRegion::crash(uint64, int8*)" : true, - "void mozilla::dom::workers::WorkerPrivate::AssertIsOnWorkerThread() const" : true, + "void mozilla::dom::WorkerPrivate::AssertIsOnWorkerThread() const" : true, // It would be cool to somehow annotate that nsTHashtable will use // nsTHashtable::s_MatchEntry for its matchEntry function pointer, but diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index b0821c95f5ff..cfb1eebdb632 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -1243,9 +1243,7 @@ IsChromeOrXBL(JSContext* cx, JSObject* /* unused */) return AccessCheck::isChrome(c) || IsContentXBLCompartment(c) || !AllowContentXBLScope(realm); } -namespace workers { extern bool IsCurrentThreadRunningChromeWorker(); -} bool ThreadSafeIsChromeOrXBL(JSContext* cx, JSObject* obj) @@ -1253,7 +1251,7 @@ ThreadSafeIsChromeOrXBL(JSContext* cx, JSObject* obj) if (NS_IsMainThread()) { return IsChromeOrXBL(cx, obj); } - return workers::IsCurrentThreadRunningChromeWorker(); + return IsCurrentThreadRunningChromeWorker(); } } // namespace dom diff --git a/xpcom/threads/MainThreadUtils.h b/xpcom/threads/MainThreadUtils.h index 9e2ffa467b01..7c9dceb96d4e 100644 --- a/xpcom/threads/MainThreadUtils.h +++ b/xpcom/threads/MainThreadUtils.h @@ -30,6 +30,20 @@ extern nsIThread* NS_GetCurrentThread(); #ifdef MOZILLA_INTERNAL_API bool NS_IsMainThreadTLSInitialized(); bool NS_IsMainThread(); + +namespace mozilla { + +#ifdef DEBUG +void +AssertIsOnMainThread(); +#else +inline void +AssertIsOnMainThread() +{ } +#endif + +} // mozilla namespace + #endif #endif // MainThreadUtils_h_ diff --git a/xpcom/threads/nsThreadManager.cpp b/xpcom/threads/nsThreadManager.cpp index 5816bf86f1d7..e06630cb4771 100644 --- a/xpcom/threads/nsThreadManager.cpp +++ b/xpcom/threads/nsThreadManager.cpp @@ -78,6 +78,20 @@ NS_UnsetMainThread() gTlsCurrentVirtualThread.set(nullptr); } +#ifdef DEBUG + +namespace mozilla { + +void +AssertIsOnMainThread() +{ + MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!"); +} + +} // mozilla namespace + +#endif + typedef nsTArray>> nsThreadArray; //-----------------------------------------------------------------------------