Replace bare remote type strings in C++ process-selection plumbing with a RemoteType type which stores the parsed kind, isolation URI, and process selection attributes directly. This preserves the existing serialized string form for IPC and JS-facing APIs, while making native callers use explicit predicates and structured fields instead of manually parsing remote type prefixes and suffixes. No JS-exposed API for parsing or otherwise interpreting remote types are currently exposed in this patch. My current expectation is that this will likely look like a `nsIRemoteType` interface which wraps this `RemoteType` value type, exposing helpful getters for JS callers. Differential Revision: https://phabricator.services.mozilla.com/D310442
75 lines
2.4 KiB
C++
75 lines
2.4 KiB
C++
/* 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_InProcessParent_h
|
|
#define mozilla_dom_InProcessParent_h
|
|
|
|
#include "mozilla/StaticPtr.h"
|
|
#include "mozilla/dom/JSProcessActorParent.h"
|
|
#include "mozilla/dom/PInProcessParent.h"
|
|
#include "mozilla/dom/ProcessActor.h"
|
|
#include "mozilla/dom/RemoteType.h"
|
|
#include "nsIDOMProcessParent.h"
|
|
|
|
namespace mozilla::dom {
|
|
class PWindowGlobalParent;
|
|
class PWindowGlobalChild;
|
|
class InProcessChild;
|
|
|
|
/**
|
|
* The `InProcessParent` class represents the parent half of a main-thread to
|
|
* main-thread actor.
|
|
*
|
|
* The `PInProcess` actor should be used as an alternate manager to `PContent`
|
|
* for async actors which want to communicate uniformly between Content->Chrome
|
|
* and Chrome->Chrome situations.
|
|
*/
|
|
class InProcessParent final : public nsIDOMProcessParent,
|
|
public nsIObserver,
|
|
public PInProcessParent,
|
|
public ProcessActor {
|
|
public:
|
|
friend class InProcessChild;
|
|
friend class PInProcessParent;
|
|
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSIDOMPROCESSPARENT
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
// Get the singleton instance of this actor.
|
|
static InProcessParent* Singleton();
|
|
|
|
// Get the child side of the in-process child actor |aActor|. If |aActor| is
|
|
// not an in-process actor, or is not connected, this method will return
|
|
// |nullptr|.
|
|
static IProtocol* ChildActorFor(IProtocol* aActor);
|
|
|
|
const RemoteType& GetRemoteType() const override {
|
|
return RemoteType::NotRemote();
|
|
};
|
|
|
|
protected:
|
|
already_AddRefed<JSActor> InitJSActor(JS::Handle<JSObject*> aMaybeActor,
|
|
const nsACString& aName,
|
|
ErrorResult& aRv) override;
|
|
mozilla::ipc::IProtocol* AsNativeActor() override { return this; }
|
|
|
|
private:
|
|
// Lifecycle management is implemented in InProcessImpl.cpp
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
|
~InProcessParent() = default;
|
|
|
|
static void Startup();
|
|
static void Shutdown();
|
|
|
|
static StaticRefPtr<InProcessParent> sSingleton;
|
|
static bool sShutdown;
|
|
|
|
nsRefPtrHashtable<nsCStringHashKey, JSProcessActorParent> mProcessActors;
|
|
};
|
|
|
|
} // namespace mozilla::dom
|
|
|
|
#endif // defined(mozilla_dom_InProcessParent_h)
|