1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_InProcessParent_h
8 #define mozilla_dom_InProcessParent_h
10 #include "mozilla/dom/PInProcessParent.h"
11 #include "mozilla/dom/JSProcessActorParent.h"
12 #include "mozilla/dom/ProcessActor.h"
13 #include "mozilla/dom/RemoteType.h"
14 #include "mozilla/StaticPtr.h"
15 #include "nsIDOMProcessParent.h"
17 namespace mozilla::dom
{
18 class PWindowGlobalParent
;
19 class PWindowGlobalChild
;
23 * The `InProcessParent` class represents the parent half of a main-thread to
26 * The `PInProcess` actor should be used as an alternate manager to `PContent`
27 * for async actors which want to communicate uniformly between Content->Chrome
28 * and Chrome->Chrome situations.
30 class InProcessParent final
: public nsIDOMProcessParent
,
32 public PInProcessParent
,
35 friend class InProcessChild
;
36 friend class PInProcessParent
;
39 NS_DECL_NSIDOMPROCESSPARENT
42 // Get the singleton instance of this actor.
43 static InProcessParent
* Singleton();
45 // Get the child side of the in-process child actor |aActor|. If |aActor| is
46 // not an in-process actor, or is not connected, this method will return
48 static IProtocol
* ChildActorFor(IProtocol
* aActor
);
50 const nsACString
& GetRemoteType() const override
{ return NOT_REMOTE_TYPE
; };
53 already_AddRefed
<JSActor
> InitJSActor(JS::Handle
<JSObject
*> aMaybeActor
,
54 const nsACString
& aName
,
55 ErrorResult
& aRv
) override
;
56 mozilla::ipc::IProtocol
* AsNativeActor() override
{ return this; }
59 // Lifecycle management is implemented in InProcessImpl.cpp
60 virtual void ActorDestroy(ActorDestroyReason aWhy
) override
;
61 ~InProcessParent() = default;
63 static void Startup();
64 static void Shutdown();
66 static StaticRefPtr
<InProcessParent
> sSingleton
;
67 static bool sShutdown
;
69 nsRefPtrHashtable
<nsCStringHashKey
, JSProcessActorParent
> mProcessActors
;
72 } // namespace mozilla::dom
74 #endif // defined(mozilla_dom_InProcessParent_h)