gecko-dev/dom/workers/remoteworkers/RemoteWorkerServiceChild.h
Eden Chuang 55ffcda3fa Bug 1672493 - P2 Create IPC PRemoteWorkerNonLifeCycleOpController. r=asuth
In this patch, IPC PRemoteWorkerNonLifeCycleOpController is created for non-life cycle operations of SharedWorker/ServiceWorker.

PRemoteWorkerNonLifeCycleOpController is the IPC between the content process worker thread and the parent process background thread.
This IPC helps to build a direct communication instead of go through worker launcher thread and the main thread.

Endpoint<PRemoteWorkerNonLifeCycleOpControllerParent/Child> pairs are created when RemoteWorkerManager::LaunchInternal().
The parent Endpoint is binded a RemoteWorkerNonLifeCycleOpControllerParent immediately and connect to the corresponding RemoteWorkerController.
And the child Endpoint is passed through IPC PRemoteWorkerService::SendPRemoteWorkerConstructor() to the content process, and then binds to a PRemoteWorkerNonLifeCycleOpControllerChild when the Worker gets into "Running" state.

After connection is built, RemoteWorkerController can send non-life cycle related operations by PRemoteWorkerNonLifeCycleOpController and send life cycle related operations by PRemoteWorker.

Depends on D196946

Differential Revision: https://phabricator.services.mozilla.com/D197563
2024-11-14 09:46:16 +00:00

46 lines
1.5 KiB
C++

/* -*- 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_RemoteWorkerServiceChild_h
#define mozilla_dom_RemoteWorkerServiceChild_h
#include "mozilla/dom/PRemoteWorkerServiceChild.h"
#include "mozilla/dom/PRemoteWorkerNonLifeCycleOpControllerChild.h"
#include "nsISupportsImpl.h"
namespace mozilla::dom {
class RemoteWorkerController;
class RemoteWorkerData;
/**
* "Worker Launcher"-thread child actor created by the RemoteWorkerService to
* receive messages from the PBackground RemoteWorkerManager in the parent.
*/
class RemoteWorkerServiceChild final : public PRemoteWorkerServiceChild {
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RemoteWorkerServiceChild, final)
RemoteWorkerServiceChild();
already_AddRefed<PRemoteWorkerChild> AllocPRemoteWorkerChild(
const RemoteWorkerData& aData,
mozilla::ipc::Endpoint<PRemoteWorkerNonLifeCycleOpControllerChild>&
aChildEp);
mozilla::ipc::IPCResult RecvPRemoteWorkerConstructor(
PRemoteWorkerChild* aActor, const RemoteWorkerData& aData,
mozilla::ipc::Endpoint<PRemoteWorkerNonLifeCycleOpControllerChild>&&
aChildEp);
private:
~RemoteWorkerServiceChild();
};
} // namespace mozilla::dom
#endif // mozilla_dom_RemoteWorkerServiceChild_h