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_nsIContentChild_h
8 #define mozilla_dom_nsIContentChild_h
9 
10 #include "mozilla/dom/ipc/IdType.h"
11 
12 #include "nsISupports.h"
13 #include "nsTArrayForwardDeclare.h"
14 #include "mozilla/dom/CPOWManagerGetter.h"
15 #include "mozilla/ipc/Shmem.h"
16 #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
17 
18 #define NS_ICONTENTCHILD_IID                                    \
19   { 0x4eed2e73, 0x94ba, 0x48a8,                                 \
20     { 0xa2, 0xd1, 0xa5, 0xed, 0x86, 0xd7, 0xbb, 0xe4 } }
21 
22 class nsString;
23 
24 namespace IPC {
25 class Principal;
26 } // namespace IPC
27 
28 namespace mozilla {
29 namespace ipc {
30 class FileDescriptor;
31 class PFileDescriptorSetChild;
32 class PSendStreamChild;
33 class Shmem;
34 } // namespace ipc
35 
36 namespace jsipc {
37 class PJavaScriptChild;
38 class CpowEntry;
39 } // namespace jsipc
40 
41 namespace dom {
42 
43 class Blob;
44 class BlobChild;
45 class BlobImpl;
46 class BlobConstructorParams;
47 class ClonedMessageData;
48 class IPCTabContext;
49 class PBlobChild;
50 class PBrowserChild;
51 
52 class nsIContentChild : public nsISupports
53                       , public CPOWManagerGetter
54                       , public mozilla::ipc::IShmemAllocator
55 {
56 public:
57   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENTCHILD_IID)
58 
59   BlobChild* GetOrCreateActorForBlob(Blob* aBlob);
60   BlobChild* GetOrCreateActorForBlobImpl(BlobImpl* aImpl);
61 
62   virtual PBlobChild*
63   SendPBlobConstructor(PBlobChild* aActor,
64                        const BlobConstructorParams& aParams) = 0;
65 
66   virtual bool
67   SendPBrowserConstructor(PBrowserChild* aActor,
68                           const TabId& aTabId,
69                           const IPCTabContext& aContext,
70                           const uint32_t& aChromeFlags,
71                           const ContentParentId& aCpID,
72                           const bool& aIsForApp,
73                           const bool& aIsForBrowser) = 0;
74 
75   virtual mozilla::ipc::PFileDescriptorSetChild*
76   SendPFileDescriptorSetConstructor(const mozilla::ipc::FileDescriptor&) = 0;
77 
78   virtual mozilla::ipc::PSendStreamChild*
79   SendPSendStreamConstructor(mozilla::ipc::PSendStreamChild*) = 0;
80 
81 protected:
82   virtual jsipc::PJavaScriptChild* AllocPJavaScriptChild();
83   virtual bool DeallocPJavaScriptChild(jsipc::PJavaScriptChild*);
84 
85   virtual PBrowserChild* AllocPBrowserChild(const TabId& aTabId,
86                                             const IPCTabContext& aContext,
87                                             const uint32_t& aChromeFlags,
88                                             const ContentParentId& aCpId,
89                                             const bool& aIsForApp,
90                                             const bool& aIsForBrowser);
91   virtual bool DeallocPBrowserChild(PBrowserChild*);
92 
93   virtual PBlobChild* AllocPBlobChild(const BlobConstructorParams& aParams);
94 
95   virtual bool DeallocPBlobChild(PBlobChild* aActor);
96 
97   virtual mozilla::ipc::PSendStreamChild* AllocPSendStreamChild();
98 
99   virtual bool DeallocPSendStreamChild(mozilla::ipc::PSendStreamChild* aActor);
100 
101   virtual mozilla::ipc::PFileDescriptorSetChild*
102   AllocPFileDescriptorSetChild(const mozilla::ipc::FileDescriptor& aFD);
103 
104   virtual bool
105   DeallocPFileDescriptorSetChild(mozilla::ipc::PFileDescriptorSetChild* aActor);
106 
107   virtual bool RecvAsyncMessage(const nsString& aMsg,
108                                 InfallibleTArray<jsipc::CpowEntry>&& aCpows,
109                                 const IPC::Principal& aPrincipal,
110                                 const ClonedMessageData& aData);
111 };
112 
113 NS_DEFINE_STATIC_IID_ACCESSOR(nsIContentChild, NS_ICONTENTCHILD_IID)
114 
115 } // namespace dom
116 } // namespace mozilla
117 
118 #endif /* mozilla_dom_nsIContentChild_h */
119