/work/obj-fuzz/dist/include/mozilla/dom/ContentProcessMessageManager.h
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #ifndef mozilla_dom_ContentProcessMessageManager_h |
8 | | #define mozilla_dom_ContentProcessMessageManager_h |
9 | | |
10 | | #include "mozilla/Attributes.h" |
11 | | #include "mozilla/dom/MessageManagerGlobal.h" |
12 | | #include "nsCOMPtr.h" |
13 | | #include "nsFrameMessageManager.h" |
14 | | #include "nsIScriptContext.h" |
15 | | #include "nsIScriptContext.h" |
16 | | #include "nsIClassInfo.h" |
17 | | #include "nsIRunnable.h" |
18 | | #include "nsServiceManagerUtils.h" |
19 | | #include "nsWeakReference.h" |
20 | | #include "nsWrapperCache.h" |
21 | | #include "xpcpublic.h" |
22 | | |
23 | | namespace mozilla { |
24 | | namespace dom { |
25 | | |
26 | | namespace ipc { |
27 | | class SharedMap; |
28 | | } |
29 | | |
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. |
35 | | */ |
36 | | |
37 | | class ContentProcessMessageManager : |
38 | | public nsIMessageSender, |
39 | | public nsMessageManagerScriptExecutor, |
40 | | public nsSupportsWeakReference, |
41 | | public ipc::MessageManagerCallback, |
42 | | public MessageManagerGlobal, |
43 | | public nsWrapperCache |
44 | | { |
45 | | public: |
46 | | explicit ContentProcessMessageManager(nsFrameMessageManager* aMessageManager); |
47 | | |
48 | | using ipc::MessageManagerCallback::GetProcessMessageManager; |
49 | | using MessageManagerGlobal::GetProcessMessageManager; |
50 | | |
51 | | bool Init(); |
52 | | |
53 | | static ContentProcessMessageManager* Get(); |
54 | | static bool WasCreated(); |
55 | | |
56 | | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
57 | | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(ContentProcessMessageManager, nsIMessageSender) |
58 | | |
59 | | void MarkForCC(); |
60 | | |
61 | | virtual JSObject* WrapObject(JSContext* aCx, |
62 | | JS::Handle<JSObject*> aGivenProto) override; |
63 | | |
64 | | JSObject* GetOrCreateWrapper(); |
65 | | |
66 | | using MessageManagerGlobal::AddMessageListener; |
67 | | using MessageManagerGlobal::RemoveMessageListener; |
68 | | using MessageManagerGlobal::AddWeakMessageListener; |
69 | | using MessageManagerGlobal::RemoveWeakMessageListener; |
70 | | |
71 | | // ContentProcessMessageManager |
72 | | void GetInitialProcessData(JSContext* aCx, |
73 | | JS::MutableHandle<JS::Value> aInitialProcessData, |
74 | | ErrorResult& aError) |
75 | 0 | { |
76 | 0 | if (!mMessageManager) { |
77 | 0 | aError.Throw(NS_ERROR_NULL_POINTER); |
78 | 0 | return; |
79 | 0 | } |
80 | 0 | mMessageManager->GetInitialProcessData(aCx, aInitialProcessData, aError); |
81 | 0 | } |
82 | | |
83 | | already_AddRefed<ipc::SharedMap> SharedData(); |
84 | | |
85 | | NS_FORWARD_SAFE_NSIMESSAGESENDER(mMessageManager) |
86 | | |
87 | 0 | nsIGlobalObject* GetParentObject() const { return xpc::NativeGlobal(xpc::PrivilegedJunkScope()); } |
88 | | |
89 | | virtual void LoadScript(const nsAString& aURL); |
90 | | |
91 | | bool IsProcessScoped() const override |
92 | | { |
93 | | return true; |
94 | | } |
95 | | |
96 | | void SetInitialProcessData(JS::HandleValue aInitialData); |
97 | | |
98 | | protected: |
99 | | virtual ~ContentProcessMessageManager(); |
100 | | |
101 | | private: |
102 | | bool mInitialized; |
103 | | |
104 | | static bool sWasCreated; |
105 | | }; |
106 | | |
107 | | } // namespace dom |
108 | | } // namespace mozilla |
109 | | |
110 | | #endif // mozilla_dom_ContentProcessMessageManager_h |