/work/obj-fuzz/ipc/ipdl/PCompositorManagerParent.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/layers/PCompositorManagerParent.h" |
8 | | #include "ipc/IPCMessageUtils.h" |
9 | | |
10 | | #include "mozilla/layers/PCompositorBridgeParent.h" |
11 | | |
12 | | #include "nsIFile.h" |
13 | | #include "GeckoProfiler.h" |
14 | | |
15 | | namespace mozilla { |
16 | | namespace layers { |
17 | | |
18 | | |
19 | | auto PCompositorManagerParent::RecvPCompositorBridgeConstructor( |
20 | | PCompositorBridgeParent* actor, |
21 | | const CompositorBridgeOptions& options) -> mozilla::ipc::IPCResult |
22 | 0 | { |
23 | 0 | return IPC_OK(); |
24 | 0 | } |
25 | | |
26 | | auto PCompositorManagerParent::ActorDestroy(ActorDestroyReason aWhy) -> void |
27 | 0 | { |
28 | 0 | } |
29 | | |
30 | | auto PCompositorManagerParent::ProcessingError( |
31 | | Result aCode, |
32 | | const char* aReason) -> void |
33 | 0 | { |
34 | 0 | } |
35 | | |
36 | | auto PCompositorManagerParent::ShouldContinueFromReplyTimeout() -> bool |
37 | 0 | { |
38 | 0 | return true; |
39 | 0 | } |
40 | | |
41 | | auto PCompositorManagerParent::EnteredCxxStack() -> void |
42 | 0 | { |
43 | 0 | } |
44 | | |
45 | | auto PCompositorManagerParent::ExitedCxxStack() -> void |
46 | 0 | { |
47 | 0 | } |
48 | | |
49 | | auto PCompositorManagerParent::EnteredCall() -> void |
50 | 0 | { |
51 | 0 | } |
52 | | |
53 | | auto PCompositorManagerParent::ExitedCall() -> void |
54 | 0 | { |
55 | 0 | } |
56 | | |
57 | | MOZ_IMPLICIT PCompositorManagerParent::PCompositorManagerParent() : |
58 | | mozilla::ipc::IToplevelProtocol("PCompositorManagerParent", PCompositorManagerMsgStart, mozilla::ipc::ParentSide), |
59 | | mLivenessState(mozilla::ipc::LivenessState::Start) |
60 | 0 | { |
61 | 0 | MOZ_COUNT_CTOR(PCompositorManagerParent); |
62 | 0 | } |
63 | | |
64 | | PCompositorManagerParent::~PCompositorManagerParent() |
65 | 0 | { |
66 | 0 | MOZ_COUNT_DTOR(PCompositorManagerParent); |
67 | 0 | } |
68 | | |
69 | | auto PCompositorManagerParent::ManagedPCompositorBridgeParent(nsTArray<PCompositorBridgeParent*>& aArr) const -> void |
70 | 0 | { |
71 | 0 | (mManagedPCompositorBridgeParent).ToArray(aArr); |
72 | 0 | } |
73 | | |
74 | | auto PCompositorManagerParent::ManagedPCompositorBridgeParent() const -> const ManagedContainer<PCompositorBridgeParent>& |
75 | 0 | { |
76 | 0 | return mManagedPCompositorBridgeParent; |
77 | 0 | } |
78 | | |
79 | | auto PCompositorManagerParent::RemoveManagee( |
80 | | int32_t aProtocolId, |
81 | | IProtocol* aListener) -> void |
82 | 0 | { |
83 | 0 | switch (aProtocolId) { |
84 | 0 | case PCompositorBridgeMsgStart: |
85 | 0 | { |
86 | 0 | PCompositorBridgeParent* actor = static_cast<PCompositorBridgeParent*>(aListener); |
87 | 0 | auto& container = mManagedPCompositorBridgeParent; |
88 | 0 | MOZ_RELEASE_ASSERT((container).Contains(actor), "actor not managed by this!"); |
89 | 0 |
|
90 | 0 | (container).RemoveEntry(actor); |
91 | 0 | DeallocPCompositorBridgeParent(actor); |
92 | 0 | return; |
93 | 0 | } |
94 | 0 | default: |
95 | 0 | { |
96 | 0 | FatalError("unreached"); |
97 | 0 | return; |
98 | 0 | } |
99 | 0 | } |
100 | 0 | } |
101 | | |
102 | | auto PCompositorManagerParent::OnMessageReceived(const Message& msg__) -> PCompositorManagerParent::Result |
103 | 0 | { |
104 | 0 | int32_t route__ = (msg__).routing_id(); |
105 | 0 | if ((MSG_ROUTING_CONTROL) != (route__)) { |
106 | 0 | IProtocol* routed__ = Lookup(route__); |
107 | 0 | if ((!(routed__))) { |
108 | 0 | return MsgRouteError; |
109 | 0 | } |
110 | 0 | return (routed__)->OnMessageReceived(msg__); |
111 | 0 | } |
112 | 0 | |
113 | 0 | switch ((msg__).type()) { |
114 | 0 | case PCompositorManager::Msg_PCompositorBridgeConstructor__ID: |
115 | 0 | { |
116 | 0 | if (mozilla::ipc::LoggingEnabledFor("PCompositorManagerParent")) { |
117 | 0 | mozilla::ipc::LogMessageForProtocol("PCompositorManagerParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving); |
118 | 0 | } |
119 | 0 | AUTO_PROFILER_LABEL("PCompositorManager::Msg_PCompositorBridgeConstructor", OTHER); |
120 | 0 |
|
121 | 0 | PickleIterator iter__(msg__); |
122 | 0 | ActorHandle handle__; |
123 | 0 | PCompositorBridgeParent* actor; |
124 | 0 | CompositorBridgeOptions options; |
125 | 0 |
|
126 | 0 | if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(handle__)))))) { |
127 | 0 | FatalError("Error deserializing 'ActorHandle'"); |
128 | 0 | return MsgValueError; |
129 | 0 | } |
130 | 0 | // Sentinel = 'actor' |
131 | 0 | if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 875202478)))) { |
132 | 0 | mozilla::ipc::SentinelReadError("Error deserializing 'ActorHandle'"); |
133 | 0 | return MsgValueError; |
134 | 0 | } |
135 | 0 | if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(options)))))) { |
136 | 0 | FatalError("Error deserializing 'CompositorBridgeOptions'"); |
137 | 0 | return MsgValueError; |
138 | 0 | } |
139 | 0 | // Sentinel = 'options' |
140 | 0 | if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 33222909)))) { |
141 | 0 | mozilla::ipc::SentinelReadError("Error deserializing 'CompositorBridgeOptions'"); |
142 | 0 | return MsgValueError; |
143 | 0 | } |
144 | 0 | (msg__).EndRead(iter__, (msg__).type()); |
145 | 0 | if ((!(StateTransition(false, (&(mLivenessState)))))) { |
146 | 0 | FatalError("Transition error"); |
147 | 0 | return MsgValueError; |
148 | 0 | } |
149 | 0 | actor = AllocPCompositorBridgeParent(options); |
150 | 0 | if ((!(actor))) { |
151 | 0 | NS_WARNING("Error constructing actor PCompositorBridgeParent"); |
152 | 0 | return MsgValueError; |
153 | 0 | } |
154 | 0 | (actor)->SetManagerAndRegister(this, (handle__).mId); |
155 | 0 | (mManagedPCompositorBridgeParent).PutEntry(actor); |
156 | 0 | (actor)->mLivenessState = mozilla::ipc::LivenessState::Start; |
157 | 0 |
|
158 | 0 | if ((!(RecvPCompositorBridgeConstructor(actor, options)))) { |
159 | 0 | mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); |
160 | 0 | // Error handled in mozilla::ipc::IPCResult |
161 | 0 | return MsgProcessingError; |
162 | 0 | } |
163 | 0 | |
164 | 0 | return MsgProcessed; |
165 | 0 | } |
166 | 0 | case PCompositorManager::Msg_AddSharedSurface__ID: |
167 | 0 | { |
168 | 0 | if (mozilla::ipc::LoggingEnabledFor("PCompositorManagerParent")) { |
169 | 0 | mozilla::ipc::LogMessageForProtocol("PCompositorManagerParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving); |
170 | 0 | } |
171 | 0 | AUTO_PROFILER_LABEL("PCompositorManager::Msg_AddSharedSurface", OTHER); |
172 | 0 |
|
173 | 0 | PickleIterator iter__(msg__); |
174 | 0 | ExternalImageId aId; |
175 | 0 | SurfaceDescriptorShared aDesc; |
176 | 0 |
|
177 | 0 | if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(aId)))))) { |
178 | 0 | FatalError("Error deserializing 'ExternalImageId'"); |
179 | 0 | return MsgValueError; |
180 | 0 | } |
181 | 0 | // Sentinel = 'aId' |
182 | 0 | if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 2735041817)))) { |
183 | 0 | mozilla::ipc::SentinelReadError("Error deserializing 'ExternalImageId'"); |
184 | 0 | return MsgValueError; |
185 | 0 | } |
186 | 0 | if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(aDesc)))))) { |
187 | 0 | FatalError("Error deserializing 'SurfaceDescriptorShared'"); |
188 | 0 | return MsgValueError; |
189 | 0 | } |
190 | 0 | // Sentinel = 'aDesc' |
191 | 0 | if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 1882627759)))) { |
192 | 0 | mozilla::ipc::SentinelReadError("Error deserializing 'SurfaceDescriptorShared'"); |
193 | 0 | return MsgValueError; |
194 | 0 | } |
195 | 0 | (msg__).EndRead(iter__, (msg__).type()); |
196 | 0 | if ((!(StateTransition(false, (&(mLivenessState)))))) { |
197 | 0 | FatalError("Transition error"); |
198 | 0 | return MsgValueError; |
199 | 0 | } |
200 | 0 | if ((!(RecvAddSharedSurface(aId, aDesc)))) { |
201 | 0 | mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); |
202 | 0 | // Error handled in mozilla::ipc::IPCResult |
203 | 0 | return MsgProcessingError; |
204 | 0 | } |
205 | 0 | |
206 | 0 | return MsgProcessed; |
207 | 0 | } |
208 | 0 | case PCompositorManager::Msg_RemoveSharedSurface__ID: |
209 | 0 | { |
210 | 0 | if (mozilla::ipc::LoggingEnabledFor("PCompositorManagerParent")) { |
211 | 0 | mozilla::ipc::LogMessageForProtocol("PCompositorManagerParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving); |
212 | 0 | } |
213 | 0 | AUTO_PROFILER_LABEL("PCompositorManager::Msg_RemoveSharedSurface", OTHER); |
214 | 0 |
|
215 | 0 | PickleIterator iter__(msg__); |
216 | 0 | ExternalImageId aId; |
217 | 0 |
|
218 | 0 | if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(aId)))))) { |
219 | 0 | FatalError("Error deserializing 'ExternalImageId'"); |
220 | 0 | return MsgValueError; |
221 | 0 | } |
222 | 0 | // Sentinel = 'aId' |
223 | 0 | if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 2735041817)))) { |
224 | 0 | mozilla::ipc::SentinelReadError("Error deserializing 'ExternalImageId'"); |
225 | 0 | return MsgValueError; |
226 | 0 | } |
227 | 0 | (msg__).EndRead(iter__, (msg__).type()); |
228 | 0 | if ((!(StateTransition(false, (&(mLivenessState)))))) { |
229 | 0 | FatalError("Transition error"); |
230 | 0 | return MsgValueError; |
231 | 0 | } |
232 | 0 | if ((!(RecvRemoveSharedSurface(aId)))) { |
233 | 0 | mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); |
234 | 0 | // Error handled in mozilla::ipc::IPCResult |
235 | 0 | return MsgProcessingError; |
236 | 0 | } |
237 | 0 | |
238 | 0 | return MsgProcessed; |
239 | 0 | } |
240 | 0 | case PCompositorManager::Msg_NotifyMemoryPressure__ID: |
241 | 0 | { |
242 | 0 | if (mozilla::ipc::LoggingEnabledFor("PCompositorManagerParent")) { |
243 | 0 | mozilla::ipc::LogMessageForProtocol("PCompositorManagerParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving); |
244 | 0 | } |
245 | 0 | AUTO_PROFILER_LABEL("PCompositorManager::Msg_NotifyMemoryPressure", OTHER); |
246 | 0 |
|
247 | 0 | if ((!(StateTransition(false, (&(mLivenessState)))))) { |
248 | 0 | FatalError("Transition error"); |
249 | 0 | return MsgValueError; |
250 | 0 | } |
251 | 0 | if ((!(RecvNotifyMemoryPressure()))) { |
252 | 0 | mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); |
253 | 0 | // Error handled in mozilla::ipc::IPCResult |
254 | 0 | return MsgProcessingError; |
255 | 0 | } |
256 | 0 | |
257 | 0 | return MsgProcessed; |
258 | 0 | } |
259 | 0 | case PCompositorManager::Msg_ReportMemory__ID: |
260 | 0 | { |
261 | 0 | if (mozilla::ipc::LoggingEnabledFor("PCompositorManagerParent")) { |
262 | 0 | mozilla::ipc::LogMessageForProtocol("PCompositorManagerParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving); |
263 | 0 | } |
264 | 0 | AUTO_PROFILER_LABEL("PCompositorManager::Msg_ReportMemory", OTHER); |
265 | 0 |
|
266 | 0 | if ((!(StateTransition(false, (&(mLivenessState)))))) { |
267 | 0 | FatalError("Transition error"); |
268 | 0 | return MsgValueError; |
269 | 0 | } |
270 | 0 | int32_t id__ = MSG_ROUTING_CONTROL; |
271 | 0 |
|
272 | 0 | int32_t seqno__ = (msg__).seqno(); |
273 | 0 | WeakPtr<PCompositorManagerParent> self__ = this; |
274 | 0 | ReportMemoryResolver resolver = [this, self__, id__, seqno__](const MemoryReport& aParam) { |
275 | 0 | if ((!(self__))) { |
276 | 0 | NS_WARNING("Not resolving response because actor is dead."); |
277 | 0 | return; |
278 | 0 | } |
279 | 0 | if ((mLivenessState) == (mozilla::ipc::LivenessState::Dead)) { |
280 | 0 | NS_WARNING("Not resolving response because actor is destroyed."); |
281 | 0 | return; |
282 | 0 | } |
283 | 0 | bool resolve__ = true; |
284 | 0 | MemoryReport aReport; |
285 | 0 | aReport = std::move(aParam); |
286 | 0 | IPC::Message* reply__ = PCompositorManager::Reply_ReportMemory(id__); |
287 | 0 | WriteIPDLParam(reply__, self__, resolve__); |
288 | 0 | // Sentinel = 'resolve__' |
289 | 0 | (reply__)->WriteSentinel(3997392463); |
290 | 0 | WriteIPDLParam(reply__, self__, aReport); |
291 | 0 | // Sentinel = 'aReport' |
292 | 0 | (reply__)->WriteSentinel(3792799576); |
293 | 0 | (reply__)->set_seqno(seqno__); |
294 | 0 |
|
295 | 0 | if (mozilla::ipc::LoggingEnabledFor("PCompositorManagerParent")) { |
296 | 0 | mozilla::ipc::LogMessageForProtocol("PCompositorManagerParent", OtherPid(), "Sending reply ", (reply__)->type(), mozilla::ipc::MessageDirection::eSending); |
297 | 0 | } |
298 | 0 | bool sendok__ = (GetIPCChannel())->Send(reply__); |
299 | 0 | if ((!(sendok__))) { |
300 | 0 | NS_WARNING("Error sending reply"); |
301 | 0 | } |
302 | 0 | }; |
303 | 0 | if ((!(RecvReportMemory(std::move(resolver))))) { |
304 | 0 | mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!"); |
305 | 0 | // Error handled in mozilla::ipc::IPCResult |
306 | 0 | return MsgProcessingError; |
307 | 0 | } |
308 | 0 | |
309 | 0 | return MsgProcessed; |
310 | 0 | } |
311 | 0 | default: |
312 | 0 | { |
313 | 0 | return MsgNotKnown; |
314 | 0 | } |
315 | 0 | case SHMEM_CREATED_MESSAGE_TYPE: |
316 | 0 | { |
317 | 0 | if ((!(ShmemCreated(msg__)))) { |
318 | 0 | return MsgPayloadError; |
319 | 0 | } |
320 | 0 | return MsgProcessed; |
321 | 0 | } |
322 | 0 | case SHMEM_DESTROYED_MESSAGE_TYPE: |
323 | 0 | { |
324 | 0 | if ((!(ShmemDestroyed(msg__)))) { |
325 | 0 | return MsgPayloadError; |
326 | 0 | } |
327 | 0 | return MsgProcessed; |
328 | 0 | } |
329 | 0 | } |
330 | 0 | } |
331 | | |
332 | | auto PCompositorManagerParent::OnMessageReceived( |
333 | | const Message& msg__, |
334 | | Message*& reply__) -> PCompositorManagerParent::Result |
335 | 0 | { |
336 | 0 | int32_t route__ = (msg__).routing_id(); |
337 | 0 | if ((MSG_ROUTING_CONTROL) != (route__)) { |
338 | 0 | IProtocol* routed__ = Lookup(route__); |
339 | 0 | if ((!(routed__))) { |
340 | 0 | return MsgRouteError; |
341 | 0 | } |
342 | 0 | return (routed__)->OnMessageReceived(msg__, reply__); |
343 | 0 | } |
344 | 0 | |
345 | 0 | return MsgNotKnown; |
346 | 0 | } |
347 | | |
348 | | auto PCompositorManagerParent::OnCallReceived( |
349 | | const Message& msg__, |
350 | | Message*& reply__) -> PCompositorManagerParent::Result |
351 | 0 | { |
352 | 0 | MOZ_ASSERT_UNREACHABLE("message protocol not supported"); |
353 | 0 | return MsgNotKnown; |
354 | 0 | } |
355 | | |
356 | | auto PCompositorManagerParent::GetProtocolTypeId() -> int32_t |
357 | 0 | { |
358 | 0 | return PCompositorManagerMsgStart; |
359 | 0 | } |
360 | | |
361 | | auto PCompositorManagerParent::OnChannelClose() -> void |
362 | 0 | { |
363 | 0 | DestroySubtree(NormalShutdown); |
364 | 0 | DeallocSubtree(); |
365 | 0 | DeallocShmems(); |
366 | 0 | DeallocPCompositorManagerParent(); |
367 | 0 | } |
368 | | |
369 | | auto PCompositorManagerParent::OnChannelError() -> void |
370 | 0 | { |
371 | 0 | DestroySubtree(AbnormalShutdown); |
372 | 0 | DeallocSubtree(); |
373 | 0 | DeallocShmems(); |
374 | 0 | DeallocPCompositorManagerParent(); |
375 | 0 | } |
376 | | |
377 | | auto PCompositorManagerParent::DestroySubtree(ActorDestroyReason why) -> void |
378 | 0 | { |
379 | 0 | ActorDestroyReason subtreewhy = (((why) == (Deletion)) || ((why) == (FailedConstructor)) ? AncestorDeletion : why); |
380 | 0 |
|
381 | 0 | { |
382 | 0 | // Recursively shutting down PCompositorBridge kids |
383 | 0 | nsTArray<PCompositorBridgeParent*> kids; |
384 | 0 | // Accumulate kids into a stable structure to iterate over |
385 | 0 | ManagedPCompositorBridgeParent(kids); |
386 | 0 | for (auto& kid : kids) { |
387 | 0 | // Guarding against a child removing a sibling from the list during the iteration. |
388 | 0 | if ((mManagedPCompositorBridgeParent).Contains(kid)) { |
389 | 0 | (kid)->DestroySubtree(subtreewhy); |
390 | 0 | } |
391 | 0 | } |
392 | 0 | } |
393 | 0 |
|
394 | 0 | // Reject owning pending responses. |
395 | 0 | (GetIPCChannel())->RejectPendingResponsesForActor(this); |
396 | 0 |
|
397 | 0 | // Finally, destroy "us". |
398 | 0 | ActorDestroy(why); |
399 | 0 | } |
400 | | |
401 | | auto PCompositorManagerParent::DeallocSubtree() -> void |
402 | 0 | { |
403 | 0 | { |
404 | 0 | // Recursively deleting PCompositorBridge kids |
405 | 0 | for (auto iter = (mManagedPCompositorBridgeParent).Iter(); (!((iter).Done())); (iter).Next()) { |
406 | 0 | (((iter).Get())->GetKey())->DeallocSubtree(); |
407 | 0 | } |
408 | 0 |
|
409 | 0 | for (auto iter = (mManagedPCompositorBridgeParent).Iter(); (!((iter).Done())); (iter).Next()) { |
410 | 0 | DeallocPCompositorBridgeParent(((iter).Get())->GetKey()); |
411 | 0 | } |
412 | 0 | (mManagedPCompositorBridgeParent).Clear(); |
413 | 0 | } |
414 | 0 | } |
415 | | |
416 | | auto PCompositorManagerParent::DeallocPCompositorManagerParent() -> void |
417 | 0 | { |
418 | 0 | } |
419 | | |
420 | | |
421 | | |
422 | | } // namespace layers |
423 | | } // namespace mozilla |
424 | | namespace mozilla { |
425 | | namespace ipc { |
426 | | auto IPDLParamTraits<mozilla::layers::PCompositorManagerParent>::Write( |
427 | | IPC::Message* aMsg, |
428 | | mozilla::ipc::IProtocol* aActor, |
429 | | const paramType& aVar) -> void |
430 | 0 | { |
431 | 0 | int32_t id; |
432 | 0 | if ((!(aVar))) { |
433 | 0 | id = 0; |
434 | 0 | } |
435 | 0 | else { |
436 | 0 | id = (aVar)->Id(); |
437 | 0 | if ((1) == (id)) { |
438 | 0 | (aActor)->FatalError("actor has been |delete|d"); |
439 | 0 | } |
440 | 0 | } |
441 | 0 | WriteIPDLParam(aMsg, aActor, id); |
442 | 0 | } |
443 | | |
444 | | auto IPDLParamTraits<mozilla::layers::PCompositorManagerParent>::Read( |
445 | | const IPC::Message* aMsg, |
446 | | PickleIterator* aIter, |
447 | | mozilla::ipc::IProtocol* aActor, |
448 | | paramType* aVar) -> bool |
449 | 0 | { |
450 | 0 | mozilla::Maybe<mozilla::ipc::IProtocol*> actor = (aActor)->ReadActor(aMsg, aIter, true, "PCompositorManager", PCompositorManagerMsgStart); |
451 | 0 | if ((actor).isNothing()) { |
452 | 0 | return false; |
453 | 0 | } |
454 | 0 | |
455 | 0 | (*(aVar)) = static_cast<mozilla::layers::PCompositorManagerParent*>((actor).value()); |
456 | 0 | return true; |
457 | 0 | } |
458 | | |
459 | | } // namespace ipc |
460 | | } // namespace mozilla |