Bug 1700051: part 35) Reduce accessibility of `mSoftText.mDOMMapping` to `private...
[gecko.git] / dom / base / ContentProcessMessageManager.h
blob5e859838060dff3dcfbc92db6942d1025789022f
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_ContentProcessMessageManager_h
8 #define mozilla_dom_ContentProcessMessageManager_h
10 #include "mozilla/Attributes.h"
11 #include "mozilla/dom/MessageManagerGlobal.h"
12 #include "mozilla/dom/MessageManagerCallback.h"
13 #include "nsCOMPtr.h"
14 #include "nsIScriptContext.h"
15 #include "nsIScriptContext.h"
16 #include "nsServiceManagerUtils.h"
17 #include "nsWeakReference.h"
18 #include "nsWrapperCache.h"
19 #include "xpcpublic.h"
21 class nsFrameMessageManager;
23 namespace mozilla {
24 namespace dom {
26 namespace ipc {
27 class SharedMap;
30 /**
31 * This class implements a singleton process message manager for content
32 * processes. Each child process has exactly one instance of this class, which
33 * hosts the process's process scripts, and may exchange messages with its
34 * corresponding ParentProcessMessageManager on the parent side.
37 class ContentProcessMessageManager : public nsIMessageSender,
38 public nsMessageManagerScriptExecutor,
39 public nsSupportsWeakReference,
40 public ipc::MessageManagerCallback,
41 public MessageManagerGlobal,
42 public nsWrapperCache {
43 public:
44 explicit ContentProcessMessageManager(nsFrameMessageManager* aMessageManager);
46 using ipc::MessageManagerCallback::GetProcessMessageManager;
47 using MessageManagerGlobal::GetProcessMessageManager;
49 bool Init();
51 static ContentProcessMessageManager* Get();
52 static bool WasCreated();
54 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
55 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(
56 ContentProcessMessageManager, nsIMessageSender)
58 void MarkForCC();
60 virtual JSObject* WrapObject(JSContext* aCx,
61 JS::Handle<JSObject*> aGivenProto) override;
63 JSObject* GetOrCreateWrapper();
65 using MessageManagerGlobal::AddMessageListener;
66 using MessageManagerGlobal::AddWeakMessageListener;
67 using MessageManagerGlobal::RemoveMessageListener;
68 using MessageManagerGlobal::RemoveWeakMessageListener;
70 // ContentProcessMessageManager
71 void GetInitialProcessData(JSContext* aCx,
72 JS::MutableHandle<JS::Value> aInitialProcessData,
73 ErrorResult& aError) {
74 if (!mMessageManager) {
75 aError.Throw(NS_ERROR_NOT_INITIALIZED);
76 return;
78 mMessageManager->GetInitialProcessData(aCx, aInitialProcessData, aError);
81 already_AddRefed<ipc::SharedMap> GetSharedData();
83 NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager)
85 nsIGlobalObject* GetParentObject() const {
86 return xpc::NativeGlobal(xpc::PrivilegedJunkScope());
89 virtual void LoadScript(const nsAString& aURL);
91 bool IsProcessScoped() const override { return true; }
93 void SetInitialProcessData(JS::HandleValue aInitialData);
95 protected:
96 virtual ~ContentProcessMessageManager();
98 private:
99 bool mInitialized;
101 static bool sWasCreated;
104 } // namespace dom
105 } // namespace mozilla
107 #endif // mozilla_dom_ContentProcessMessageManager_h