Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / ipc / InProcessChild.h
blob16176ef98b9bc44f9066e2dc0ac3e7f05eb03ca5
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_InProcessChild_h
8 #define mozilla_dom_InProcessChild_h
10 #include "mozilla/dom/PInProcessChild.h"
11 #include "mozilla/dom/JSProcessActorChild.h"
12 #include "mozilla/dom/ProcessActor.h"
13 #include "mozilla/dom/RemoteType.h"
14 #include "mozilla/StaticPtr.h"
15 #include "nsIDOMProcessChild.h"
17 namespace mozilla::dom {
18 class PWindowGlobalParent;
19 class PWindowGlobalChild;
20 class InProcessParent;
22 /**
23 * The `InProcessChild` class represents the child half of a main-thread to
24 * main-thread actor.
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 InProcessChild final : public nsIDOMProcessChild,
31 public PInProcessChild,
32 public ProcessActor {
33 public:
34 friend class InProcessParent;
35 friend class PInProcessChild;
37 NS_DECL_ISUPPORTS
38 NS_DECL_NSIDOMPROCESSCHILD
40 // Get the singleton instance of this actor.
41 static InProcessChild* Singleton();
43 // Get the parent side of the in-process child actor |aActor|. If |aActor| is
44 // not an in-process actor, or is not connected, this method will return
45 // |nullptr|.
46 static IProtocol* ParentActorFor(IProtocol* aActor);
48 const nsACString& GetRemoteType() const override { return NOT_REMOTE_TYPE; }
50 protected:
51 already_AddRefed<JSActor> InitJSActor(JS::Handle<JSObject*> aMaybeActor,
52 const nsACString& aName,
53 ErrorResult& aRv) override;
54 mozilla::ipc::IProtocol* AsNativeActor() override { return this; }
56 private:
57 // NOTE: PInProcess lifecycle management is declared as staic methods and
58 // state on InProcessParent, and implemented in InProcessImpl.cpp.
59 virtual void ActorDestroy(ActorDestroyReason aWhy) override;
60 ~InProcessChild() = default;
62 static StaticRefPtr<InProcessChild> sSingleton;
64 nsRefPtrHashtable<nsCStringHashKey, JSProcessActorChild> mProcessActors;
67 } // namespace mozilla::dom
69 #endif // defined(mozilla_dom_InProcessChild_h)