Bug 1901851 - Part 3: Make PRemoteWorkerService a toplevel actor which manages PRemoteWorker, r=dom-worker-reviewers,asuth

This enables the PRemoteWorkerService to be created by the parent process
instead of by the content process, which is useful as the parent process is the
party initiating remote worker actions.

Differential Revision: https://phabricator.services.mozilla.com/D213333
This commit is contained in:
Nika Layzell 2024-06-24 23:19:26 +00:00
Родитель eb355c902b
Коммит 933bd0ea88
23 изменённых файлов: 202 добавлений и 120 удалений

Просмотреть файл

@ -2706,13 +2706,6 @@ mozilla::ipc::IPCResult ContentChild::RecvRemoteType(
CrashReporter::RecordAnnotationNSCString(
CrashReporter::Annotation::RemoteType, remoteTypePrefix);
// Defer RemoteWorkerService initialization until the child process does
// receive its specific remoteType and can become actionable for the
// RemoteWorkerManager in the parent process.
if (mRemoteType != PREALLOC_REMOTE_TYPE) {
RemoteWorkerService::Initialize();
}
return IPC_OK();
}
@ -2729,6 +2722,12 @@ void ContentChild::PreallocInit() {
// for telemetry.
const nsACString& ContentChild::GetRemoteType() const { return mRemoteType; }
mozilla::ipc::IPCResult ContentChild::RecvInitRemoteWorkerService(
Endpoint<PRemoteWorkerServiceChild>&& aEndpoint) {
RemoteWorkerService::InitializeChild(std::move(aEndpoint));
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvInitBlobURLs(
nsTArray<BlobURLRegistrationData>&& aRegistrations) {
for (uint32_t i = 0; i < aRegistrations.Length(); ++i) {

Просмотреть файл

@ -365,6 +365,9 @@ class ContentChild final : public PContentChild,
// this for telemetry.
const nsACString& GetRemoteType() const override;
mozilla::ipc::IPCResult RecvInitRemoteWorkerService(
Endpoint<PRemoteWorkerServiceChild>&& aEndpoint);
mozilla::ipc::IPCResult RecvInitBlobURLs(
nsTArray<BlobURLRegistrationData>&& aRegistations);

Просмотреть файл

@ -119,6 +119,7 @@
#include "mozilla/dom/Permissions.h"
#include "mozilla/dom/ProcessMessageManager.h"
#include "mozilla/dom/PushNotifier.h"
#include "mozilla/dom/RemoteWorkerServiceParent.h"
#include "mozilla/dom/ServiceWorkerManager.h"
#include "mozilla/dom/ServiceWorkerRegistrar.h"
#include "mozilla/dom/ServiceWorkerUtils.h"
@ -1017,6 +1018,8 @@ already_AddRefed<ContentParent> ContentParent::GetUsedBrowserProcess(
Unused << preallocated->SendRemoteType(preallocated->mRemoteType,
preallocated->mProfile);
preallocated->StartRemoteWorkerService();
nsCOMPtr<nsIObserverService> obs =
mozilla::services::GetObserverService();
if (obs) {
@ -3174,6 +3177,10 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
Unused << SendRemoteType(mRemoteType, mProfile);
if (mRemoteType != PREALLOC_REMOTE_TYPE) {
StartRemoteWorkerService();
}
ScriptPreloader::InitContentChild(*this);
// Initialize the message manager (and load delayed scripts) now that we
@ -8173,6 +8180,18 @@ NS_IMETHODIMP ContentParent::GetRemoteType(nsACString& aRemoteType) {
return NS_OK;
}
void ContentParent::StartRemoteWorkerService() {
MOZ_ASSERT(!mRemoteWorkerServiceActor);
MOZ_ASSERT(mRemoteType != PREALLOC_REMOTE_TYPE);
Endpoint<PRemoteWorkerServiceChild> childEp;
mRemoteWorkerServiceActor =
RemoteWorkerServiceParent::CreateForProcess(this, &childEp);
if (mRemoteWorkerServiceActor) {
Unused << SendInitRemoteWorkerService(std::move(childEp));
}
}
IPCResult ContentParent::RecvRawMessage(
const JSActorMessageMeta& aMeta, const Maybe<ClonedMessageData>& aData,
const Maybe<ClonedMessageData>& aStack) {

Просмотреть файл

@ -95,6 +95,7 @@ class TabContext;
class GetFilesHelper;
class MemoryReportRequestHost;
class RemoteWorkerManager;
class RemoteWorkerServiceParent;
class ThreadsafeContentParentHandle;
struct CancelContentJSOptions;
@ -1448,6 +1449,8 @@ class ContentParent final : public PContentParent,
void AssertAlive();
void StartRemoteWorkerService();
private:
// If you add strong pointers to cycle collected objects here, be sure to
// release these objects in ShutDownProcess. See the comment there for more
@ -1549,6 +1552,8 @@ class ContentParent final : public PContentParent,
RefPtr<PProcessHangMonitorParent> mHangMonitorActor;
RefPtr<RemoteWorkerServiceParent> mRemoteWorkerServiceActor;
UniquePtr<gfx::DriverCrashGuard> mDriverCrashGuard;
UniquePtr<MemoryReportRequestHost> mMemoryReportRequest;

Просмотреть файл

@ -40,6 +40,7 @@ include protocol PURLClassifier;
include protocol PURLClassifierLocal;
include protocol PVRManager;
include protocol PRemoteDecoderManager;
include protocol PRemoteWorkerService;
include protocol PProfiler;
include protocol PScriptCache;
include protocol PSessionStorageObserver;
@ -771,6 +772,11 @@ child:
*/
async RemoteType(nsCString aRemoteType, nsCString aProfile);
/**
* Initialize the RemoteWorkerService thread in the content process.
*/
async InitRemoteWorkerService(Endpoint<PRemoteWorkerServiceChild> aEndpoint);
/**
* Send BlobURLRegistrationData to child process.
*/

Просмотреть файл

@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PBackground;
include protocol PFetchEventOpProxy;
include protocol PRemoteWorkerService;
include DOMTypes;
include ServiceWorkerOpArgs;
@ -58,7 +58,7 @@ union RemoteWorkerOp {
// PRemoteWorkerController protocol.
protocol PRemoteWorker
{
manager PBackground;
manager PRemoteWorkerService;
manages PFetchEventOpProxy;

Просмотреть файл

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
include protocol PBackground;
include protocol PRemoteWorker;
include ProtocolTypes;
include RemoteWorkerTypes;
@ -13,12 +13,13 @@ namespace dom {
// Simple protocol to register any active RemoteWorkerService running on any
// process. Initialization/registration is delayed for preallocated processes
// until the process takes on its final remoteType.
[NeedsOtherPid, ChildProc=anydom]
protocol PRemoteWorkerService
{
manager PBackground;
manages PRemoteWorker;
parent:
async __delete__();
child:
async PRemoteWorker(RemoteWorkerData data);
};
} // namespace dom

Просмотреть файл

@ -232,7 +232,7 @@ void RemoteWorkerManager::RegisterActor(RemoteWorkerServiceParent* aActor) {
AssertIsOnBackgroundThread();
MOZ_ASSERT(aActor);
if (!BackgroundParent::IsOtherProcessActor(aActor->Manager())) {
if (!aActor->IsOtherProcessActor()) {
MOZ_ASSERT(!mParentActor);
mParentActor = aActor;
MOZ_ASSERT(mPendings.IsEmpty());
@ -342,7 +342,7 @@ void RemoteWorkerManager::LaunchInternal(
// the worker here in the parent process.
if (aTargetActor != mParentActor) {
RefPtr<ThreadsafeContentParentHandle> contentHandle =
BackgroundParent::GetContentParentHandle(aTargetActor->Manager());
aTargetActor->GetContentParentHandle();
// This won't cause any race conditions because the content process
// should wait for the permissions to be received before executing the
@ -362,8 +362,7 @@ void RemoteWorkerManager::LaunchInternal(
}
RefPtr<RemoteWorkerParent> workerActor = MakeAndAddRef<RemoteWorkerParent>();
if (!aTargetActor->Manager()->SendPRemoteWorkerConstructor(workerActor,
aData)) {
if (!aTargetActor->SendPRemoteWorkerConstructor(workerActor, aData)) {
AsyncCreationFailed(aController);
return;
}
@ -413,7 +412,7 @@ void RemoteWorkerManager::ForEachActor(
if (MatchRemoteType(actor->GetRemoteType(), aRemoteType)) {
ThreadsafeContentParentHandle* contentHandle =
BackgroundParent::GetContentParentHandle(actor->Manager());
actor->GetContentParentHandle();
if (!aCallback(actor, contentHandle)) {
break;

Просмотреть файл

@ -6,6 +6,7 @@
#include "RemoteWorkerParent.h"
#include "RemoteWorkerController.h"
#include "RemoteWorkerServiceParent.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/PFetchEventOpProxyParent.h"
#include "mozilla/ipc/BackgroundParent.h"
@ -56,9 +57,14 @@ RemoteWorkerParent::~RemoteWorkerParent() {
MOZ_ASSERT(XRE_IsParentProcess());
}
RemoteWorkerServiceParent* RemoteWorkerParent::Manager() const {
return static_cast<RemoteWorkerServiceParent*>(
PRemoteWorkerParent::Manager());
}
void RemoteWorkerParent::Initialize(bool aAlreadyRegistered) {
RefPtr<ThreadsafeContentParentHandle> parent =
BackgroundParent::GetContentParentHandle(Manager());
Manager()->GetContentParentHandle();
// Parent is null if the child actor runs on the parent process.
if (parent) {
@ -83,7 +89,7 @@ void RemoteWorkerParent::ActorDestroy(IProtocol::ActorDestroyReason) {
MOZ_ASSERT(XRE_IsParentProcess());
RefPtr<ThreadsafeContentParentHandle> parent =
BackgroundParent::GetContentParentHandle(Manager());
Manager()->GetContentParentHandle();
// Parent is null if the child actor runs on the parent process.
if (parent) {

Просмотреть файл

@ -12,6 +12,7 @@
namespace mozilla::dom {
class RemoteWorkerController;
class RemoteWorkerServiceParent;
/**
* PBackground-managed parent actor that is mutually associated with a single
@ -32,6 +33,8 @@ class RemoteWorkerParent final : public PRemoteWorkerParent {
void MaybeSendDelete();
RemoteWorkerServiceParent* Manager() const;
private:
~RemoteWorkerParent();

Просмотреть файл

@ -112,27 +112,15 @@ RemoteWorkerServiceKeepAlive::~RemoteWorkerServiceKeepAlive() {
}
/* static */
void RemoteWorkerService::Initialize() {
void RemoteWorkerService::InitializeParent() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(XRE_IsParentProcess());
StaticMutexAutoLock lock(sRemoteWorkerServiceMutex);
MOZ_ASSERT(!sRemoteWorkerService);
RefPtr<RemoteWorkerService> service = new RemoteWorkerService();
// ## Content Process Initialization Case
//
// We are being told to initialize now that we know what our remote type is.
// Now is a fine time to call InitializeOnMainThread.
if (!XRE_IsParentProcess()) {
nsresult rv = service->InitializeOnMainThread();
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
sRemoteWorkerService = service;
return;
}
// ## Parent Process Initialization Case
//
// Otherwise we are in the parent process and were invoked by
@ -157,6 +145,30 @@ void RemoteWorkerService::Initialize() {
sRemoteWorkerService = service;
}
/* static */
void RemoteWorkerService::InitializeChild(
mozilla::ipc::Endpoint<PRemoteWorkerServiceChild> aEndpoint) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(!XRE_IsParentProcess());
StaticMutexAutoLock lock(sRemoteWorkerServiceMutex);
MOZ_ASSERT(!sRemoteWorkerService);
RefPtr<RemoteWorkerService> service = new RemoteWorkerService();
// ## Content Process Initialization Case
//
// We are being told to initialize now that we know what our remote type is.
// Now is a fine time to call InitializeOnMainThread.
nsresult rv = service->InitializeOnMainThread(std::move(aEndpoint));
if (NS_WARN_IF(NS_FAILED(rv))) {
return;
}
sRemoteWorkerService = service;
}
/* static */
nsIThread* RemoteWorkerService::Thread() {
StaticMutexAutoLock lock(sRemoteWorkerServiceMutex);
@ -183,7 +195,8 @@ RemoteWorkerService::MaybeGetKeepAlive() {
return extraRef.forget();
}
nsresult RemoteWorkerService::InitializeOnMainThread() {
nsresult RemoteWorkerService::InitializeOnMainThread(
mozilla::ipc::Endpoint<PRemoteWorkerServiceChild> aEndpoint) {
// I would like to call this thread "DOM Remote Worker Launcher", but the max
// length is 16 chars.
nsresult rv = NS_NewNamedThread("Worker Launcher", getter_AddRefs(mThread));
@ -213,7 +226,9 @@ nsresult RemoteWorkerService::InitializeOnMainThread() {
RefPtr<RemoteWorkerService> self = this;
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
"InitializeThread", [self]() { self->InitializeOnTargetThread(); });
"InitializeThread", [self, endpoint = std::move(aEndpoint)]() mutable {
self->InitializeOnTargetThread(std::move(endpoint));
});
rv = mThread->Dispatch(r.forget(), NS_DISPATCH_NORMAL);
if (NS_WARN_IF(NS_FAILED(rv))) {
@ -230,20 +245,14 @@ RemoteWorkerService::RemoteWorkerService()
RemoteWorkerService::~RemoteWorkerService() = default;
void RemoteWorkerService::InitializeOnTargetThread() {
void RemoteWorkerService::InitializeOnTargetThread(
mozilla::ipc::Endpoint<PRemoteWorkerServiceChild> aEndpoint) {
MOZ_ASSERT(mThread);
MOZ_ASSERT(mThread->IsOnCurrentThread());
PBackgroundChild* backgroundActor =
BackgroundChild::GetOrCreateForCurrentThread();
if (NS_WARN_IF(!backgroundActor)) {
return;
}
RefPtr<RemoteWorkerServiceChild> serviceActor =
MakeAndAddRef<RemoteWorkerServiceChild>();
if (NS_WARN_IF(!backgroundActor->SendPRemoteWorkerServiceConstructor(
serviceActor))) {
if (NS_WARN_IF(!aEndpoint.Bind(serviceActor))) {
return;
}
@ -258,7 +267,7 @@ void RemoteWorkerService::CloseActorOnTargetThread() {
// If mActor is nullptr it means that initialization failed.
if (mActor) {
// Here we need to shutdown the IPC protocol.
mActor->Send__delete__(mActor);
mActor->Close();
mActor = nullptr;
}
}
@ -300,7 +309,12 @@ RemoteWorkerService::Observe(nsISupports* aSubject, const char* aTopic,
obs->RemoveObserver(this, "profile-after-change");
}
return InitializeOnMainThread();
Endpoint<PRemoteWorkerServiceChild> childEp;
RefPtr<RemoteWorkerServiceParent> parentActor =
RemoteWorkerServiceParent::CreateForProcess(nullptr, &childEp);
NS_ENSURE_TRUE(parentActor, NS_ERROR_FAILURE);
return InitializeOnMainThread(std::move(childEp));
}
void RemoteWorkerService::BeginShutdown() {

Просмотреть файл

@ -9,6 +9,7 @@
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/DataMutex.h"
#include "mozilla/ipc/Endpoint.h"
#include "nsCOMPtr.h"
#include "nsIObserver.h"
#include "nsISupportsImpl.h"
@ -20,6 +21,7 @@ namespace mozilla::dom {
class RemoteWorkerService;
class RemoteWorkerServiceChild;
class RemoteWorkerServiceShutdownBlocker;
class PRemoteWorkerServiceChild;
/**
* Refcounted lifecycle helper; when its refcount goes to zero its destructor
@ -67,7 +69,9 @@ class RemoteWorkerService final : public nsIObserver {
NS_DECL_NSIOBSERVER
// To be called when a process is initialized on main-thread.
static void Initialize();
static void InitializeParent();
static void InitializeChild(
mozilla::ipc::Endpoint<PRemoteWorkerServiceChild> aEndpoint);
static nsIThread* Thread();
@ -91,9 +95,11 @@ class RemoteWorkerService final : public nsIObserver {
RemoteWorkerService();
~RemoteWorkerService();
nsresult InitializeOnMainThread();
nsresult InitializeOnMainThread(
mozilla::ipc::Endpoint<PRemoteWorkerServiceChild> aEndpoint);
void InitializeOnTargetThread();
void InitializeOnTargetThread(
mozilla::ipc::Endpoint<PRemoteWorkerServiceChild> aEndpoint);
void CloseActorOnTargetThread();

Просмотреть файл

@ -6,6 +6,7 @@
#include "RemoteWorkerServiceChild.h"
#include "RemoteWorkerController.h"
#include "RemoteWorkerChild.h"
namespace mozilla::dom {
@ -13,4 +14,17 @@ RemoteWorkerServiceChild::RemoteWorkerServiceChild() = default;
RemoteWorkerServiceChild::~RemoteWorkerServiceChild() = default;
already_AddRefed<PRemoteWorkerChild>
RemoteWorkerServiceChild::AllocPRemoteWorkerChild(
const RemoteWorkerData& aData) {
return MakeAndAddRef<RemoteWorkerChild>(aData);
}
mozilla::ipc::IPCResult RemoteWorkerServiceChild::RecvPRemoteWorkerConstructor(
PRemoteWorkerChild* aActor, const RemoteWorkerData& aData) {
RemoteWorkerChild* actor = static_cast<RemoteWorkerChild*>(aActor);
actor->ExecWorker(aData);
return IPC_OK();
}
} // namespace mozilla::dom

Просмотреть файл

@ -17,14 +17,19 @@ class RemoteWorkerData;
/**
* "Worker Launcher"-thread child actor created by the RemoteWorkerService to
* register itself with the PBackground RemoteWorkerManager in the parent.
* receive messages from the PBackground RemoteWorkerManager in the parent.
*/
class RemoteWorkerServiceChild final : public PRemoteWorkerServiceChild {
public:
NS_INLINE_DECL_REFCOUNTING(RemoteWorkerServiceChild, final)
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RemoteWorkerServiceChild, final)
RemoteWorkerServiceChild();
already_AddRefed<PRemoteWorkerChild> AllocPRemoteWorkerChild(
const RemoteWorkerData& aData);
mozilla::ipc::IPCResult RecvPRemoteWorkerConstructor(
PRemoteWorkerChild* aActor, const RemoteWorkerData& aData);
private:
~RemoteWorkerServiceChild();
};

Просмотреть файл

@ -14,20 +14,65 @@ using namespace ipc;
namespace dom {
RemoteWorkerServiceParent::RemoteWorkerServiceParent()
: mManager(RemoteWorkerManager::GetOrCreate()) {}
RemoteWorkerServiceParent::RemoteWorkerServiceParent(
ThreadsafeContentParentHandle* aProcess)
: mProcess(aProcess) {}
RemoteWorkerServiceParent::~RemoteWorkerServiceParent() = default;
RemoteWorkerServiceParent::~RemoteWorkerServiceParent() {
MOZ_ASSERT(!mManager,
"ActorDestroy not called before ~RemoteWorkerServiceParent");
}
void RemoteWorkerServiceParent::Initialize(const nsACString& aRemoteType) {
RefPtr<RemoteWorkerServiceParent> RemoteWorkerServiceParent::CreateForProcess(
ContentParent* aProcess, Endpoint<PRemoteWorkerServiceChild>* aChildEp) {
AssertIsOnMainThread();
nsCOMPtr<nsISerialEventTarget> backgroundThread =
BackgroundParent::GetBackgroundThread();
NS_ENSURE_TRUE(backgroundThread, nullptr);
Endpoint<PRemoteWorkerServiceParent> parentEp;
nsresult rv = PRemoteWorkerService::CreateEndpoints(
base::GetCurrentProcId(),
aProcess ? aProcess->OtherPid() : base::GetCurrentProcId(), &parentEp,
aChildEp);
NS_ENSURE_SUCCESS(rv, nullptr);
RefPtr<RemoteWorkerServiceParent> actor = new RemoteWorkerServiceParent(
aProcess ? aProcess->ThreadsafeHandle() : nullptr);
rv = backgroundThread->Dispatch(
NS_NewRunnableFunction("RemoteWorkerServiceParent::CreateForProcess",
[actor, parentEp = std::move(parentEp)]() mutable {
actor->InitializeOnThread(std::move(parentEp));
}));
NS_ENSURE_SUCCESS(rv, nullptr);
return actor;
}
void RemoteWorkerServiceParent::InitializeOnThread(
Endpoint<PRemoteWorkerServiceParent> aEndpoint) {
AssertIsOnBackgroundThread();
mRemoteType = aRemoteType;
if (NS_WARN_IF(!aEndpoint.Bind(this))) {
return;
}
mManager = RemoteWorkerManager::GetOrCreate();
mManager->RegisterActor(this);
}
void RemoteWorkerServiceParent::ActorDestroy(IProtocol::ActorDestroyReason) {
AssertIsOnBackgroundThread();
mManager->UnregisterActor(this);
if (mManager) {
mManager->UnregisterActor(this);
mManager = nullptr;
}
}
nsCString RemoteWorkerServiceParent::GetRemoteType() const {
if (mProcess) {
return mProcess->GetRemoteType();
}
return NOT_REMOTE_TYPE;
}
} // namespace dom

Просмотреть файл

@ -12,28 +12,39 @@
namespace mozilla::dom {
class ContentParent;
class RemoteWorkerManager;
class ThreadsafeContentParentHandle;
/**
* PBackground parent actor that registers with the PBackground
* PBackground-thread parent actor that registers with the PBackground
* RemoteWorkerManager and used to relay spawn requests.
*/
class RemoteWorkerServiceParent final : public PRemoteWorkerServiceParent {
public:
RemoteWorkerServiceParent();
NS_INLINE_DECL_REFCOUNTING(RemoteWorkerServiceParent, override);
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RemoteWorkerServiceParent, override);
static RefPtr<RemoteWorkerServiceParent> CreateForProcess(
ContentParent* aProcess, Endpoint<PRemoteWorkerServiceChild>* aChildEp);
void ActorDestroy(mozilla::ipc::IProtocol::ActorDestroyReason) override;
void Initialize(const nsACString& aRemoteType);
bool IsOtherProcessActor() const { return mProcess != nullptr; }
nsCString GetRemoteType() const { return mRemoteType; }
ThreadsafeContentParentHandle* GetContentParentHandle() const {
return mProcess;
}
nsCString GetRemoteType() const;
private:
explicit RemoteWorkerServiceParent(ThreadsafeContentParentHandle* aProcess);
~RemoteWorkerServiceParent();
void InitializeOnThread(Endpoint<PRemoteWorkerServiceParent> aEndpoint);
const RefPtr<ThreadsafeContentParentHandle> mProcess;
RefPtr<RemoteWorkerManager> mManager;
nsCString mRemoteType = NOT_REMOTE_TYPE;
};
} // namespace mozilla::dom

Просмотреть файл

@ -69,11 +69,9 @@ namespace mozilla::ipc {
using mozilla::dom::UDPSocketChild;
using mozilla::net::PUDPSocketChild;
using mozilla::dom::PRemoteWorkerChild;
using mozilla::dom::PServiceWorkerChild;
using mozilla::dom::PServiceWorkerContainerChild;
using mozilla::dom::PServiceWorkerRegistrationChild;
using mozilla::dom::RemoteWorkerChild;
using mozilla::dom::StorageDBChild;
using mozilla::dom::cache::PCacheChild;
using mozilla::dom::cache::PCacheStreamControlChild;
@ -252,18 +250,6 @@ bool BackgroundChildImpl::DeallocPBackgroundStorageChild(
return true;
}
already_AddRefed<PRemoteWorkerChild>
BackgroundChildImpl::AllocPRemoteWorkerChild(const RemoteWorkerData& aData) {
return MakeAndAddRef<RemoteWorkerChild>(aData);
}
IPCResult BackgroundChildImpl::RecvPRemoteWorkerConstructor(
PRemoteWorkerChild* aActor, const RemoteWorkerData& aData) {
dom::RemoteWorkerChild* actor = static_cast<dom::RemoteWorkerChild*>(aActor);
actor->ExecWorker(aData);
return IPC_OK();
}
dom::PSharedWorkerChild* BackgroundChildImpl::AllocPSharedWorkerChild(
const dom::RemoteWorkerData& aData, const uint64_t& aWindowID,
const dom::MessagePortIdentifier& aPortIdentifier) {

Просмотреть файл

@ -102,12 +102,6 @@ class BackgroundChildImpl : public PBackgroundChild {
virtual bool DeallocPFileCreatorChild(PFileCreatorChild* aActor) override;
already_AddRefed<mozilla::dom::PRemoteWorkerChild> AllocPRemoteWorkerChild(
const RemoteWorkerData& aData) override;
virtual mozilla::ipc::IPCResult RecvPRemoteWorkerConstructor(
PRemoteWorkerChild* aActor, const RemoteWorkerData& aData) override;
virtual mozilla::dom::PSharedWorkerChild* AllocPSharedWorkerChild(
const mozilla::dom::RemoteWorkerData& aData, const uint64_t& aWindowID,
const mozilla::dom::MessagePortIdentifier& aPortIdentifier) override;

Просмотреть файл

@ -652,7 +652,7 @@ void AssertIsOnBackgroundThread() { ParentImpl::AssertIsOnBackgroundThread(); }
// -----------------------------------------------------------------------------
// static
already_AddRefed<nsISerialEventTarget> GetBackgroundThread() {
already_AddRefed<nsISerialEventTarget> BackgroundParent::GetBackgroundThread() {
return ParentImpl::GetBackgroundThread();
}

Просмотреть файл

@ -527,27 +527,6 @@ IPCResult BackgroundParentImpl::RecvPRemoteWorkerControllerConstructor(
return IPC_OK();
}
already_AddRefed<dom::PRemoteWorkerServiceParent>
BackgroundParentImpl::AllocPRemoteWorkerServiceParent() {
return MakeAndAddRef<dom::RemoteWorkerServiceParent>();
}
IPCResult BackgroundParentImpl::RecvPRemoteWorkerServiceConstructor(
PRemoteWorkerServiceParent* aActor) {
mozilla::dom::RemoteWorkerServiceParent* actor =
static_cast<mozilla::dom::RemoteWorkerServiceParent*>(aActor);
RefPtr<ThreadsafeContentParentHandle> parent =
BackgroundParent::GetContentParentHandle(this);
// If the ContentParent is null we are dealing with a same-process actor.
if (!parent) {
actor->Initialize(NOT_REMOTE_TYPE);
} else {
actor->Initialize(parent->GetRemoteType());
}
return IPC_OK();
}
mozilla::dom::PSharedWorkerParent*
BackgroundParentImpl::AllocPSharedWorkerParent(
const mozilla::dom::RemoteWorkerData& aData, const uint64_t& aWindowID,

Просмотреть файл

@ -169,12 +169,6 @@ class BackgroundParentImpl : public PBackgroundParent {
mozilla::dom::PRemoteWorkerControllerParent* aActor,
const mozilla::dom::RemoteWorkerData& aRemoteWorkerData) override;
already_AddRefed<PRemoteWorkerServiceParent> AllocPRemoteWorkerServiceParent()
override;
mozilla::ipc::IPCResult RecvPRemoteWorkerServiceConstructor(
PRemoteWorkerServiceParent* aActor) override;
mozilla::dom::PSharedWorkerParent* AllocPSharedWorkerParent(
const mozilla::dom::RemoteWorkerData& aData, const uint64_t& aWindowID,
const mozilla::dom::MessagePortIdentifier& aPortIdentifier) override;

Просмотреть файл

@ -27,7 +27,6 @@ include protocol PGamepadEventChannel;
include protocol PGamepadTestChannel;
include protocol PHttpBackgroundChannel;
include protocol PIdleScheduler;
include protocol PRemoteWorker;
include protocol PRemoteWorkerController;
include protocol PRemoteWorkerService;
include protocol PSharedWorker;
@ -107,9 +106,7 @@ sync protocol PBackground
manages PHttpBackgroundChannel;
manages PIdleScheduler;
manages PLockManager;
manages PRemoteWorker;
manages PRemoteWorkerController;
manages PRemoteWorkerService;
manages PSharedWorker;
manages PTemporaryIPCBlob;
manages PFileCreator;
@ -261,8 +258,6 @@ parent:
async PRemoteWorkerController(RemoteWorkerData aData);
async PRemoteWorkerService();
async PServiceWorkerContainer();
async PServiceWorkerRegistration(IPCServiceWorkerRegistrationDescriptor aDescriptor);
@ -289,8 +284,6 @@ parent:
child:
async PCache();
async PCacheStreamControl();
async PRemoteWorker(RemoteWorkerData data);
};
} // namespace ipc

Просмотреть файл

@ -253,7 +253,7 @@ nsresult nsLayoutStatics::Initialize() {
if (XRE_IsParentProcess()) {
// On content process we initialize these components when PContentChild is
// fully initialized.
mozilla::dom::RemoteWorkerService::Initialize();
mozilla::dom::RemoteWorkerService::InitializeParent();
}
ClearSiteData::Initialize();