зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1744025: Use CheckedUnsafePtr<WorkerPrivate> in WorkerGlobalScopeBase. r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D132709
This commit is contained in:
Родитель
f461a1a999
Коммит
d53627390a
|
@ -41,7 +41,7 @@
|
|||
#include "mozilla/dom/UnionTypes.h"
|
||||
#include "mozilla/dom/WindowBinding.h" // For IdleRequestCallback/Options
|
||||
#include "mozilla/dom/WindowGlobalParent.h"
|
||||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
#include "mozilla/dom/WorkerScope.h"
|
||||
#include "mozilla/ipc/GeckoChildProcessHost.h"
|
||||
#include "mozilla/net/UrlClassifierFeatureFactory.h"
|
||||
#include "IOActivityMonitor.h"
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "PerformanceWorker.h"
|
||||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
#include "mozilla/dom/WorkerScope.h"
|
||||
#include "mozilla/StaticPrefs_dom.h"
|
||||
|
||||
namespace mozilla::dom {
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "mozilla/dom/RemoteWorkerService.h"
|
||||
#include "mozilla/dom/TimeoutHandler.h"
|
||||
#include "mozilla/dom/WorkerBinding.h"
|
||||
#include "mozilla/dom/WorkerScope.h"
|
||||
#include "mozilla/dom/JSExecutionManager.h"
|
||||
#include "mozilla/dom/WindowContext.h"
|
||||
#include "mozilla/extensions/ExtensionBrowser.h" // extensions::Create{AndDispatchInitWorkerContext,WorkerLoaded,WorkerDestroyed}Runnable
|
||||
|
@ -5244,15 +5245,14 @@ WorkerGlobalScope* WorkerPrivate::GetOrCreateGlobalScope(JSContext* aCx) {
|
|||
}
|
||||
|
||||
if (IsSharedWorker()) {
|
||||
data->mScope = new SharedWorkerGlobalScope(
|
||||
WrapNotNull(this), CreateClientSource(), WorkerName());
|
||||
} else if (IsServiceWorker()) {
|
||||
data->mScope =
|
||||
new ServiceWorkerGlobalScope(WrapNotNull(this), CreateClientSource(),
|
||||
GetServiceWorkerRegistrationDescriptor());
|
||||
new SharedWorkerGlobalScope(this, CreateClientSource(), WorkerName());
|
||||
} else if (IsServiceWorker()) {
|
||||
data->mScope = new ServiceWorkerGlobalScope(
|
||||
this, CreateClientSource(), GetServiceWorkerRegistrationDescriptor());
|
||||
} else {
|
||||
data->mScope = new DedicatedWorkerGlobalScope(
|
||||
WrapNotNull(this), CreateClientSource(), WorkerName());
|
||||
data->mScope = new DedicatedWorkerGlobalScope(this, CreateClientSource(),
|
||||
WorkerName());
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> global(aCx);
|
||||
|
@ -5281,7 +5281,7 @@ WorkerDebuggerGlobalScope* WorkerPrivate::CreateDebuggerGlobalScope(
|
|||
GetClientType(), HybridEventTarget(), NullPrincipalInfo());
|
||||
|
||||
data->mDebuggerScope =
|
||||
new WorkerDebuggerGlobalScope(WrapNotNull(this), std::move(clientSource));
|
||||
new WorkerDebuggerGlobalScope(this, std::move(clientSource));
|
||||
|
||||
JS::Rooted<JSObject*> global(aCx);
|
||||
NS_ENSURE_TRUE(data->mDebuggerScope->WrapGlobalObject(aCx, &global), nullptr);
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "mozilla/dom/Worker.h"
|
||||
#include "mozilla/dom/WorkerCommon.h"
|
||||
#include "mozilla/dom/WorkerLoadInfo.h"
|
||||
#include "mozilla/dom/WorkerScope.h"
|
||||
#include "mozilla/dom/WorkerStatus.h"
|
||||
#include "mozilla/dom/workerinternals/JSSettings.h"
|
||||
#include "mozilla/dom/workerinternals/Queue.h"
|
||||
|
|
|
@ -209,8 +209,7 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(WorkerGlobalScopeBase)
|
|||
NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
|
||||
|
||||
WorkerGlobalScopeBase::WorkerGlobalScopeBase(
|
||||
NotNull<WorkerPrivate*> aWorkerPrivate,
|
||||
UniquePtr<ClientSource> aClientSource)
|
||||
WorkerPrivate* aWorkerPrivate, UniquePtr<ClientSource> aClientSource)
|
||||
: mWorkerPrivate(aWorkerPrivate),
|
||||
mClientSource(std::move(aClientSource)),
|
||||
mSerialEventTarget(aWorkerPrivate->HybridEventTarget()) {
|
||||
|
@ -762,9 +761,9 @@ void WorkerGlobalScope::ConsumeWindowInteraction() {
|
|||
}
|
||||
|
||||
DedicatedWorkerGlobalScope::DedicatedWorkerGlobalScope(
|
||||
NotNull<WorkerPrivate*> aWorkerPrivate,
|
||||
UniquePtr<ClientSource> aClientSource, const nsString& aName)
|
||||
: WorkerGlobalScope(aWorkerPrivate, std::move(aClientSource)),
|
||||
WorkerPrivate* aWorkerPrivate, UniquePtr<ClientSource> aClientSource,
|
||||
const nsString& aName)
|
||||
: WorkerGlobalScope(std::move(aWorkerPrivate), std::move(aClientSource)),
|
||||
NamedWorkerGlobalScopeMixin(aName) {}
|
||||
|
||||
bool DedicatedWorkerGlobalScope::WrapGlobalObject(
|
||||
|
@ -814,9 +813,9 @@ void DedicatedWorkerGlobalScope::Close() {
|
|||
}
|
||||
|
||||
SharedWorkerGlobalScope::SharedWorkerGlobalScope(
|
||||
NotNull<WorkerPrivate*> aWorkerPrivate,
|
||||
UniquePtr<ClientSource> aClientSource, const nsString& aName)
|
||||
: WorkerGlobalScope(aWorkerPrivate, std::move(aClientSource)),
|
||||
WorkerPrivate* aWorkerPrivate, UniquePtr<ClientSource> aClientSource,
|
||||
const nsString& aName)
|
||||
: WorkerGlobalScope(std::move(aWorkerPrivate), std::move(aClientSource)),
|
||||
NamedWorkerGlobalScopeMixin(aName) {}
|
||||
|
||||
bool SharedWorkerGlobalScope::WrapGlobalObject(
|
||||
|
@ -848,10 +847,9 @@ NS_IMPL_ADDREF_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope)
|
|||
NS_IMPL_RELEASE_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope)
|
||||
|
||||
ServiceWorkerGlobalScope::ServiceWorkerGlobalScope(
|
||||
NotNull<WorkerPrivate*> aWorkerPrivate,
|
||||
UniquePtr<ClientSource> aClientSource,
|
||||
WorkerPrivate* aWorkerPrivate, UniquePtr<ClientSource> aClientSource,
|
||||
const ServiceWorkerRegistrationDescriptor& aRegistrationDescriptor)
|
||||
: WorkerGlobalScope(aWorkerPrivate, std::move(aClientSource)),
|
||||
: WorkerGlobalScope(std::move(aWorkerPrivate), std::move(aClientSource)),
|
||||
mScope(NS_ConvertUTF8toUTF16(aRegistrationDescriptor.Scope()))
|
||||
|
||||
// Eagerly create the registration because we will need to receive
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "mozilla/dom/ImageBitmapBinding.h"
|
||||
#include "mozilla/dom/ImageBitmapSource.h"
|
||||
#include "mozilla/dom/SafeRefPtr.h"
|
||||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIGlobalObject.h"
|
||||
|
@ -70,7 +71,6 @@ class ServiceWorkerRegistrationDescriptor;
|
|||
struct StructuredSerializeOptions;
|
||||
class WorkerLocation;
|
||||
class WorkerNavigator;
|
||||
class WorkerPrivate;
|
||||
struct RequestInit;
|
||||
|
||||
namespace cache {
|
||||
|
@ -88,7 +88,7 @@ class WorkerGlobalScopeBase : public DOMEventTargetHelper,
|
|||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(WorkerGlobalScopeBase,
|
||||
DOMEventTargetHelper)
|
||||
|
||||
WorkerGlobalScopeBase(NotNull<WorkerPrivate*> aWorkerPrivate,
|
||||
WorkerGlobalScopeBase(WorkerPrivate* aWorkerPrivate,
|
||||
UniquePtr<ClientSource> aClientSource);
|
||||
|
||||
virtual bool WrapGlobalObject(JSContext* aCx,
|
||||
|
@ -157,7 +157,7 @@ class WorkerGlobalScopeBase : public DOMEventTargetHelper,
|
|||
protected:
|
||||
~WorkerGlobalScopeBase();
|
||||
|
||||
const NotNull<WorkerPrivate*> mWorkerPrivate;
|
||||
CheckedUnsafePtr<WorkerPrivate> mWorkerPrivate;
|
||||
|
||||
private:
|
||||
RefPtr<Console> mConsole;
|
||||
|
@ -330,7 +330,7 @@ class DedicatedWorkerGlobalScope final
|
|||
: public WorkerGlobalScope,
|
||||
public workerinternals::NamedWorkerGlobalScopeMixin {
|
||||
public:
|
||||
DedicatedWorkerGlobalScope(NotNull<WorkerPrivate*> aWorkerPrivate,
|
||||
DedicatedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
|
||||
UniquePtr<ClientSource> aClientSource,
|
||||
const nsString& aName);
|
||||
|
||||
|
@ -357,7 +357,7 @@ class SharedWorkerGlobalScope final
|
|||
: public WorkerGlobalScope,
|
||||
public workerinternals::NamedWorkerGlobalScopeMixin {
|
||||
public:
|
||||
SharedWorkerGlobalScope(NotNull<WorkerPrivate*> aWorkerPrivate,
|
||||
SharedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
|
||||
UniquePtr<ClientSource> aClientSource,
|
||||
const nsString& aName);
|
||||
|
||||
|
@ -379,8 +379,7 @@ class ServiceWorkerGlobalScope final : public WorkerGlobalScope {
|
|||
WorkerGlobalScope)
|
||||
|
||||
ServiceWorkerGlobalScope(
|
||||
NotNull<WorkerPrivate*> aWorkerPrivate,
|
||||
UniquePtr<ClientSource> aClientSource,
|
||||
WorkerPrivate* aWorkerPrivate, UniquePtr<ClientSource> aClientSource,
|
||||
const ServiceWorkerRegistrationDescriptor& aRegistrationDescriptor);
|
||||
|
||||
bool WrapGlobalObject(JSContext* aCx,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "mozilla/dom/ClonedErrorHolderBinding.h"
|
||||
#include "mozilla/dom/ExtensionBrowserBinding.h"
|
||||
#include "mozilla/dom/FunctionBinding.h"
|
||||
#include "mozilla/dom/WorkerPrivate.h"
|
||||
#include "mozilla/dom/WorkerScope.h"
|
||||
#include "mozilla/dom/SerializedStackHolder.h"
|
||||
#include "mozilla/dom/ServiceWorkerInfo.h"
|
||||
#include "mozilla/dom/ServiceWorkerManager.h"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "mozilla/dom/ExtensionBrowserBinding.h"
|
||||
#include "mozilla/dom/ExtensionPortBinding.h" // ExtensionPortDescriptor
|
||||
#include "mozilla/dom/WorkerPrivate.h" // GetWorkerPrivateFromContext
|
||||
#include "mozilla/dom/WorkerScope.h" // GetWorkerPrivateFromContext
|
||||
#include "mozilla/extensions/ExtensionAlarms.h"
|
||||
#include "mozilla/extensions/ExtensionMockAPI.h"
|
||||
#include "mozilla/extensions/ExtensionPort.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче