зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1432963 - Fixing workers headers - part 16 - JSSettings in a workerinternals namespace, r=smaug
This commit is contained in:
Родитель
a5bed23bd8
Коммит
7e52540256
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "mozilla/dom/StructuredCloneTags.h"
|
#include "mozilla/dom/StructuredCloneTags.h"
|
||||||
// for mozilla::dom::workers::kJSPrincipalsDebugToken
|
// for mozilla::dom::workers::kJSPrincipalsDebugToken
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/workerinternals/JSSettings.h"
|
||||||
#include "mozilla/ipc/BackgroundUtils.h"
|
#include "mozilla/ipc/BackgroundUtils.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
|
@ -90,7 +90,7 @@ JSPrincipals::dump()
|
||||||
nsresult rv = static_cast<nsJSPrincipals *>(this)->GetScriptLocation(str);
|
nsresult rv = static_cast<nsJSPrincipals *>(this)->GetScriptLocation(str);
|
||||||
fprintf(stderr, "nsIPrincipal (%p) = %s\n", static_cast<void*>(this),
|
fprintf(stderr, "nsIPrincipal (%p) = %s\n", static_cast<void*>(this),
|
||||||
NS_SUCCEEDED(rv) ? str.get() : "(unknown)");
|
NS_SUCCEEDED(rv) ? str.get() : "(unknown)");
|
||||||
} else if (debugToken == dom::workers::kJSPrincipalsDebugToken) {
|
} else if (debugToken == dom::workerinternals::kJSPrincipalsDebugToken) {
|
||||||
fprintf(stderr, "Web Worker principal singleton (%p)\n", this);
|
fprintf(stderr, "Web Worker principal singleton (%p)\n", this);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
#include "mozilla/dom/VRDisplay.h"
|
#include "mozilla/dom/VRDisplay.h"
|
||||||
#include "mozilla/dom/VRDisplayEvent.h"
|
#include "mozilla/dom/VRDisplayEvent.h"
|
||||||
#include "mozilla/dom/VRServiceTest.h"
|
#include "mozilla/dom/VRServiceTest.h"
|
||||||
#include "mozilla/dom/workers/RuntimeService.h"
|
#include "mozilla/dom/workerinternals/RuntimeService.h"
|
||||||
#include "mozilla/Hal.h"
|
#include "mozilla/Hal.h"
|
||||||
#include "mozilla/ClearOnShutdown.h"
|
#include "mozilla/ClearOnShutdown.h"
|
||||||
#include "mozilla/StaticPtr.h"
|
#include "mozilla/StaticPtr.h"
|
||||||
|
@ -692,7 +692,8 @@ Navigator::JavaEnabled(CallerType aCallerType, ErrorResult& aRv)
|
||||||
uint64_t
|
uint64_t
|
||||||
Navigator::HardwareConcurrency()
|
Navigator::HardwareConcurrency()
|
||||||
{
|
{
|
||||||
workers::RuntimeService* rts = workers::RuntimeService::GetOrCreateService();
|
workerinternals::RuntimeService* rts =
|
||||||
|
workerinternals::RuntimeService::GetOrCreateService();
|
||||||
if (!rts) {
|
if (!rts) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
#include "nsContentCID.h"
|
#include "nsContentCID.h"
|
||||||
#include "nsLayoutStatics.h"
|
#include "nsLayoutStatics.h"
|
||||||
#include "nsCCUncollectableMarker.h"
|
#include "nsCCUncollectableMarker.h"
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
#include "mozilla/dom/ToJSValue.h"
|
#include "mozilla/dom/ToJSValue.h"
|
||||||
#include "nsJSPrincipals.h"
|
#include "nsJSPrincipals.h"
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
#include "nsContentCID.h"
|
#include "nsContentCID.h"
|
||||||
#include "nsLayoutStatics.h"
|
#include "nsLayoutStatics.h"
|
||||||
#include "nsCCUncollectableMarker.h"
|
#include "nsCCUncollectableMarker.h"
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
#include "mozilla/dom/ToJSValue.h"
|
#include "mozilla/dom/ToJSValue.h"
|
||||||
#include "nsJSPrincipals.h"
|
#include "nsJSPrincipals.h"
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#include "mozilla/dom/File.h"
|
#include "mozilla/dom/File.h"
|
||||||
#include "mozilla/dom/PerformanceStorage.h"
|
#include "mozilla/dom/PerformanceStorage.h"
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
#include "mozilla/EventStateManager.h"
|
#include "mozilla/EventStateManager.h"
|
||||||
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
#include "mozilla/ipc/PBackgroundSharedTypes.h"
|
||||||
#include "mozilla/Unused.h"
|
#include "mozilla/Unused.h"
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
#include "mozilla/ErrorResult.h"
|
#include "mozilla/ErrorResult.h"
|
||||||
#include "mozilla/dom/FetchTypes.h"
|
#include "mozilla/dom/FetchTypes.h"
|
||||||
#include "mozilla/dom/ScriptSettings.h"
|
#include "mozilla/dom/ScriptSettings.h"
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
|
||||||
|
|
||||||
#include "WorkerPrivate.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
|
#include "mozilla/dom/WorkerPrivate.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "mozilla/dom/Event.h"
|
#include "mozilla/dom/Event.h"
|
||||||
#include "mozilla/dom/NotificationEventBinding.h"
|
#include "mozilla/dom/NotificationEventBinding.h"
|
||||||
#include "mozilla/dom/ServiceWorkerEvents.h"
|
#include "mozilla/dom/ServiceWorkerEvents.h"
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
#include "mozilla/dom/PromiseWorkerProxy.h"
|
#include "mozilla/dom/PromiseWorkerProxy.h"
|
||||||
#include "mozilla/dom/PushSubscriptionOptions.h"
|
#include "mozilla/dom/PushSubscriptionOptions.h"
|
||||||
#include "mozilla/dom/PushUtil.h"
|
#include "mozilla/dom/PushUtil.h"
|
||||||
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
#include "mozilla/dom/WorkerPrivate.h"
|
#include "mozilla/dom/WorkerPrivate.h"
|
||||||
#include "mozilla/dom/WorkerScope.h"
|
#include "mozilla/dom/WorkerScope.h"
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "mozilla/dom/File.h"
|
#include "mozilla/dom/File.h"
|
||||||
#include "mozilla/dom/Promise.h"
|
#include "mozilla/dom/Promise.h"
|
||||||
#include "mozilla/dom/Response.h"
|
#include "mozilla/dom/Response.h"
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
|
|
||||||
#include "nsProxyRelease.h"
|
#include "nsProxyRelease.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include "MainThreadUtils.h"
|
#include "MainThreadUtils.h"
|
||||||
#include "mozilla/dom/ServiceWorkerBinding.h" // For ServiceWorkerState
|
#include "mozilla/dom/ServiceWorkerBinding.h" // For ServiceWorkerState
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
#include "mozilla/OriginAttributes.h"
|
#include "mozilla/OriginAttributes.h"
|
||||||
#include "nsIServiceWorkerManager.h"
|
#include "nsIServiceWorkerManager.h"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,132 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#ifndef mozilla_dom_workerinternals_JSSettings_h
|
||||||
|
#define mozilla_dom_workerinternals_JSSettings_h
|
||||||
|
|
||||||
|
#include "jsapi.h"
|
||||||
|
#include "mozilla/Maybe.h"
|
||||||
|
#include "nsString.h"
|
||||||
|
#include "nsTArray.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
namespace workerinternals {
|
||||||
|
|
||||||
|
// Random unique constant to facilitate JSPrincipal debugging
|
||||||
|
const uint32_t kJSPrincipalsDebugToken = 0x7e2df9d2;
|
||||||
|
|
||||||
|
struct JSSettings
|
||||||
|
{
|
||||||
|
enum {
|
||||||
|
// All the GC parameters that we support.
|
||||||
|
JSSettings_JSGC_MAX_BYTES = 0,
|
||||||
|
JSSettings_JSGC_MAX_MALLOC_BYTES,
|
||||||
|
JSSettings_JSGC_HIGH_FREQUENCY_TIME_LIMIT,
|
||||||
|
JSSettings_JSGC_LOW_FREQUENCY_HEAP_GROWTH,
|
||||||
|
JSSettings_JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN,
|
||||||
|
JSSettings_JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX,
|
||||||
|
JSSettings_JSGC_HIGH_FREQUENCY_LOW_LIMIT,
|
||||||
|
JSSettings_JSGC_HIGH_FREQUENCY_HIGH_LIMIT,
|
||||||
|
JSSettings_JSGC_ALLOCATION_THRESHOLD,
|
||||||
|
JSSettings_JSGC_SLICE_TIME_BUDGET,
|
||||||
|
JSSettings_JSGC_DYNAMIC_HEAP_GROWTH,
|
||||||
|
JSSettings_JSGC_DYNAMIC_MARK_SLICE,
|
||||||
|
// JSGC_MODE not supported
|
||||||
|
|
||||||
|
// This must be last so that we get an accurate count.
|
||||||
|
kGCSettingsArraySize
|
||||||
|
};
|
||||||
|
|
||||||
|
struct JSGCSetting
|
||||||
|
{
|
||||||
|
mozilla::Maybe<JSGCParamKey> key;
|
||||||
|
uint32_t value;
|
||||||
|
|
||||||
|
JSGCSetting()
|
||||||
|
: key(), value(0)
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
// There are several settings that we know we need so it makes sense to
|
||||||
|
// preallocate here.
|
||||||
|
typedef JSGCSetting JSGCSettingsArray[kGCSettingsArraySize];
|
||||||
|
|
||||||
|
// Settings that change based on chrome/content context.
|
||||||
|
struct JSContentChromeSettings
|
||||||
|
{
|
||||||
|
JS::CompartmentOptions compartmentOptions;
|
||||||
|
int32_t maxScriptRuntime;
|
||||||
|
|
||||||
|
JSContentChromeSettings()
|
||||||
|
: compartmentOptions(), maxScriptRuntime(0)
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
JSContentChromeSettings chrome;
|
||||||
|
JSContentChromeSettings content;
|
||||||
|
JSGCSettingsArray gcSettings;
|
||||||
|
JS::ContextOptions contextOptions;
|
||||||
|
|
||||||
|
#ifdef JS_GC_ZEAL
|
||||||
|
uint8_t gcZeal;
|
||||||
|
uint32_t gcZealFrequency;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
JSSettings()
|
||||||
|
#ifdef JS_GC_ZEAL
|
||||||
|
: gcZeal(0), gcZealFrequency(0)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
for (uint32_t index = 0; index < ArrayLength(gcSettings); index++) {
|
||||||
|
new (gcSettings + index) JSGCSetting();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ApplyGCSetting(JSGCParamKey aKey, uint32_t aValue)
|
||||||
|
{
|
||||||
|
JSSettings::JSGCSetting* firstEmptySetting = nullptr;
|
||||||
|
JSSettings::JSGCSetting* foundSetting = nullptr;
|
||||||
|
|
||||||
|
for (uint32_t index = 0; index < ArrayLength(gcSettings); index++) {
|
||||||
|
JSSettings::JSGCSetting& setting = gcSettings[index];
|
||||||
|
if (setting.key.isSome() && *setting.key == aKey) {
|
||||||
|
foundSetting = &setting;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!firstEmptySetting && setting.key.isNothing()) {
|
||||||
|
firstEmptySetting = &setting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aValue) {
|
||||||
|
if (!foundSetting) {
|
||||||
|
foundSetting = firstEmptySetting;
|
||||||
|
if (!foundSetting) {
|
||||||
|
NS_ERROR("Not enough space for this value!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foundSetting->key = mozilla::Some(aKey);
|
||||||
|
foundSetting->value = aValue;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (foundSetting) {
|
||||||
|
foundSetting->key.reset();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // workerinternals namespace
|
||||||
|
} // dom namespace
|
||||||
|
} // mozilla namespace
|
||||||
|
|
||||||
|
#endif // mozilla_dom_workerinternals_JSSettings_h
|
|
@ -36,7 +36,7 @@ GetWorkerPrincipal()
|
||||||
--sPrincipal.refcount;
|
--sPrincipal.refcount;
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
sPrincipal.debugToken = workers::kJSPrincipalsDebugToken;
|
sPrincipal.debugToken = workerinternals::kJSPrincipalsDebugToken;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,17 +4,17 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#ifndef mozilla_dom_workers_queue_h__
|
#ifndef mozilla_dom_workerinternal_Queue_h
|
||||||
#define mozilla_dom_workers_queue_h__
|
#define mozilla_dom_workerinternal_Queue_h
|
||||||
|
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
|
|
||||||
#include "mozilla/Mutex.h"
|
#include "mozilla/Mutex.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
namespace workersinternals {
|
namespace workerinternals {
|
||||||
|
|
||||||
template <typename T, int TCount>
|
template <typename T, int TCount>
|
||||||
struct StorageWithTArray
|
struct StorageWithTArray
|
||||||
|
@ -200,8 +200,8 @@ private:
|
||||||
Queue & operator=(const Queue&);
|
Queue & operator=(const Queue&);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // workersinternals namespace
|
} // workerinternals namespace
|
||||||
} // dom namespace
|
} // dom namespace
|
||||||
} // mozilla namespace
|
} // mozilla namespace
|
||||||
|
|
||||||
#endif /* mozilla_dom_workers_queue_h__ */
|
#endif /* mozilla_dom_workerinternals_Queue_h*/
|
||||||
|
|
|
@ -83,7 +83,11 @@ namespace mozilla {
|
||||||
using namespace ipc;
|
using namespace ipc;
|
||||||
|
|
||||||
namespace dom {
|
namespace dom {
|
||||||
namespace workers {
|
|
||||||
|
using namespace workers;
|
||||||
|
using namespace workerinternals;
|
||||||
|
|
||||||
|
namespace workerinternals {
|
||||||
|
|
||||||
// The size of the worker runtime heaps in bytes. May be changed via pref.
|
// The size of the worker runtime heaps in bytes. May be changed via pref.
|
||||||
#define WORKER_DEFAULT_RUNTIME_HEAPSIZE 32 * 1024 * 1024
|
#define WORKER_DEFAULT_RUNTIME_HEAPSIZE 32 * 1024 * 1024
|
||||||
|
@ -1251,131 +1255,6 @@ PlatformOverrideChanged(const char* /* aPrefName */, void* /* aClosure */)
|
||||||
|
|
||||||
} /* anonymous namespace */
|
} /* anonymous namespace */
|
||||||
|
|
||||||
void
|
|
||||||
CancelWorkersForWindow(nsPIDOMWindowInner* aWindow)
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
RuntimeService* runtime = RuntimeService::GetService();
|
|
||||||
if (runtime) {
|
|
||||||
runtime->CancelWorkersForWindow(aWindow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
FreezeWorkersForWindow(nsPIDOMWindowInner* aWindow)
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
RuntimeService* runtime = RuntimeService::GetService();
|
|
||||||
if (runtime) {
|
|
||||||
runtime->FreezeWorkersForWindow(aWindow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ThawWorkersForWindow(nsPIDOMWindowInner* aWindow)
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
RuntimeService* runtime = RuntimeService::GetService();
|
|
||||||
if (runtime) {
|
|
||||||
runtime->ThawWorkersForWindow(aWindow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
SuspendWorkersForWindow(nsPIDOMWindowInner* aWindow)
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
RuntimeService* runtime = RuntimeService::GetService();
|
|
||||||
if (runtime) {
|
|
||||||
runtime->SuspendWorkersForWindow(aWindow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ResumeWorkersForWindow(nsPIDOMWindowInner* aWindow)
|
|
||||||
{
|
|
||||||
AssertIsOnMainThread();
|
|
||||||
RuntimeService* runtime = RuntimeService::GetService();
|
|
||||||
if (runtime) {
|
|
||||||
runtime->ResumeWorkersForWindow(aWindow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkerPrivate*
|
|
||||||
GetWorkerPrivateFromContext(JSContext* aCx)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(!NS_IsMainThread());
|
|
||||||
MOZ_ASSERT(aCx);
|
|
||||||
|
|
||||||
void* cxPrivate = JS_GetContextPrivate(aCx);
|
|
||||||
if (!cxPrivate) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
static_cast<WorkerThreadContextPrivate*>(cxPrivate)->GetWorkerPrivate();
|
|
||||||
}
|
|
||||||
|
|
||||||
WorkerPrivate*
|
|
||||||
GetCurrentThreadWorkerPrivate()
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(!NS_IsMainThread());
|
|
||||||
|
|
||||||
CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
|
|
||||||
if (!ccjscx) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
JSContext* cx = ccjscx->Context();
|
|
||||||
MOZ_ASSERT(cx);
|
|
||||||
|
|
||||||
// Note that we can return nullptr if the nsCycleCollector_shutdown() in
|
|
||||||
// ~WorkerJSContext() triggers any calls to GetCurrentThreadWorkerPrivate().
|
|
||||||
// At this stage CycleCollectedJSContext::Get() will still return a context,
|
|
||||||
// but the context private has already been cleared.
|
|
||||||
return GetWorkerPrivateFromContext(cx);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
IsCurrentThreadRunningChromeWorker()
|
|
||||||
{
|
|
||||||
return GetCurrentThreadWorkerPrivate()->UsesSystemPrincipal();
|
|
||||||
}
|
|
||||||
|
|
||||||
JSContext*
|
|
||||||
GetCurrentThreadJSContext()
|
|
||||||
{
|
|
||||||
WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
|
|
||||||
if (!wp) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return wp->GetJSContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
JSObject*
|
|
||||||
GetCurrentThreadWorkerGlobal()
|
|
||||||
{
|
|
||||||
WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
|
|
||||||
if (!wp) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
WorkerGlobalScope* scope = wp->GlobalScope();
|
|
||||||
if (!scope) {
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return scope->GetGlobalJSObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
|
|
||||||
void
|
|
||||||
AssertIsOnMainThread()
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct RuntimeService::IdleThreadInfo
|
struct RuntimeService::IdleThreadInfo
|
||||||
{
|
{
|
||||||
RefPtr<WorkerThread> mThread;
|
RefPtr<WorkerThread> mThread;
|
||||||
|
@ -2931,6 +2810,136 @@ WorkerThreadPrimaryRunnable::FinishedRunnable::Run()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // workerinternals namespace
|
||||||
|
|
||||||
|
namespace workers {
|
||||||
|
|
||||||
|
void
|
||||||
|
CancelWorkersForWindow(nsPIDOMWindowInner* aWindow)
|
||||||
|
{
|
||||||
|
AssertIsOnMainThread();
|
||||||
|
RuntimeService* runtime = RuntimeService::GetService();
|
||||||
|
if (runtime) {
|
||||||
|
runtime->CancelWorkersForWindow(aWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
FreezeWorkersForWindow(nsPIDOMWindowInner* aWindow)
|
||||||
|
{
|
||||||
|
AssertIsOnMainThread();
|
||||||
|
RuntimeService* runtime = RuntimeService::GetService();
|
||||||
|
if (runtime) {
|
||||||
|
runtime->FreezeWorkersForWindow(aWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ThawWorkersForWindow(nsPIDOMWindowInner* aWindow)
|
||||||
|
{
|
||||||
|
AssertIsOnMainThread();
|
||||||
|
RuntimeService* runtime = RuntimeService::GetService();
|
||||||
|
if (runtime) {
|
||||||
|
runtime->ThawWorkersForWindow(aWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SuspendWorkersForWindow(nsPIDOMWindowInner* aWindow)
|
||||||
|
{
|
||||||
|
AssertIsOnMainThread();
|
||||||
|
RuntimeService* runtime = RuntimeService::GetService();
|
||||||
|
if (runtime) {
|
||||||
|
runtime->SuspendWorkersForWindow(aWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ResumeWorkersForWindow(nsPIDOMWindowInner* aWindow)
|
||||||
|
{
|
||||||
|
AssertIsOnMainThread();
|
||||||
|
RuntimeService* runtime = RuntimeService::GetService();
|
||||||
|
if (runtime) {
|
||||||
|
runtime->ResumeWorkersForWindow(aWindow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkerPrivate*
|
||||||
|
GetWorkerPrivateFromContext(JSContext* aCx)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(!NS_IsMainThread());
|
||||||
|
MOZ_ASSERT(aCx);
|
||||||
|
|
||||||
|
void* cxPrivate = JS_GetContextPrivate(aCx);
|
||||||
|
if (!cxPrivate) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
static_cast<WorkerThreadContextPrivate*>(cxPrivate)->GetWorkerPrivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
WorkerPrivate*
|
||||||
|
GetCurrentThreadWorkerPrivate()
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(!NS_IsMainThread());
|
||||||
|
|
||||||
|
CycleCollectedJSContext* ccjscx = CycleCollectedJSContext::Get();
|
||||||
|
if (!ccjscx) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSContext* cx = ccjscx->Context();
|
||||||
|
MOZ_ASSERT(cx);
|
||||||
|
|
||||||
|
// Note that we can return nullptr if the nsCycleCollector_shutdown() in
|
||||||
|
// ~WorkerJSContext() triggers any calls to GetCurrentThreadWorkerPrivate().
|
||||||
|
// At this stage CycleCollectedJSContext::Get() will still return a context,
|
||||||
|
// but the context private has already been cleared.
|
||||||
|
return GetWorkerPrivateFromContext(cx);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
IsCurrentThreadRunningChromeWorker()
|
||||||
|
{
|
||||||
|
return GetCurrentThreadWorkerPrivate()->UsesSystemPrincipal();
|
||||||
|
}
|
||||||
|
|
||||||
|
JSContext*
|
||||||
|
GetCurrentThreadJSContext()
|
||||||
|
{
|
||||||
|
WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
|
||||||
|
if (!wp) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return wp->GetJSContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
JSObject*
|
||||||
|
GetCurrentThreadWorkerGlobal()
|
||||||
|
{
|
||||||
|
WorkerPrivate* wp = GetCurrentThreadWorkerPrivate();
|
||||||
|
if (!wp) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
WorkerGlobalScope* scope = wp->GlobalScope();
|
||||||
|
if (!scope) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return scope->GetGlobalJSObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
|
||||||
|
void
|
||||||
|
AssertIsOnMainThread()
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(NS_IsMainThread(), "Wrong thread!");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // workers namespace
|
} // workers namespace
|
||||||
|
|
||||||
} // dom namespace
|
} // dom namespace
|
||||||
} // mozilla namespace
|
} // mozilla namespace
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "nsIObserver.h"
|
#include "nsIObserver.h"
|
||||||
|
|
||||||
#include "mozilla/dom/BindingDeclarations.h"
|
#include "mozilla/dom/BindingDeclarations.h"
|
||||||
|
#include "mozilla/dom/workerinternals/JSSettings.h"
|
||||||
#include "nsClassHashtable.h"
|
#include "nsClassHashtable.h"
|
||||||
#include "nsHashKeys.h"
|
#include "nsHashKeys.h"
|
||||||
#include "nsTArray.h"
|
#include "nsTArray.h"
|
||||||
|
@ -25,7 +26,7 @@ class SharedWorker;
|
||||||
struct WorkerLoadInfo;
|
struct WorkerLoadInfo;
|
||||||
class WorkerThread;
|
class WorkerThread;
|
||||||
|
|
||||||
namespace workers {
|
namespace workerinternals {
|
||||||
|
|
||||||
class RuntimeService final : public nsIObserver
|
class RuntimeService final : public nsIObserver
|
||||||
{
|
{
|
||||||
|
@ -93,7 +94,7 @@ class RuntimeService final : public nsIObserver
|
||||||
// Only used on the main thread.
|
// Only used on the main thread.
|
||||||
nsCOMPtr<nsITimer> mIdleThreadTimer;
|
nsCOMPtr<nsITimer> mIdleThreadTimer;
|
||||||
|
|
||||||
static JSSettings sDefaultJSSettings;
|
static workerinternals::JSSettings sDefaultJSSettings;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct NavigatorProperties
|
struct NavigatorProperties
|
||||||
|
@ -169,16 +170,16 @@ public:
|
||||||
NoteIdleThread(WorkerThread* aThread);
|
NoteIdleThread(WorkerThread* aThread);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
GetDefaultJSSettings(JSSettings& aSettings)
|
GetDefaultJSSettings(workerinternals::JSSettings& aSettings)
|
||||||
{
|
{
|
||||||
AssertIsOnMainThread();
|
workers::AssertIsOnMainThread();
|
||||||
aSettings = sDefaultJSSettings;
|
aSettings = sDefaultJSSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SetDefaultContextOptions(const JS::ContextOptions& aContextOptions)
|
SetDefaultContextOptions(const JS::ContextOptions& aContextOptions)
|
||||||
{
|
{
|
||||||
AssertIsOnMainThread();
|
workers::AssertIsOnMainThread();
|
||||||
sDefaultJSSettings.contextOptions = aContextOptions;
|
sDefaultJSSettings.contextOptions = aContextOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +201,7 @@ public:
|
||||||
static void
|
static void
|
||||||
SetDefaultJSGCSettings(JSGCParamKey aKey, uint32_t aValue)
|
SetDefaultJSGCSettings(JSGCParamKey aKey, uint32_t aValue)
|
||||||
{
|
{
|
||||||
AssertIsOnMainThread();
|
workers::AssertIsOnMainThread();
|
||||||
sDefaultJSSettings.ApplyGCSetting(aKey, aValue);
|
sDefaultJSSettings.ApplyGCSetting(aKey, aValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +212,7 @@ public:
|
||||||
static void
|
static void
|
||||||
SetDefaultGCZeal(uint8_t aGCZeal, uint32_t aFrequency)
|
SetDefaultGCZeal(uint8_t aGCZeal, uint32_t aFrequency)
|
||||||
{
|
{
|
||||||
AssertIsOnMainThread();
|
workers::AssertIsOnMainThread();
|
||||||
sDefaultJSSettings.gcZeal = aGCZeal;
|
sDefaultJSSettings.gcZeal = aGCZeal;
|
||||||
sDefaultJSSettings.gcZealFrequency = aFrequency;
|
sDefaultJSSettings.gcZealFrequency = aFrequency;
|
||||||
}
|
}
|
||||||
|
@ -270,7 +271,7 @@ private:
|
||||||
SharedWorker** aSharedWorker);
|
SharedWorker** aSharedWorker);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // workers namespace
|
} // workerinternals namespace
|
||||||
} // dom namespace
|
} // dom namespace
|
||||||
} // mozilla namespace
|
} // mozilla namespace
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,8 @@ SharedWorker::Constructor(const GlobalObject& aGlobal,
|
||||||
{
|
{
|
||||||
AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
workers::RuntimeService* rts = workers::RuntimeService::GetOrCreateService();
|
workerinternals::RuntimeService* rts =
|
||||||
|
workerinternals::RuntimeService::GetOrCreateService();
|
||||||
if (!rts) {
|
if (!rts) {
|
||||||
aRv = NS_ERROR_NOT_AVAILABLE;
|
aRv = NS_ERROR_NOT_AVAILABLE;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -27,13 +27,13 @@ class MessagePort;
|
||||||
class StringOrWorkerOptions;
|
class StringOrWorkerOptions;
|
||||||
class WorkerPrivate;
|
class WorkerPrivate;
|
||||||
|
|
||||||
namespace workers {
|
namespace workerinternals {
|
||||||
class RuntimeService;
|
class RuntimeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
class SharedWorker final : public DOMEventTargetHelper
|
class SharedWorker final : public DOMEventTargetHelper
|
||||||
{
|
{
|
||||||
friend class workers::RuntimeService;
|
friend class workerinternals::RuntimeService;
|
||||||
|
|
||||||
typedef mozilla::ErrorResult ErrorResult;
|
typedef mozilla::ErrorResult ErrorResult;
|
||||||
typedef mozilla::dom::GlobalObject GlobalObject;
|
typedef mozilla::dom::GlobalObject GlobalObject;
|
||||||
|
|
|
@ -37,115 +37,6 @@ class WorkerPrivate;
|
||||||
|
|
||||||
namespace workers {
|
namespace workers {
|
||||||
|
|
||||||
struct PrivatizableBase
|
|
||||||
{ };
|
|
||||||
|
|
||||||
struct JSSettings
|
|
||||||
{
|
|
||||||
enum {
|
|
||||||
// All the GC parameters that we support.
|
|
||||||
JSSettings_JSGC_MAX_BYTES = 0,
|
|
||||||
JSSettings_JSGC_MAX_MALLOC_BYTES,
|
|
||||||
JSSettings_JSGC_HIGH_FREQUENCY_TIME_LIMIT,
|
|
||||||
JSSettings_JSGC_LOW_FREQUENCY_HEAP_GROWTH,
|
|
||||||
JSSettings_JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN,
|
|
||||||
JSSettings_JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX,
|
|
||||||
JSSettings_JSGC_HIGH_FREQUENCY_LOW_LIMIT,
|
|
||||||
JSSettings_JSGC_HIGH_FREQUENCY_HIGH_LIMIT,
|
|
||||||
JSSettings_JSGC_ALLOCATION_THRESHOLD,
|
|
||||||
JSSettings_JSGC_SLICE_TIME_BUDGET,
|
|
||||||
JSSettings_JSGC_DYNAMIC_HEAP_GROWTH,
|
|
||||||
JSSettings_JSGC_DYNAMIC_MARK_SLICE,
|
|
||||||
// JSGC_MODE not supported
|
|
||||||
|
|
||||||
// This must be last so that we get an accurate count.
|
|
||||||
kGCSettingsArraySize
|
|
||||||
};
|
|
||||||
|
|
||||||
struct JSGCSetting
|
|
||||||
{
|
|
||||||
mozilla::Maybe<JSGCParamKey> key;
|
|
||||||
uint32_t value;
|
|
||||||
|
|
||||||
JSGCSetting()
|
|
||||||
: key(), value(0)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
// There are several settings that we know we need so it makes sense to
|
|
||||||
// preallocate here.
|
|
||||||
typedef JSGCSetting JSGCSettingsArray[kGCSettingsArraySize];
|
|
||||||
|
|
||||||
// Settings that change based on chrome/content context.
|
|
||||||
struct JSContentChromeSettings
|
|
||||||
{
|
|
||||||
JS::CompartmentOptions compartmentOptions;
|
|
||||||
int32_t maxScriptRuntime;
|
|
||||||
|
|
||||||
JSContentChromeSettings()
|
|
||||||
: compartmentOptions(), maxScriptRuntime(0)
|
|
||||||
{ }
|
|
||||||
};
|
|
||||||
|
|
||||||
JSContentChromeSettings chrome;
|
|
||||||
JSContentChromeSettings content;
|
|
||||||
JSGCSettingsArray gcSettings;
|
|
||||||
JS::ContextOptions contextOptions;
|
|
||||||
|
|
||||||
#ifdef JS_GC_ZEAL
|
|
||||||
uint8_t gcZeal;
|
|
||||||
uint32_t gcZealFrequency;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
JSSettings()
|
|
||||||
#ifdef JS_GC_ZEAL
|
|
||||||
: gcZeal(0), gcZealFrequency(0)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
for (uint32_t index = 0; index < ArrayLength(gcSettings); index++) {
|
|
||||||
new (gcSettings + index) JSGCSetting();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
ApplyGCSetting(JSGCParamKey aKey, uint32_t aValue)
|
|
||||||
{
|
|
||||||
JSSettings::JSGCSetting* firstEmptySetting = nullptr;
|
|
||||||
JSSettings::JSGCSetting* foundSetting = nullptr;
|
|
||||||
|
|
||||||
for (uint32_t index = 0; index < ArrayLength(gcSettings); index++) {
|
|
||||||
JSSettings::JSGCSetting& setting = gcSettings[index];
|
|
||||||
if (setting.key.isSome() && *setting.key == aKey) {
|
|
||||||
foundSetting = &setting;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!firstEmptySetting && setting.key.isNothing()) {
|
|
||||||
firstEmptySetting = &setting;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aValue) {
|
|
||||||
if (!foundSetting) {
|
|
||||||
foundSetting = firstEmptySetting;
|
|
||||||
if (!foundSetting) {
|
|
||||||
NS_ERROR("Not enough space for this value!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foundSetting->key = mozilla::Some(aKey);
|
|
||||||
foundSetting->value = aValue;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (foundSetting) {
|
|
||||||
foundSetting->key.reset();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// All of these are implemented in RuntimeService.cpp
|
// All of these are implemented in RuntimeService.cpp
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -198,9 +89,6 @@ IsDebuggerGlobal(JSObject* global);
|
||||||
bool
|
bool
|
||||||
IsDebuggerSandbox(JSObject* object);
|
IsDebuggerSandbox(JSObject* object);
|
||||||
|
|
||||||
// Random unique constant to facilitate JSPrincipal debugging
|
|
||||||
const uint32_t kJSPrincipalsDebugToken = 0x7e2df9d2;
|
|
||||||
|
|
||||||
} // workers namespace
|
} // workers namespace
|
||||||
} // dom namespace
|
} // dom namespace
|
||||||
} // mozilla namespace
|
} // mozilla namespace
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef mozilla_dom_workers_WorkerDebugger_h
|
#ifndef mozilla_dom_workers_WorkerDebugger_h
|
||||||
#define mozilla_dom_workers_WorkerDebugger_h
|
#define mozilla_dom_workers_WorkerDebugger_h
|
||||||
|
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
#include "nsIWorkerDebugger.h"
|
#include "nsIWorkerDebugger.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef mozilla_dom_workers_workerdebuggermanager_h
|
#ifndef mozilla_dom_workers_workerdebuggermanager_h
|
||||||
#define mozilla_dom_workers_workerdebuggermanager_h
|
#define mozilla_dom_workers_workerdebuggermanager_h
|
||||||
|
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
|
|
||||||
#include "nsIObserver.h"
|
#include "nsIObserver.h"
|
||||||
#include "nsIWorkerDebuggerManager.h"
|
#include "nsIWorkerDebuggerManager.h"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef mozilla_dom_workers_WorkerHolder_h
|
#ifndef mozilla_dom_workers_WorkerHolder_h
|
||||||
#define mozilla_dom_workers_WorkerHolder_h
|
#define mozilla_dom_workers_WorkerHolder_h
|
||||||
|
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#define mozilla_dom_workers_WorkerLoadInfo_h
|
#define mozilla_dom_workers_WorkerLoadInfo_h
|
||||||
|
|
||||||
#include "mozilla/dom/ChannelInfo.h"
|
#include "mozilla/dom/ChannelInfo.h"
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
#include "mozilla/net/ReferrerPolicy.h"
|
#include "mozilla/net/ReferrerPolicy.h"
|
||||||
#include "nsIInterfaceRequestor.h"
|
#include "nsIInterfaceRequestor.h"
|
||||||
#include "nsILoadContext.h"
|
#include "nsILoadContext.h"
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Connection;
|
||||||
|
|
||||||
class WorkerNavigator final : public nsWrapperCache
|
class WorkerNavigator final : public nsWrapperCache
|
||||||
{
|
{
|
||||||
typedef struct workers::RuntimeService::NavigatorProperties NavigatorProperties;
|
typedef struct workerinternals::RuntimeService::NavigatorProperties NavigatorProperties;
|
||||||
|
|
||||||
NavigatorProperties mProperties;
|
NavigatorProperties mProperties;
|
||||||
RefPtr<StorageManager> mStorageManager;
|
RefPtr<StorageManager> mStorageManager;
|
||||||
|
|
|
@ -95,6 +95,7 @@ TimeoutsLog()
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
using namespace mozilla::dom::workers;
|
using namespace mozilla::dom::workers;
|
||||||
|
using namespace mozilla::dom::workerinternals;
|
||||||
using namespace mozilla::ipc;
|
using namespace mozilla::ipc;
|
||||||
|
|
||||||
MOZ_DEFINE_MALLOC_SIZE_OF(JsWorkerMallocSizeOf)
|
MOZ_DEFINE_MALLOC_SIZE_OF(JsWorkerMallocSizeOf)
|
||||||
|
@ -241,7 +242,7 @@ private:
|
||||||
NS_WARNING("Failed to dispatch, going to leak!");
|
NS_WARNING("Failed to dispatch, going to leak!");
|
||||||
}
|
}
|
||||||
|
|
||||||
workers::RuntimeService* runtime = workers::RuntimeService::GetService();
|
RuntimeService* runtime = RuntimeService::GetService();
|
||||||
NS_ASSERTION(runtime, "This should never be null!");
|
NS_ASSERTION(runtime, "This should never be null!");
|
||||||
|
|
||||||
mFinishedWorker->DisableDebugger();
|
mFinishedWorker->DisableDebugger();
|
||||||
|
@ -273,9 +274,9 @@ private:
|
||||||
NS_IMETHOD
|
NS_IMETHOD
|
||||||
Run() override
|
Run() override
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
workers::RuntimeService* runtime = workers::RuntimeService::GetService();
|
RuntimeService* runtime = RuntimeService::GetService();
|
||||||
MOZ_ASSERT(runtime);
|
MOZ_ASSERT(runtime);
|
||||||
|
|
||||||
mFinishedWorker->DisableDebugger();
|
mFinishedWorker->DisableDebugger();
|
||||||
|
@ -555,7 +556,7 @@ public:
|
||||||
if (aWorkerPrivate) {
|
if (aWorkerPrivate) {
|
||||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||||
} else {
|
} else {
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now fire a runnable to do the same on the parent's thread if we can.
|
// Now fire a runnable to do the same on the parent's thread if we can.
|
||||||
|
@ -1213,7 +1214,7 @@ private:
|
||||||
~FinishCollectRunnable()
|
~FinishCollectRunnable()
|
||||||
{
|
{
|
||||||
// mHandleReport and mHandlerData are released on the main thread.
|
// mHandleReport and mHandlerData are released on the main thread.
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
FinishCollectRunnable(const FinishCollectRunnable&) = delete;
|
FinishCollectRunnable(const FinishCollectRunnable&) = delete;
|
||||||
|
@ -1247,7 +1248,7 @@ WorkerPrivate::MemoryReporter::CollectReports(nsIHandleReportCallback* aHandleRe
|
||||||
nsISupports* aData,
|
nsISupports* aData,
|
||||||
bool aAnonymize)
|
bool aAnonymize)
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
RefPtr<CollectReportsRunnable> runnable;
|
RefPtr<CollectReportsRunnable> runnable;
|
||||||
|
|
||||||
|
@ -1299,7 +1300,7 @@ WorkerPrivate::MemoryReporter::CollectReports(nsIHandleReportCallback* aHandleRe
|
||||||
void
|
void
|
||||||
WorkerPrivate::MemoryReporter::TryToMapAddon(nsACString &path)
|
WorkerPrivate::MemoryReporter::TryToMapAddon(nsACString &path)
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
mMutex.AssertCurrentThreadOwns();
|
mMutex.AssertCurrentThreadOwns();
|
||||||
|
|
||||||
if (mAlreadyMappedToAddon || !mWorkerPrivate) {
|
if (mAlreadyMappedToAddon || !mWorkerPrivate) {
|
||||||
|
@ -1388,7 +1389,7 @@ WorkerPrivate::MemoryReporter::FinishCollectRunnable::FinishCollectRunnable(
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
WorkerPrivate::MemoryReporter::FinishCollectRunnable::Run()
|
WorkerPrivate::MemoryReporter::FinishCollectRunnable::Run()
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
nsCOMPtr<nsIMemoryReporterManager> manager =
|
nsCOMPtr<nsIMemoryReporterManager> manager =
|
||||||
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
||||||
|
@ -1441,7 +1442,7 @@ template <class Derived>
|
||||||
nsIDocument*
|
nsIDocument*
|
||||||
WorkerPrivateParent<Derived>::GetDocument() const
|
WorkerPrivateParent<Derived>::GetDocument() const
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
if (mLoadInfo.mWindow) {
|
if (mLoadInfo.mWindow) {
|
||||||
return mLoadInfo.mWindow->GetExtantDoc();
|
return mLoadInfo.mWindow->GetExtantDoc();
|
||||||
}
|
}
|
||||||
|
@ -1462,7 +1463,7 @@ template <class Derived>
|
||||||
void
|
void
|
||||||
WorkerPrivateParent<Derived>::SetCSP(nsIContentSecurityPolicy* aCSP)
|
WorkerPrivateParent<Derived>::SetCSP(nsIContentSecurityPolicy* aCSP)
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
if (!aCSP) {
|
if (!aCSP) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1476,7 +1477,7 @@ nsresult
|
||||||
WorkerPrivateParent<Derived>::SetCSPFromHeaderValues(const nsACString& aCSPHeaderValue,
|
WorkerPrivateParent<Derived>::SetCSPFromHeaderValues(const nsACString& aCSPHeaderValue,
|
||||||
const nsACString& aCSPReportOnlyHeaderValue)
|
const nsACString& aCSPReportOnlyHeaderValue)
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
MOZ_DIAGNOSTIC_ASSERT(!mLoadInfo.mCSP);
|
MOZ_DIAGNOSTIC_ASSERT(!mLoadInfo.mCSP);
|
||||||
|
|
||||||
NS_ConvertASCIItoUTF16 cspHeaderValue(aCSPHeaderValue);
|
NS_ConvertASCIItoUTF16 cspHeaderValue(aCSPHeaderValue);
|
||||||
|
@ -1576,7 +1577,7 @@ WorkerPrivateParent<Derived>::WorkerPrivateParent(
|
||||||
MOZ_ASSERT_IF(!IsDedicatedWorker(), NS_IsMainThread());
|
MOZ_ASSERT_IF(!IsDedicatedWorker(), NS_IsMainThread());
|
||||||
|
|
||||||
if (aLoadInfo.mWindow) {
|
if (aLoadInfo.mWindow) {
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
BindToOwner(aLoadInfo.mWindow);
|
BindToOwner(aLoadInfo.mWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1600,9 +1601,9 @@ WorkerPrivateParent<Derived>::WorkerPrivateParent(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
workers::RuntimeService::GetDefaultJSSettings(mJSSettings);
|
RuntimeService::GetDefaultJSSettings(mJSSettings);
|
||||||
|
|
||||||
// Our secure context state depends on the kind of worker we have.
|
// Our secure context state depends on the kind of worker we have.
|
||||||
if (UsesSystemPrincipal() || IsServiceWorker()) {
|
if (UsesSystemPrincipal() || IsServiceWorker()) {
|
||||||
|
@ -1866,7 +1867,7 @@ WorkerPrivateParent<Derived>::NotifyPrivate(WorkerStatus aStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsSharedWorker()) {
|
if (IsSharedWorker()) {
|
||||||
workers::RuntimeService* runtime = workers::RuntimeService::GetService();
|
RuntimeService* runtime = RuntimeService::GetService();
|
||||||
MOZ_ASSERT(runtime);
|
MOZ_ASSERT(runtime);
|
||||||
|
|
||||||
runtime->ForgetSharedWorker(ParentAsWorkerPrivate());
|
runtime->ForgetSharedWorker(ParentAsWorkerPrivate());
|
||||||
|
@ -1914,7 +1915,7 @@ WorkerPrivateParent<Derived>::Freeze(nsPIDOMWindowInner* aWindow)
|
||||||
// frozen. It can happen that mSharedWorkers is empty but this thread has
|
// frozen. It can happen that mSharedWorkers is empty but this thread has
|
||||||
// not been unregistered yet.
|
// not been unregistered yet.
|
||||||
if ((IsSharedWorker() || IsServiceWorker()) && !mSharedWorkers.IsEmpty()) {
|
if ((IsSharedWorker() || IsServiceWorker()) && !mSharedWorkers.IsEmpty()) {
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
bool allFrozen = true;
|
bool allFrozen = true;
|
||||||
|
|
||||||
|
@ -1973,7 +1974,7 @@ WorkerPrivateParent<Derived>::Thaw(nsPIDOMWindowInner* aWindow)
|
||||||
// It can happen that mSharedWorkers is empty but this thread has not been
|
// It can happen that mSharedWorkers is empty but this thread has not been
|
||||||
// unregistered yet.
|
// unregistered yet.
|
||||||
if ((IsSharedWorker() || IsServiceWorker()) && !mSharedWorkers.IsEmpty()) {
|
if ((IsSharedWorker() || IsServiceWorker()) && !mSharedWorkers.IsEmpty()) {
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
bool anyRunning = false;
|
bool anyRunning = false;
|
||||||
|
|
||||||
|
@ -2040,7 +2041,7 @@ template <class Derived>
|
||||||
void
|
void
|
||||||
WorkerPrivateParent<Derived>::ParentWindowPaused()
|
WorkerPrivateParent<Derived>::ParentWindowPaused()
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
MOZ_ASSERT_IF(IsDedicatedWorker(), mParentWindowPausedDepth == 0);
|
MOZ_ASSERT_IF(IsDedicatedWorker(), mParentWindowPausedDepth == 0);
|
||||||
mParentWindowPausedDepth += 1;
|
mParentWindowPausedDepth += 1;
|
||||||
}
|
}
|
||||||
|
@ -2049,7 +2050,7 @@ template <class Derived>
|
||||||
void
|
void
|
||||||
WorkerPrivateParent<Derived>::ParentWindowResumed()
|
WorkerPrivateParent<Derived>::ParentWindowResumed()
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
MOZ_ASSERT(mParentWindowPausedDepth > 0);
|
MOZ_ASSERT(mParentWindowPausedDepth > 0);
|
||||||
MOZ_ASSERT_IF(IsDedicatedWorker(), mParentWindowPausedDepth == 1);
|
MOZ_ASSERT_IF(IsDedicatedWorker(), mParentWindowPausedDepth == 1);
|
||||||
|
@ -2385,7 +2386,7 @@ bool
|
||||||
WorkerPrivateParent<Derived>::RegisterSharedWorker(SharedWorker* aSharedWorker,
|
WorkerPrivateParent<Derived>::RegisterSharedWorker(SharedWorker* aSharedWorker,
|
||||||
MessagePort* aPort)
|
MessagePort* aPort)
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
MOZ_ASSERT(aSharedWorker);
|
MOZ_ASSERT(aSharedWorker);
|
||||||
MOZ_ASSERT(IsSharedWorker());
|
MOZ_ASSERT(IsSharedWorker());
|
||||||
MOZ_ASSERT(!mSharedWorkers.Contains(aSharedWorker));
|
MOZ_ASSERT(!mSharedWorkers.Contains(aSharedWorker));
|
||||||
|
@ -2416,7 +2417,7 @@ WorkerPrivateParent<Derived>::BroadcastErrorToSharedWorkers(
|
||||||
const WorkerErrorReport* aReport,
|
const WorkerErrorReport* aReport,
|
||||||
bool aIsErrorEvent)
|
bool aIsErrorEvent)
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
if (aIsErrorEvent && JSREPORT_IS_WARNING(aReport->mFlags)) {
|
if (aIsErrorEvent && JSREPORT_IS_WARNING(aReport->mFlags)) {
|
||||||
// Don't fire any events anywhere. Just log to console.
|
// Don't fire any events anywhere. Just log to console.
|
||||||
|
@ -2550,7 +2551,7 @@ void
|
||||||
WorkerPrivateParent<Derived>::GetAllSharedWorkers(
|
WorkerPrivateParent<Derived>::GetAllSharedWorkers(
|
||||||
nsTArray<RefPtr<SharedWorker>>& aSharedWorkers)
|
nsTArray<RefPtr<SharedWorker>>& aSharedWorkers)
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
MOZ_ASSERT(IsSharedWorker() || IsServiceWorker());
|
MOZ_ASSERT(IsSharedWorker() || IsServiceWorker());
|
||||||
|
|
||||||
if (!aSharedWorkers.IsEmpty()) {
|
if (!aSharedWorkers.IsEmpty()) {
|
||||||
|
@ -2567,7 +2568,7 @@ void
|
||||||
WorkerPrivateParent<Derived>::CloseSharedWorkersForWindow(
|
WorkerPrivateParent<Derived>::CloseSharedWorkersForWindow(
|
||||||
nsPIDOMWindowInner* aWindow)
|
nsPIDOMWindowInner* aWindow)
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
MOZ_ASSERT(IsSharedWorker() || IsServiceWorker());
|
MOZ_ASSERT(IsSharedWorker() || IsServiceWorker());
|
||||||
MOZ_ASSERT(aWindow);
|
MOZ_ASSERT(aWindow);
|
||||||
|
|
||||||
|
@ -2604,7 +2605,7 @@ template <class Derived>
|
||||||
void
|
void
|
||||||
WorkerPrivateParent<Derived>::CloseAllSharedWorkers()
|
WorkerPrivateParent<Derived>::CloseAllSharedWorkers()
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
MOZ_ASSERT(IsSharedWorker() || IsServiceWorker());
|
MOZ_ASSERT(IsSharedWorker() || IsServiceWorker());
|
||||||
|
|
||||||
for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
|
for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
|
||||||
|
@ -2620,7 +2621,7 @@ template <class Derived>
|
||||||
void
|
void
|
||||||
WorkerPrivateParent<Derived>::WorkerScriptLoaded()
|
WorkerPrivateParent<Derived>::WorkerScriptLoaded()
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
if (IsSharedWorker() || IsServiceWorker()) {
|
if (IsSharedWorker() || IsServiceWorker()) {
|
||||||
// No longer need to hold references to the window or document we came from.
|
// No longer need to hold references to the window or document we came from.
|
||||||
|
@ -2633,7 +2634,7 @@ template <class Derived>
|
||||||
void
|
void
|
||||||
WorkerPrivateParent<Derived>::SetBaseURI(nsIURI* aBaseURI)
|
WorkerPrivateParent<Derived>::SetBaseURI(nsIURI* aBaseURI)
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
if (!mLoadInfo.mBaseURI) {
|
if (!mLoadInfo.mBaseURI) {
|
||||||
NS_ASSERTION(GetParent(), "Shouldn't happen without a parent!");
|
NS_ASSERTION(GetParent(), "Shouldn't happen without a parent!");
|
||||||
|
@ -2727,7 +2728,7 @@ template <class Derived>
|
||||||
void
|
void
|
||||||
WorkerPrivateParent<Derived>::UpdateOverridenLoadGroup(nsILoadGroup* aBaseLoadGroup)
|
WorkerPrivateParent<Derived>::UpdateOverridenLoadGroup(nsILoadGroup* aBaseLoadGroup)
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
// The load group should have been overriden at init time.
|
// The load group should have been overriden at init time.
|
||||||
mLoadInfo.mInterfaceRequestor->MaybeAddTabChild(aBaseLoadGroup);
|
mLoadInfo.mInterfaceRequestor->MaybeAddTabChild(aBaseLoadGroup);
|
||||||
|
@ -2738,7 +2739,7 @@ void
|
||||||
WorkerPrivateParent<Derived>::FlushReportsToSharedWorkers(
|
WorkerPrivateParent<Derived>::FlushReportsToSharedWorkers(
|
||||||
nsIConsoleReportCollector* aReporter)
|
nsIConsoleReportCollector* aReporter)
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
AutoTArray<RefPtr<SharedWorker>, 10> sharedWorkers;
|
AutoTArray<RefPtr<SharedWorker>, 10> sharedWorkers;
|
||||||
AutoTArray<WindowAction, 10> windowActions;
|
AutoTArray<WindowAction, 10> windowActions;
|
||||||
|
@ -2831,7 +2832,7 @@ WorkerPrivateParent<Derived>::AssertIsOnParentThread() const
|
||||||
GetParent()->AssertIsOnWorkerThread();
|
GetParent()->AssertIsOnWorkerThread();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2846,7 +2847,7 @@ WorkerPrivateParent<Derived>::AssertInnerWindowIsCorrect() const
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
nsPIDOMWindowOuter* outer = mLoadInfo.mWindow->GetOuterWindow();
|
nsPIDOMWindowOuter* outer = mLoadInfo.mWindow->GetOuterWindow();
|
||||||
NS_ASSERTION(outer && outer->GetCurrentInnerWindow() == mLoadInfo.mWindow,
|
NS_ASSERTION(outer && outer->GetCurrentInnerWindow() == mLoadInfo.mWindow,
|
||||||
|
@ -2904,7 +2905,7 @@ WorkerPrivate::WorkerPrivate(WorkerPrivate* aParent,
|
||||||
mOnLine = aParent->OnLine();
|
mOnLine = aParent->OnLine();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
mOnLine = !NS_IsOffline();
|
mOnLine = !NS_IsOffline();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3048,7 +3049,7 @@ WorkerPrivate::Constructor(JSContext* aCx,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
Maybe<WorkerLoadInfo> stackLoadInfo;
|
Maybe<WorkerLoadInfo> stackLoadInfo;
|
||||||
|
@ -3070,17 +3071,17 @@ WorkerPrivate::Constructor(JSContext* aCx,
|
||||||
// NB: This has to be done before creating the WorkerPrivate, because it will
|
// NB: This has to be done before creating the WorkerPrivate, because it will
|
||||||
// attempt to use static variables that are initialized in the RuntimeService
|
// attempt to use static variables that are initialized in the RuntimeService
|
||||||
// constructor.
|
// constructor.
|
||||||
workers::RuntimeService* runtimeService;
|
RuntimeService* runtimeService;
|
||||||
|
|
||||||
if (!parent) {
|
if (!parent) {
|
||||||
runtimeService = workers::RuntimeService::GetOrCreateService();
|
runtimeService = RuntimeService::GetOrCreateService();
|
||||||
if (!runtimeService) {
|
if (!runtimeService) {
|
||||||
aRv.Throw(NS_ERROR_FAILURE);
|
aRv.Throw(NS_ERROR_FAILURE);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
runtimeService = workers::RuntimeService::GetService();
|
runtimeService = RuntimeService::GetService();
|
||||||
}
|
}
|
||||||
|
|
||||||
MOZ_ASSERT(runtimeService);
|
MOZ_ASSERT(runtimeService);
|
||||||
|
@ -3138,7 +3139,7 @@ WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
|
||||||
MOZ_ASSERT_IF(NS_IsMainThread(), aCx == nsContentUtils::GetCurrentJSContext());
|
MOZ_ASSERT_IF(NS_IsMainThread(), aCx == nsContentUtils::GetCurrentJSContext());
|
||||||
|
|
||||||
if (aWindow) {
|
if (aWindow) {
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkerLoadInfo loadInfo;
|
WorkerLoadInfo loadInfo;
|
||||||
|
@ -3188,7 +3189,7 @@ WorkerPrivate::GetLoadInfo(JSContext* aCx, nsPIDOMWindowInner* aWindow,
|
||||||
aParent->ServiceWorkersTestingInWindow();
|
aParent->ServiceWorkersTestingInWindow();
|
||||||
loadInfo.mParentController = aParent->GetController();
|
loadInfo.mParentController = aParent->GetController();
|
||||||
} else {
|
} else {
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
// Make sure that the IndexedDatabaseManager is set up
|
// Make sure that the IndexedDatabaseManager is set up
|
||||||
Unused << NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate());
|
Unused << NS_WARN_IF(!IndexedDatabaseManager::GetOrCreate());
|
||||||
|
@ -5535,7 +5536,7 @@ WorkerPrivate::DumpCrashInformation(nsACString& aString)
|
||||||
PerformanceStorage*
|
PerformanceStorage*
|
||||||
WorkerPrivate::GetPerformanceStorage()
|
WorkerPrivate::GetPerformanceStorage()
|
||||||
{
|
{
|
||||||
workers::AssertIsOnMainThread();
|
AssertIsOnMainThread();
|
||||||
|
|
||||||
if (!mPerformanceStorage) {
|
if (!mPerformanceStorage) {
|
||||||
mPerformanceStorage = PerformanceStorageWorker::Create(this);
|
mPerformanceStorage = PerformanceStorageWorker::Create(this);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef mozilla_dom_workers_workerprivate_h__
|
#ifndef mozilla_dom_workers_workerprivate_h__
|
||||||
#define mozilla_dom_workers_workerprivate_h__
|
#define mozilla_dom_workers_workerprivate_h__
|
||||||
|
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
#include "mozilla/CondVar.h"
|
#include "mozilla/CondVar.h"
|
||||||
#include "mozilla/DOMEventTargetHelper.h"
|
#include "mozilla/DOMEventTargetHelper.h"
|
||||||
#include "nsDOMNavigationTiming.h"
|
#include "nsDOMNavigationTiming.h"
|
||||||
|
@ -18,7 +18,8 @@
|
||||||
|
|
||||||
#include "mozilla/dom/WorkerHolder.h"
|
#include "mozilla/dom/WorkerHolder.h"
|
||||||
#include "mozilla/dom/WorkerLoadInfo.h"
|
#include "mozilla/dom/WorkerLoadInfo.h"
|
||||||
#include "mozilla/dom/workers/Queue.h"
|
#include "mozilla/dom/workerinternals/JSSettings.h"
|
||||||
|
#include "mozilla/dom/workerinternals/Queue.h"
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
#undef PostMessage
|
#undef PostMessage
|
||||||
|
@ -144,7 +145,7 @@ private:
|
||||||
nsTArray<nsCOMPtr<nsIRunnable>> mQueuedRunnables;
|
nsTArray<nsCOMPtr<nsIRunnable>> mQueuedRunnables;
|
||||||
|
|
||||||
// Protected by mMutex.
|
// Protected by mMutex.
|
||||||
workers::JSSettings mJSSettings;
|
workerinternals::JSSettings mJSSettings;
|
||||||
|
|
||||||
// Only touched on the parent thread (currently this is always the main
|
// Only touched on the parent thread (currently this is always the main
|
||||||
// thread as SharedWorkers are always top-level).
|
// thread as SharedWorkers are always top-level).
|
||||||
|
@ -707,7 +708,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CopyJSSettings(workers::JSSettings& aSettings)
|
CopyJSSettings(workerinternals::JSSettings& aSettings)
|
||||||
{
|
{
|
||||||
mozilla::MutexAutoLock lock(mMutex);
|
mozilla::MutexAutoLock lock(mMutex);
|
||||||
aSettings = mJSSettings;
|
aSettings = mJSSettings;
|
||||||
|
@ -889,8 +890,8 @@ class WorkerPrivate : public WorkerPrivateParent<WorkerPrivate>
|
||||||
bool mDebuggerRegistered;
|
bool mDebuggerRegistered;
|
||||||
WorkerDebugger* mDebugger;
|
WorkerDebugger* mDebugger;
|
||||||
|
|
||||||
workersinternals::Queue<WorkerControlRunnable*, 4> mControlQueue;
|
workerinternals::Queue<WorkerControlRunnable*, 4> mControlQueue;
|
||||||
workersinternals::Queue<WorkerRunnable*, 4> mDebuggerQueue;
|
workerinternals::Queue<WorkerRunnable*, 4> mDebuggerQueue;
|
||||||
|
|
||||||
// Touched on multiple threads, protected with mMutex.
|
// Touched on multiple threads, protected with mMutex.
|
||||||
JSContext* mJSContext;
|
JSContext* mJSContext;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef mozilla_dom_workers_workerrunnable_h__
|
#ifndef mozilla_dom_workers_workerrunnable_h__
|
||||||
#define mozilla_dom_workers_workerrunnable_h__
|
#define mozilla_dom_workers_workerrunnable_h__
|
||||||
|
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
#include "mozilla/dom/WorkerHolder.h"
|
#include "mozilla/dom/WorkerHolder.h"
|
||||||
|
|
||||||
#include "nsICancelableRunnable.h"
|
#include "nsICancelableRunnable.h"
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#ifndef mozilla_dom_workerscope_h__
|
#ifndef mozilla_dom_workerscope_h__
|
||||||
#define mozilla_dom_workerscope_h__
|
#define mozilla_dom_workerscope_h__
|
||||||
|
|
||||||
#include "mozilla/dom/workers/WorkerCommon.h"
|
#include "mozilla/dom/WorkerCommon.h"
|
||||||
#include "mozilla/DOMEventTargetHelper.h"
|
#include "mozilla/DOMEventTargetHelper.h"
|
||||||
#include "mozilla/dom/Headers.h"
|
#include "mozilla/dom/Headers.h"
|
||||||
#include "mozilla/dom/RequestBinding.h"
|
#include "mozilla/dom/RequestBinding.h"
|
||||||
|
|
|
@ -23,7 +23,7 @@ class WorkerRunnable;
|
||||||
class WorkerPrivate;
|
class WorkerPrivate;
|
||||||
template <class> class WorkerPrivateParent;
|
template <class> class WorkerPrivateParent;
|
||||||
|
|
||||||
namespace workers {
|
namespace workerinternals {
|
||||||
class RuntimeService;
|
class RuntimeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class RuntimeService;
|
||||||
// full access to private methods (as would happen if they were simply friends).
|
// full access to private methods (as would happen if they were simply friends).
|
||||||
class WorkerThreadFriendKey
|
class WorkerThreadFriendKey
|
||||||
{
|
{
|
||||||
friend class workers::RuntimeService;
|
friend class workerinternals::RuntimeService;
|
||||||
friend class WorkerPrivate;
|
friend class WorkerPrivate;
|
||||||
friend class WorkerPrivateParent<WorkerPrivate>;
|
friend class WorkerPrivateParent<WorkerPrivate>;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ with Files("**"):
|
||||||
# Public stuff.
|
# Public stuff.
|
||||||
EXPORTS.mozilla.dom += [
|
EXPORTS.mozilla.dom += [
|
||||||
'SharedWorker.h',
|
'SharedWorker.h',
|
||||||
|
'WorkerCommon.h',
|
||||||
'WorkerDebugger.h',
|
'WorkerDebugger.h',
|
||||||
'WorkerDebuggerManager.h',
|
'WorkerDebuggerManager.h',
|
||||||
'WorkerHolder.h',
|
'WorkerHolder.h',
|
||||||
|
@ -22,10 +23,11 @@ EXPORTS.mozilla.dom += [
|
||||||
'WorkerScope.h',
|
'WorkerScope.h',
|
||||||
]
|
]
|
||||||
|
|
||||||
EXPORTS.mozilla.dom.workers += [
|
# Private stuff.
|
||||||
|
EXPORTS.mozilla.dom.workerinternals += [
|
||||||
|
'JSSettings.h',
|
||||||
'Queue.h',
|
'Queue.h',
|
||||||
'RuntimeService.h',
|
'RuntimeService.h',
|
||||||
'WorkerCommon.h',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
XPIDL_MODULE = 'dom_workers'
|
XPIDL_MODULE = 'dom_workers'
|
||||||
|
|
Загрузка…
Ссылка в новой задаче