/work/obj-fuzz/ipc/ipdl/PCacheChild.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // |
2 | | // Automatically generated by ipdlc. |
3 | | // Edit at your own risk |
4 | | // |
5 | | |
6 | | |
7 | | #include "mozilla/dom/cache/PCacheChild.h" |
8 | | |
9 | | #include "mozilla/ipc/PBackgroundChild.h" |
10 | | #include "mozilla/dom/cache/PCacheOpChild.h" |
11 | | #include "mozilla/dom/cache/PCacheStreamControlChild.h" |
12 | | #include "mozilla/ipc/PFileDescriptorSetChild.h" |
13 | | #include "mozilla/ipc/PChildToParentStreamChild.h" |
14 | | #include "mozilla/ipc/PParentToChildStreamChild.h" |
15 | | |
16 | | #include "nsIFile.h" |
17 | | #include "GeckoProfiler.h" |
18 | | |
19 | | namespace mozilla { |
20 | | namespace dom { |
21 | | namespace cache { |
22 | | |
23 | | |
24 | | auto PCacheChild::Recv__delete__() -> mozilla::ipc::IPCResult |
25 | 0 | { |
26 | 0 | return IPC_OK(); |
27 | 0 | } |
28 | | |
29 | | auto PCacheChild::ActorDestroy(ActorDestroyReason aWhy) -> void |
30 | 0 | { |
31 | 0 | } |
32 | | |
33 | | MOZ_IMPLICIT PCacheChild::PCacheChild() : |
34 | | mozilla::ipc::IProtocol(mozilla::ipc::ChildSide), |
35 | | mLivenessState(mozilla::ipc::LivenessState::Dead) |
36 | 0 | { |
37 | 0 | MOZ_COUNT_CTOR(PCacheChild); |
38 | 0 | } |
39 | | |
40 | | PCacheChild::~PCacheChild() |
41 | 0 | { |
42 | 0 | MOZ_COUNT_DTOR(PCacheChild); |
43 | 0 | } |
44 | | |
45 | | auto PCacheChild::Manager() const -> PBackgroundChild* |
46 | 0 | { |
47 | 0 | return static_cast<PBackgroundChild*>(IProtocol::Manager()); |
48 | 0 | } |
49 | | |
50 | | auto PCacheChild::ManagedPCacheOpChild(nsTArray<PCacheOpChild*>& aArr) const -> void |
51 | 0 | { |
52 | 0 | (mManagedPCacheOpChild).ToArray(aArr); |
53 | 0 | } |
54 | | |
55 | | auto PCacheChild::ManagedPCacheOpChild() const -> const ManagedContainer<PCacheOpChild>& |
56 | 0 | { |
57 | 0 | return mManagedPCacheOpChild; |
58 | 0 | } |
59 | | |
60 | | auto PCacheChild::SendPCacheOpConstructor(const CacheOpArgs& aOpArgs) -> PCacheOpChild* |
61 | 0 | { |
62 | 0 | return SendPCacheOpConstructor(AllocPCacheOpChild(aOpArgs), aOpArgs); |
63 | 0 | } |
64 | | |
65 | | auto PCacheChild::SendPCacheOpConstructor( |
66 | | PCacheOpChild* actor, |
67 | | const CacheOpArgs& aOpArgs) -> PCacheOpChild* |
68 | 0 | { |
69 | 0 | if ((!(actor))) { |
70 | 0 | NS_WARNING("Error constructing actor PCacheOpChild"); |
71 | 0 | return nullptr; |
72 | 0 | } |
73 | 0 | (actor)->SetManagerAndRegister(this); |
74 | 0 | (mManagedPCacheOpChild).PutEntry(actor); |
75 | 0 | (actor)->mLivenessState = mozilla::ipc::LivenessState::Start; |
76 | 0 |
|
77 | 0 | IPC::Message* msg__ = PCache::Msg_PCacheOpConstructor(Id()); |
78 | 0 |
|
79 | 0 | MOZ_RELEASE_ASSERT(actor, "NULL actor value passed to non-nullable param"); |
80 | 0 | WriteIPDLParam(msg__, this, actor); |
81 | 0 | // Sentinel = 'actor' |
82 | 0 | (msg__)->WriteSentinel(875202478); |
83 | 0 | WriteIPDLParam(msg__, this, aOpArgs); |
84 | 0 | // Sentinel = 'aOpArgs' |
85 | 0 | (msg__)->WriteSentinel(2628124652); |
86 | 0 |
|
87 | 0 |
|
88 | 0 |
|
89 | 0 | if (mozilla::ipc::LoggingEnabledFor("PCacheChild")) { |
90 | 0 | mozilla::ipc::LogMessageForProtocol("PCacheChild", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending); |
91 | 0 | } |
92 | 0 | AUTO_PROFILER_LABEL("PCache::Msg_PCacheOpConstructor", OTHER); |
93 | 0 | if ((!(StateTransition(false, (&(mLivenessState)))))) { |
94 | 0 | mozilla::ipc::LogicError("Transition error"); |
95 | 0 | } |
96 | 0 |
|
97 | 0 | bool sendok__ = (GetIPCChannel())->Send(msg__); |
98 | 0 | if ((!(sendok__))) { |
99 | 0 | FatalError("constructor for actor failed"); |
100 | 0 | return nullptr; |
101 | 0 | } |
102 | 0 | return actor; |
103 | 0 | } |
104 | | |
105 | | auto PCacheChild::SendTeardown() -> bool |
106 | 0 | { |
107 | 0 | IPC::Message* msg__ = PCache::Msg_Teardown(Id()); |
108 | 0 |
|
109 | 0 |
|
110 | 0 |
|
111 | 0 |
|
112 | 0 |
|
113 | 0 | if (mozilla::ipc::LoggingEnabledFor("PCacheChild")) { |
114 | 0 | mozilla::ipc::LogMessageForProtocol("PCacheChild", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending); |
115 | 0 | } |
116 | 0 | AUTO_PROFILER_LABEL("PCache::Msg_Teardown", OTHER); |
117 | 0 | if ((!(StateTransition(false, (&(mLivenessState)))))) { |
118 | 0 | mozilla::ipc::LogicError("Transition error"); |
119 | 0 | } |
120 | 0 |
|
121 | 0 | bool sendok__ = (GetIPCChannel())->Send(msg__); |
122 | 0 | return sendok__; |
123 | 0 | } |
124 | | |
125 | | auto PCacheChild::RemoveManagee( |
126 | | int32_t aProtocolId, |
127 | | IProtocol* aListener) -> void |
128 | 0 | { |
129 | 0 | switch (aProtocolId) { |
130 | 0 | case PCacheOpMsgStart: |
131 | 0 | { |
132 | 0 | PCacheOpChild* actor = static_cast<PCacheOpChild*>(aListener); |
133 | 0 | auto& container = mManagedPCacheOpChild; |
134 | 0 | MOZ_RELEASE_ASSERT((container).Contains(actor), "actor not managed by this!"); |
135 | 0 |
|
136 | 0 | (container).RemoveEntry(actor); |
137 | 0 | DeallocPCacheOpChild(actor); |
138 | 0 | return; |
139 | 0 | } |
140 | 0 | default: |
141 | 0 | { |
142 | 0 | FatalError("unreached"); |
143 | 0 | return; |
144 | 0 | } |
145 | 0 | } |
146 | 0 | } |
147 | | |
148 | | auto PCacheChild::OnMessageReceived(const Message& msg__) -> PCacheChild::Result |
149 | 0 | { |
150 | 0 | switch ((msg__).type()) { |
151 | 0 | case PCache::Reply_PCacheOpConstructor__ID: |
152 | 0 | { |
153 | 0 | return MsgProcessed; |
154 | 0 | } |
155 | 0 | case PCache::Msg___delete____ID: |
156 | 0 | { |
157 | 0 | if (mozilla::ipc::LoggingEnabledFor("PCacheChild")) { |
158 | 0 | mozilla::ipc::LogMessageForProtocol("PCacheChild", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving); |
159 | 0 | } |
160 | 0 | AUTO_PROFILER_LABEL("PCache::Msg___delete__", OTHER); |
161 | 0 |
|
162 | 0 | PickleIterator iter__(msg__); |
163 | 0 | PCacheChild* actor; |
164 | 0 |
|
165 | 0 | if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(actor)))))) { |
166 | 0 | FatalError("Error deserializing 'PCacheChild'"); |
167 | 0 | return MsgValueError; |
168 | 0 | } |
169 | 0 | if ((!((*((&(actor))))))) { |
170 | 0 | FatalError("Error deserializing 'PCacheChild'"); |
171 | 0 | return MsgValueError; |
172 | 0 | } |
173 | 0 | // Sentinel = 'actor' |
174 | 0 | if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 875202478)))) { |
175 | 0 | mozilla::ipc::SentinelReadError("Error deserializing 'PCacheChild'"); |
176 | 0 | return MsgValueError; |
177 | 0 | } |
178 | 0 | (msg__).EndRead(iter__, (msg__).type()); |
179 | 0 | if ((!(StateTransition(true, (&(mLivenessState)))))) { |
180 | 0 | FatalError("Transition error"); |
181 | 0 | return MsgValueError; |
182 | 0 | } |
183 | 0 | if ((!(Recv__delete__()))) { |
184 | 0 | mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); |
185 | 0 | // Error handled in mozilla::ipc::IPCResult |
186 | 0 | return MsgProcessingError; |
187 | 0 | } |
188 | 0 | |
189 | 0 | |
190 | 0 | IProtocol* mgr = (actor)->Manager(); |
191 | 0 | (actor)->DestroySubtree(Deletion); |
192 | 0 | (actor)->DeallocSubtree(); |
193 | 0 | (mgr)->RemoveManagee(PCacheMsgStart, actor); |
194 | 0 |
|
195 | 0 | return MsgProcessed; |
196 | 0 | } |
197 | 0 | default: |
198 | 0 | { |
199 | 0 | return MsgNotKnown; |
200 | 0 | } |
201 | 0 | } |
202 | 0 | } |
203 | | |
204 | | auto PCacheChild::OnMessageReceived( |
205 | | const Message& msg__, |
206 | | Message*& reply__) -> PCacheChild::Result |
207 | 0 | { |
208 | 0 | return MsgNotKnown; |
209 | 0 | } |
210 | | |
211 | | auto PCacheChild::OnCallReceived( |
212 | | const Message& msg__, |
213 | | Message*& reply__) -> PCacheChild::Result |
214 | 0 | { |
215 | 0 | MOZ_ASSERT_UNREACHABLE("message protocol not supported"); |
216 | 0 | return MsgNotKnown; |
217 | 0 | } |
218 | | |
219 | | auto PCacheChild::GetProtocolTypeId() -> int32_t |
220 | 0 | { |
221 | 0 | return PCacheMsgStart; |
222 | 0 | } |
223 | | |
224 | | auto PCacheChild::DestroySubtree(ActorDestroyReason why) -> void |
225 | 0 | { |
226 | 0 | // Unregister from our manager. |
227 | 0 | Unregister(Id()); |
228 | 0 |
|
229 | 0 | ActorDestroyReason subtreewhy = (((why) == (Deletion)) || ((why) == (FailedConstructor)) ? AncestorDeletion : why); |
230 | 0 |
|
231 | 0 | { |
232 | 0 | // Recursively shutting down PCacheOp kids |
233 | 0 | nsTArray<PCacheOpChild*> kids; |
234 | 0 | // Accumulate kids into a stable structure to iterate over |
235 | 0 | ManagedPCacheOpChild(kids); |
236 | 0 | for (auto& kid : kids) { |
237 | 0 | // Guarding against a child removing a sibling from the list during the iteration. |
238 | 0 | if ((mManagedPCacheOpChild).Contains(kid)) { |
239 | 0 | (kid)->DestroySubtree(subtreewhy); |
240 | 0 | } |
241 | 0 | } |
242 | 0 | } |
243 | 0 |
|
244 | 0 | // Reject owning pending responses. |
245 | 0 | (GetIPCChannel())->RejectPendingResponsesForActor(this); |
246 | 0 |
|
247 | 0 | // Finally, destroy "us". |
248 | 0 | ActorDestroy(why); |
249 | 0 | } |
250 | | |
251 | | auto PCacheChild::DeallocSubtree() -> void |
252 | 0 | { |
253 | 0 | { |
254 | 0 | // Recursively deleting PCacheOp kids |
255 | 0 | for (auto iter = (mManagedPCacheOpChild).Iter(); (!((iter).Done())); (iter).Next()) { |
256 | 0 | (((iter).Get())->GetKey())->DeallocSubtree(); |
257 | 0 | } |
258 | 0 |
|
259 | 0 | for (auto iter = (mManagedPCacheOpChild).Iter(); (!((iter).Done())); (iter).Next()) { |
260 | 0 | DeallocPCacheOpChild(((iter).Get())->GetKey()); |
261 | 0 | } |
262 | 0 | (mManagedPCacheOpChild).Clear(); |
263 | 0 | } |
264 | 0 | } |
265 | | |
266 | | |
267 | | |
268 | | } // namespace cache |
269 | | } // namespace dom |
270 | | } // namespace mozilla |
271 | | namespace mozilla { |
272 | | namespace ipc { |
273 | | auto IPDLParamTraits<mozilla::dom::cache::PCacheChild>::Write( |
274 | | IPC::Message* aMsg, |
275 | | mozilla::ipc::IProtocol* aActor, |
276 | | const paramType& aVar) -> void |
277 | 0 | { |
278 | 0 | int32_t id; |
279 | 0 | if ((!(aVar))) { |
280 | 0 | id = 0; |
281 | 0 | } |
282 | 0 | else { |
283 | 0 | id = (aVar)->Id(); |
284 | 0 | if ((1) == (id)) { |
285 | 0 | (aActor)->FatalError("actor has been |delete|d"); |
286 | 0 | } |
287 | 0 | } |
288 | 0 | WriteIPDLParam(aMsg, aActor, id); |
289 | 0 | } |
290 | | |
291 | | auto IPDLParamTraits<mozilla::dom::cache::PCacheChild>::Read( |
292 | | const IPC::Message* aMsg, |
293 | | PickleIterator* aIter, |
294 | | mozilla::ipc::IProtocol* aActor, |
295 | | paramType* aVar) -> bool |
296 | 0 | { |
297 | 0 | mozilla::Maybe<mozilla::ipc::IProtocol*> actor = (aActor)->ReadActor(aMsg, aIter, true, "PCache", PCacheMsgStart); |
298 | 0 | if ((actor).isNothing()) { |
299 | 0 | return false; |
300 | 0 | } |
301 | 0 | |
302 | 0 | (*(aVar)) = static_cast<mozilla::dom::cache::PCacheChild*>((actor).value()); |
303 | 0 | return true; |
304 | 0 | } |
305 | | |
306 | | } // namespace ipc |
307 | | } // namespace mozilla |