Line data Source code
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 file,
5 : * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef mozilla_dom_ContentBridgeParent_h
8 : #define mozilla_dom_ContentBridgeParent_h
9 :
10 : #include "mozilla/dom/PContentBridgeParent.h"
11 : #include "mozilla/dom/nsIContentParent.h"
12 : #include "mozilla/dom/ipc/IdType.h"
13 : #include "nsIObserver.h"
14 :
15 : namespace mozilla {
16 : namespace dom {
17 :
18 : class ContentBridgeParent : public PContentBridgeParent
19 : , public nsIContentParent
20 : , public nsIObserver
21 : {
22 : public:
23 : explicit ContentBridgeParent();
24 :
25 : NS_DECL_ISUPPORTS
26 : NS_DECL_NSIOBSERVER
27 :
28 : virtual void ActorDestroy(ActorDestroyReason aWhy) override;
29 : void DeferredDestroy();
30 0 : virtual bool IsContentBridgeParent() const override { return true; }
31 : void NotifyTabDestroyed();
32 :
33 : static ContentBridgeParent*
34 : Create(Endpoint<PContentBridgeParent>&& aEndpoint);
35 :
36 : virtual PBrowserParent*
37 : SendPBrowserConstructor(PBrowserParent* aActor,
38 : const TabId& aTabId,
39 : const TabId& aSameTabGroupAs,
40 : const IPCTabContext& aContext,
41 : const uint32_t& aChromeFlags,
42 : const ContentParentId& aCpID,
43 : const bool& aIsForBrowser) override;
44 :
45 : virtual PFileDescriptorSetParent*
46 : SendPFileDescriptorSetConstructor(const FileDescriptor&) override;
47 :
48 0 : FORWARD_SHMEM_ALLOCATOR_TO(PContentBridgeParent)
49 :
50 : jsipc::CPOWManager* GetCPOWManager() override;
51 :
52 0 : virtual ContentParentId ChildID() const override
53 : {
54 0 : return mChildID;
55 : }
56 0 : virtual bool IsForBrowser() const override
57 : {
58 0 : return mIsForBrowser;
59 : }
60 0 : virtual int32_t Pid() const override
61 : {
62 : // XXX: do we need this for ContentBridgeParent?
63 0 : return -1;
64 : }
65 0 : virtual bool IsForJSPlugin() const override
66 : {
67 0 : return mIsForJSPlugin;
68 : }
69 :
70 :
71 : virtual mozilla::ipc::PParentToChildStreamParent*
72 : SendPParentToChildStreamConstructor(mozilla::ipc::PParentToChildStreamParent*) override;
73 :
74 0 : virtual bool SendActivate(PBrowserParent* aTab) override
75 : {
76 0 : return PContentBridgeParent::SendActivate(aTab);
77 : }
78 :
79 0 : virtual bool SendDeactivate(PBrowserParent* aTab) override
80 : {
81 0 : return PContentBridgeParent::SendDeactivate(aTab);
82 : }
83 :
84 0 : virtual bool SendParentActivated(PBrowserParent* aTab,
85 : const bool& aActivated) override
86 : {
87 0 : return PContentBridgeParent::SendParentActivated(aTab, aActivated);
88 : }
89 :
90 : protected:
91 : virtual ~ContentBridgeParent();
92 :
93 0 : void SetChildID(ContentParentId aId)
94 : {
95 0 : mChildID = aId;
96 0 : }
97 :
98 0 : void SetIsForBrowser(bool aIsForBrowser)
99 : {
100 0 : mIsForBrowser = aIsForBrowser;
101 0 : }
102 0 : void SetIsForJSPlugin(bool aIsForJSPlugin)
103 : {
104 0 : mIsForJSPlugin = aIsForJSPlugin;
105 0 : }
106 :
107 0 : void Close()
108 : {
109 : // Trick NewRunnableMethod
110 0 : PContentBridgeParent::Close();
111 0 : }
112 :
113 : protected:
114 : virtual mozilla::ipc::IPCResult
115 : RecvSyncMessage(const nsString& aMsg,
116 : const ClonedMessageData& aData,
117 : InfallibleTArray<jsipc::CpowEntry>&& aCpows,
118 : const IPC::Principal& aPrincipal,
119 : nsTArray<StructuredCloneData>* aRetvals) override;
120 :
121 : virtual mozilla::ipc::IPCResult RecvAsyncMessage(const nsString& aMsg,
122 : InfallibleTArray<jsipc::CpowEntry>&& aCpows,
123 : const IPC::Principal& aPrincipal,
124 : const ClonedMessageData& aData) override;
125 :
126 : virtual jsipc::PJavaScriptParent* AllocPJavaScriptParent() override;
127 :
128 : virtual bool
129 : DeallocPJavaScriptParent(jsipc::PJavaScriptParent*) override;
130 :
131 : virtual PBrowserParent*
132 : AllocPBrowserParent(const TabId& aTabId,
133 : const TabId& aSameTabGroupAs,
134 : const IPCTabContext &aContext,
135 : const uint32_t& aChromeFlags,
136 : const ContentParentId& aCpID,
137 : const bool& aIsForBrowser) override;
138 :
139 : virtual bool DeallocPBrowserParent(PBrowserParent*) override;
140 :
141 : virtual PIPCBlobInputStreamParent*
142 : SendPIPCBlobInputStreamConstructor(PIPCBlobInputStreamParent* aActor,
143 : const nsID& aID,
144 : const uint64_t& aSize) override;
145 :
146 : virtual PIPCBlobInputStreamParent*
147 : AllocPIPCBlobInputStreamParent(const nsID& aID,
148 : const uint64_t& aSize) override;
149 :
150 : virtual bool
151 : DeallocPIPCBlobInputStreamParent(PIPCBlobInputStreamParent*) override;
152 :
153 : virtual PChildToParentStreamParent* AllocPChildToParentStreamParent() override;
154 :
155 : virtual bool
156 : DeallocPChildToParentStreamParent(PChildToParentStreamParent* aActor) override;
157 :
158 : virtual mozilla::ipc::PParentToChildStreamParent*
159 : AllocPParentToChildStreamParent() override;
160 :
161 : virtual bool
162 : DeallocPParentToChildStreamParent(mozilla::ipc::PParentToChildStreamParent* aActor) override;
163 :
164 : virtual PFileDescriptorSetParent*
165 : AllocPFileDescriptorSetParent(const mozilla::ipc::FileDescriptor&) override;
166 :
167 : virtual bool
168 : DeallocPFileDescriptorSetParent(PFileDescriptorSetParent*) override;
169 :
170 : DISALLOW_EVIL_CONSTRUCTORS(ContentBridgeParent);
171 :
172 : protected: // members
173 : RefPtr<ContentBridgeParent> mSelfRef;
174 : ContentParentId mChildID;
175 : bool mIsForBrowser;
176 : bool mIsForJSPlugin;
177 :
178 : private:
179 : friend class ContentParent;
180 : };
181 :
182 : } // namespace dom
183 : } // namespace mozilla
184 :
185 : #endif // mozilla_dom_ContentBridgeParent_h
|