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
70 lines
2.3 KiB
C++
70 lines
2.3 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_InProcessChild_h
|
|
#define mozilla_dom_InProcessChild_h
|
|
|
|
#include "mozilla/StaticPtr.h"
|
|
#include "mozilla/dom/JSProcessActorChild.h"
|
|
#include "mozilla/dom/PInProcessChild.h"
|
|
#include "mozilla/dom/ProcessActor.h"
|
|
#include "mozilla/dom/RemoteType.h"
|
|
#include "nsIDOMProcessChild.h"
|
|
|
|
namespace mozilla::dom {
|
|
class PWindowGlobalParent;
|
|
class PWindowGlobalChild;
|
|
class InProcessParent;
|
|
|
|
/**
|
|
* The `InProcessChild` class represents the child 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 InProcessChild final : public nsIDOMProcessChild,
|
|
public PInProcessChild,
|
|
public ProcessActor {
|
|
public:
|
|
friend class InProcessParent;
|
|
friend class PInProcessChild;
|
|
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSIDOMPROCESSCHILD
|
|
|
|
// Get the singleton instance of this actor.
|
|
static InProcessChild* Singleton();
|
|
|
|
// Get the parent 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* ParentActorFor(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:
|
|
// NOTE: PInProcess lifecycle management is declared as staic methods and
|
|
// state on InProcessParent, and implemented in InProcessImpl.cpp.
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
|
~InProcessChild() = default;
|
|
|
|
static StaticRefPtr<InProcessChild> sSingleton;
|
|
|
|
nsRefPtrHashtable<nsCStringHashKey, JSProcessActorChild> mProcessActors;
|
|
};
|
|
|
|
} // namespace mozilla::dom
|
|
|
|
#endif // defined(mozilla_dom_InProcessChild_h)
|