Coverage Report

Created: 2018-09-25 14:53

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