зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1435174 - Remove the renaming 'using namespace workers', r=bkelly
This commit is contained in:
Родитель
86b49a3834
Коммит
8cdf705535
|
@ -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"
|
||||
|
||||
|
|
|
@ -50,8 +50,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
|
||||
static LazyLogModule gEventSourceLog("EventSource");
|
||||
|
||||
#define SPACE_CHAR (char16_t)0x0020
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
, mEncodeCompleteCallback(aEncodeCompleteCallback)
|
||||
, mFailed(false)
|
||||
{
|
||||
if (!NS_IsMainThread() && workers::GetCurrentThreadWorkerPrivate()) {
|
||||
if (!NS_IsMainThread() && GetCurrentThreadWorkerPrivate()) {
|
||||
mCreationEventTarget = GetCurrentThreadEventTarget();
|
||||
} else {
|
||||
mCreationEventTarget = GetMainThreadEventTarget();
|
||||
|
|
|
@ -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<typename StringType, typename CharType>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 { \
|
||||
|
|
|
@ -32,7 +32,6 @@ using namespace ipc;
|
|||
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
using namespace ipc;
|
||||
|
||||
class BroadcastChannelMessage final : public StructuredCloneDataNoTransfers
|
||||
|
|
|
@ -23,8 +23,6 @@ using namespace ipc;
|
|||
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
|
||||
BroadcastChannelChild::BroadcastChannelChild(const nsACString& aOrigin)
|
||||
: mBC(nullptr)
|
||||
, mActorDestroyed(false)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -39,10 +39,6 @@ class Image;
|
|||
namespace dom {
|
||||
class OffscreenCanvas;
|
||||
|
||||
namespace workers {
|
||||
class WorkerStructuredCloneClosure;
|
||||
}
|
||||
|
||||
class ArrayBufferViewOrArrayBuffer;
|
||||
class CanvasRenderingContext2D;
|
||||
struct ChannelPixelLayout;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
using mozilla::dom::ipc::StructuredCloneData;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(mozilla::dom::Client);
|
||||
|
|
|
@ -26,8 +26,8 @@ StartClientManagerOp(Func aFunc, const Arg& aArg, nsISerialEventTarget* aTarget,
|
|||
{
|
||||
RefPtr<WorkerHolderToken> token;
|
||||
if (!NS_IsMainThread()) {
|
||||
token = WorkerHolderToken::Create(workers::GetCurrentThreadWorkerPrivate(),
|
||||
mozilla::dom::WorkerStatus::Closing);
|
||||
token = WorkerHolderToken::Create(GetCurrentThreadWorkerPrivate(),
|
||||
WorkerStatus::Closing);
|
||||
}
|
||||
|
||||
RefPtr<ClientOpPromise> promise = aFunc(aArg, aTarget);
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
using mozilla::ipc::PrincipalInfo;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(Clients);
|
||||
|
|
|
@ -42,7 +42,7 @@ ClientManager::ClientManager()
|
|||
|
||||
RefPtr<WorkerHolderToken> workerHolderToken;
|
||||
if (!NS_IsMainThread()) {
|
||||
WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_DIAGNOSTIC_ASSERT(workerPrivate);
|
||||
|
||||
workerHolderToken =
|
||||
|
|
|
@ -63,7 +63,6 @@
|
|||
#define STORAGE_MAX_EVENTS 1000
|
||||
|
||||
using namespace mozilla::dom::exceptions;
|
||||
using namespace mozilla::dom::workers;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
|
|
@ -153,7 +153,7 @@ public:
|
|||
Create()
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
|
||||
WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
|
||||
MOZ_ASSERT(workerPrivate);
|
||||
RefPtr<InternalWorkerHolder> ref = new InternalWorkerHolder();
|
||||
if (NS_WARN_IF(!ref->HoldWorker(workerPrivate, Canceling))) {
|
||||
|
|
|
@ -334,7 +334,7 @@ bool
|
|||
Event::Init(mozilla::dom::EventTarget* aGlobal)
|
||||
{
|
||||
if (!mIsMainThreadEvent) {
|
||||
return workers::IsCurrentThreadRunningChromeWorker();
|
||||
return IsCurrentThreadRunningChromeWorker();
|
||||
}
|
||||
bool trusted = false;
|
||||
nsCOMPtr<nsPIDOMWindowInner> 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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -53,8 +53,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
|
||||
namespace {
|
||||
|
||||
void
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
|
||||
namespace {
|
||||
|
||||
template <class Derived>
|
||||
|
|
|
@ -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<InternalResponse> 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) {
|
||||
|
|
|
@ -20,8 +20,6 @@ static NS_DEFINE_CID(kStreamTransportServiceCID,
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
|
||||
namespace {
|
||||
|
||||
class FetchStreamWorkerHolder final : public WorkerHolder
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
|
||||
namespace {
|
||||
|
||||
class FetchStreamReaderWorkerHolder final : public WorkerHolder
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -72,8 +72,6 @@ using ipc::PrincipalInfo;
|
|||
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
|
||||
namespace indexedDB {
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -40,7 +40,6 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
|
||||
using namespace mozilla::dom::indexedDB;
|
||||
using namespace mozilla::dom::workers;
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -73,7 +73,6 @@ namespace dom {
|
|||
namespace indexedDB {
|
||||
|
||||
using namespace mozilla::dom::quota;
|
||||
using namespace mozilla::dom::workers;
|
||||
using namespace mozilla::ipc;
|
||||
|
||||
class FileManagerInfo
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -42,8 +42,6 @@
|
|||
#undef PostMessage
|
||||
#endif
|
||||
|
||||
using namespace mozilla::dom::workers;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
|
|
@ -61,8 +61,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
|
||||
struct NotificationStrings
|
||||
{
|
||||
const nsString mID;
|
||||
|
|
|
@ -370,7 +370,7 @@ protected:
|
|||
|
||||
void GetAlertName(nsAString& aRetval)
|
||||
{
|
||||
workers::AssertIsOnMainThread();
|
||||
AssertIsOnMainThread();
|
||||
if (mAlertName.IsEmpty()) {
|
||||
SetAlertName();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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<PerformanceObserver> observer =
|
||||
|
|
|
@ -494,7 +494,7 @@ Promise::ReportRejectedPromise(JSContext* aCx, JS::HandleObject aPromise)
|
|||
RefPtr<xpc::ErrorReport> 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
|
||||
|
|
|
@ -32,9 +32,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
using workers::AssertIsOnMainThread;
|
||||
|
||||
namespace {
|
||||
|
||||
nsresult
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using workers::AssertIsOnMainThread;
|
||||
|
||||
PushNotifier::PushNotifier()
|
||||
{}
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
|
||||
namespace {
|
||||
|
||||
class UnsubscribeResultCallback final : public nsIUnsubscribeResultCallback
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
#include "nsIQuotaRequests.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
using namespace mozilla::dom::workers;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -51,7 +51,6 @@
|
|||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::dom::workers;
|
||||
|
||||
namespace {
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@
|
|||
#include "nsPIDOMWindow.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
using namespace mozilla::dom::workers;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -84,7 +84,6 @@ using namespace ipc;
|
|||
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
using namespace workerinternals;
|
||||
|
||||
namespace workerinternals {
|
||||
|
@ -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<nsCOMPtr<nsIRunnable>>* microTaskQueue = nullptr;
|
||||
|
||||
JSContext* cx = GetCurrentThreadJSContext();
|
||||
JSContext* cx = GetCurrentWorkerThreadJSContext();
|
||||
NS_ASSERTION(cx, "This should never be null!");
|
||||
|
||||
JS::Rooted<JSObject*> 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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -80,8 +80,6 @@ using mozilla::ipc::PrincipalInfo;
|
|||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
|
||||
namespace {
|
||||
|
||||
nsIURI*
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -96,7 +96,6 @@ using namespace ipc;
|
|||
|
||||
namespace dom {
|
||||
|
||||
using namespace workers;
|
||||
using namespace workerinternals;
|
||||
|
||||
MOZ_DEFINE_MALLOC_SIZE_OF(JsWorkerMallocSizeOf)
|
||||
|
|
|
@ -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<nsIChannel>
|
||||
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;
|
||||
|
|
|
@ -284,7 +284,7 @@ WorkerRunnable::Run()
|
|||
MOZ_ASSERT(isMainThread == NS_IsMainThread());
|
||||
RefPtr<WorkerPrivate> 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;
|
||||
|
|
|
@ -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<nsIEventTarget>&& 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -984,7 +984,7 @@ WorkerDebuggerGlobalScope::LoadSubScript(JSContext* aCx,
|
|||
Maybe<JSAutoCompartment> ac;
|
||||
if (aSandbox.WasPassed()) {
|
||||
JS::Rooted<JSObject*> 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
|
||||
|
|
|
@ -161,7 +161,7 @@ public:
|
|||
void
|
||||
Reset()
|
||||
{
|
||||
workers::AssertIsOnMainThread();
|
||||
AssertIsOnMainThread();
|
||||
|
||||
if (mUploadEventListenersAttached) {
|
||||
AddRemoveEventListeners(true, false);
|
||||
|
@ -171,7 +171,7 @@ public:
|
|||
already_AddRefed<nsIEventTarget>
|
||||
GetEventTarget()
|
||||
{
|
||||
workers::AssertIsOnMainThread();
|
||||
AssertIsOnMainThread();
|
||||
|
||||
nsCOMPtr<nsIEventTarget> 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<bool> ok = jsapi.Init(xpc::NativeGlobal(mScopeObj));
|
||||
|
@ -1374,7 +1374,7 @@ EventRunnable::WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate)
|
|||
bool
|
||||
WorkerThreadProxySyncRunnable::MainThreadRun()
|
||||
{
|
||||
workers::AssertIsOnMainThread();
|
||||
AssertIsOnMainThread();
|
||||
|
||||
nsCOMPtr<nsIEventTarget> 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<XMLHttpRequestWorker> xhr = new XMLHttpRequestWorker(workerPrivate);
|
||||
|
|
|
@ -1458,8 +1458,7 @@ gfxUtils::ThreadSafeGetFeatureStatus(const nsCOMPtr<nsIGfxInfo>& gfxInfo,
|
|||
int32_t* status)
|
||||
{
|
||||
if (!NS_IsMainThread()) {
|
||||
dom::WorkerPrivate* workerPrivate =
|
||||
dom::workers::GetCurrentThreadWorkerPrivate();
|
||||
dom::WorkerPrivate* workerPrivate = dom::GetCurrentThreadWorkerPrivate();
|
||||
|
||||
RefPtr<GetFeatureStatusRunnable> runnable =
|
||||
new GetFeatureStatusRunnable(workerPrivate, gfxInfo, feature, failureId,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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<T> will use
|
||||
// nsTHashtable<T>::s_MatchEntry for its matchEntry function pointer, but
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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_
|
||||
|
|
|
@ -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<NotNull<RefPtr<nsThread>>> nsThreadArray;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
Загрузка…
Ссылка в новой задаче