Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/ipc/ipdl/PGMPContentChild.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/gmp/PGMPContentChild.h"
8
9
#include "mozilla/gmp/PGMPVideoDecoderChild.h"
10
#include "mozilla/gmp/PGMPVideoEncoderChild.h"
11
#include "mozilla/gmp/PChromiumCDMChild.h"
12
13
#include "nsIFile.h"
14
#include "GeckoProfiler.h"
15
16
namespace mozilla {
17
namespace gmp {
18
19
20
auto PGMPContentChild::RecvPGMPVideoDecoderConstructor(
21
        PGMPVideoDecoderChild* actor,
22
        const uint32_t& aDecryptorId) -> mozilla::ipc::IPCResult
23
0
{
24
0
    return IPC_OK();
25
0
}
26
27
auto PGMPContentChild::RecvPGMPVideoEncoderConstructor(PGMPVideoEncoderChild* actor) -> mozilla::ipc::IPCResult
28
0
{
29
0
    return IPC_OK();
30
0
}
31
32
auto PGMPContentChild::RecvPChromiumCDMConstructor(PChromiumCDMChild* actor) -> mozilla::ipc::IPCResult
33
0
{
34
0
    return IPC_OK();
35
0
}
36
37
auto PGMPContentChild::ActorDestroy(ActorDestroyReason aWhy) -> void
38
0
{
39
0
}
40
41
auto PGMPContentChild::ProcessingError(
42
        Result aCode,
43
        const char* aReason) -> void
44
0
{
45
0
}
46
47
auto PGMPContentChild::ShouldContinueFromReplyTimeout() -> bool
48
0
{
49
0
    return true;
50
0
}
51
52
auto PGMPContentChild::EnteredCxxStack() -> void
53
0
{
54
0
}
55
56
auto PGMPContentChild::ExitedCxxStack() -> void
57
0
{
58
0
}
59
60
auto PGMPContentChild::EnteredCall() -> void
61
0
{
62
0
}
63
64
auto PGMPContentChild::ExitedCall() -> void
65
0
{
66
0
}
67
68
MOZ_IMPLICIT PGMPContentChild::PGMPContentChild() :
69
    mozilla::ipc::IToplevelProtocol("PGMPContentChild", PGMPContentMsgStart, mozilla::ipc::ChildSide),
70
    mLivenessState(mozilla::ipc::LivenessState::Start)
71
0
{
72
0
    MOZ_COUNT_CTOR(PGMPContentChild);
73
0
}
74
75
PGMPContentChild::~PGMPContentChild()
76
0
{
77
0
    MOZ_COUNT_DTOR(PGMPContentChild);
78
0
}
79
80
auto PGMPContentChild::ManagedPGMPVideoDecoderChild(nsTArray<PGMPVideoDecoderChild*>& aArr) const -> void
81
0
{
82
0
    (mManagedPGMPVideoDecoderChild).ToArray(aArr);
83
0
}
84
85
auto PGMPContentChild::ManagedPGMPVideoDecoderChild() const -> const ManagedContainer<PGMPVideoDecoderChild>&
86
0
{
87
0
    return mManagedPGMPVideoDecoderChild;
88
0
}
89
90
auto PGMPContentChild::ManagedPGMPVideoEncoderChild(nsTArray<PGMPVideoEncoderChild*>& aArr) const -> void
91
0
{
92
0
    (mManagedPGMPVideoEncoderChild).ToArray(aArr);
93
0
}
94
95
auto PGMPContentChild::ManagedPGMPVideoEncoderChild() const -> const ManagedContainer<PGMPVideoEncoderChild>&
96
0
{
97
0
    return mManagedPGMPVideoEncoderChild;
98
0
}
99
100
auto PGMPContentChild::ManagedPChromiumCDMChild(nsTArray<PChromiumCDMChild*>& aArr) const -> void
101
0
{
102
0
    (mManagedPChromiumCDMChild).ToArray(aArr);
103
0
}
104
105
auto PGMPContentChild::ManagedPChromiumCDMChild() const -> const ManagedContainer<PChromiumCDMChild>&
106
0
{
107
0
    return mManagedPChromiumCDMChild;
108
0
}
109
110
auto PGMPContentChild::RemoveManagee(
111
        int32_t aProtocolId,
112
        IProtocol* aListener) -> void
113
0
{
114
0
    switch (aProtocolId) {
115
0
    case PGMPVideoDecoderMsgStart:
116
0
        {
117
0
            PGMPVideoDecoderChild* actor = static_cast<PGMPVideoDecoderChild*>(aListener);
118
0
            auto& container = mManagedPGMPVideoDecoderChild;
119
0
            MOZ_RELEASE_ASSERT((container).Contains(actor), "actor not managed by this!");
120
0
121
0
            (container).RemoveEntry(actor);
122
0
            DeallocPGMPVideoDecoderChild(actor);
123
0
            return;
124
0
        }
125
0
    case PGMPVideoEncoderMsgStart:
126
0
        {
127
0
            PGMPVideoEncoderChild* actor = static_cast<PGMPVideoEncoderChild*>(aListener);
128
0
            auto& container = mManagedPGMPVideoEncoderChild;
129
0
            MOZ_RELEASE_ASSERT((container).Contains(actor), "actor not managed by this!");
130
0
131
0
            (container).RemoveEntry(actor);
132
0
            DeallocPGMPVideoEncoderChild(actor);
133
0
            return;
134
0
        }
135
0
    case PChromiumCDMMsgStart:
136
0
        {
137
0
            PChromiumCDMChild* actor = static_cast<PChromiumCDMChild*>(aListener);
138
0
            auto& container = mManagedPChromiumCDMChild;
139
0
            MOZ_RELEASE_ASSERT((container).Contains(actor), "actor not managed by this!");
140
0
141
0
            (container).RemoveEntry(actor);
142
0
            DeallocPChromiumCDMChild(actor);
143
0
            return;
144
0
        }
145
0
    default:
146
0
        {
147
0
            FatalError("unreached");
148
0
            return;
149
0
        }
150
0
    }
151
0
}
152
153
auto PGMPContentChild::OnMessageReceived(const Message& msg__) -> PGMPContentChild::Result
154
0
{
155
0
    int32_t route__ = (msg__).routing_id();
156
0
    if ((MSG_ROUTING_CONTROL) != (route__)) {
157
0
        IProtocol* routed__ = Lookup(route__);
158
0
        if ((!(routed__))) {
159
0
            return MsgRouteError;
160
0
        }
161
0
        return (routed__)->OnMessageReceived(msg__);
162
0
    }
163
0
164
0
    switch ((msg__).type()) {
165
0
    case PGMPContent::Msg_PGMPVideoDecoderConstructor__ID:
166
0
        {
167
0
            if (mozilla::ipc::LoggingEnabledFor("PGMPContentChild")) {
168
0
                mozilla::ipc::LogMessageForProtocol("PGMPContentChild", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
169
0
            }
170
0
            AUTO_PROFILER_LABEL("PGMPContent::Msg_PGMPVideoDecoderConstructor", OTHER);
171
0
172
0
            PickleIterator iter__(msg__);
173
0
            ActorHandle handle__;
174
0
            PGMPVideoDecoderChild* actor;
175
0
            uint32_t aDecryptorId;
176
0
177
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(handle__)))))) {
178
0
                FatalError("Error deserializing 'ActorHandle'");
179
0
                return MsgValueError;
180
0
            }
181
0
            // Sentinel = 'actor'
182
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 875202478)))) {
183
0
                mozilla::ipc::SentinelReadError("Error deserializing 'ActorHandle'");
184
0
                return MsgValueError;
185
0
            }
186
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(aDecryptorId)))))) {
187
0
                FatalError("Error deserializing 'uint32_t'");
188
0
                return MsgValueError;
189
0
            }
190
0
            // Sentinel = 'aDecryptorId'
191
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 2779641256)))) {
192
0
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
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
            actor = AllocPGMPVideoDecoderChild(aDecryptorId);
201
0
            if ((!(actor))) {
202
0
                NS_WARNING("Error constructing actor PGMPVideoDecoderChild");
203
0
                return MsgValueError;
204
0
            }
205
0
            (actor)->SetManagerAndRegister(this, (handle__).mId);
206
0
            (mManagedPGMPVideoDecoderChild).PutEntry(actor);
207
0
            (actor)->mLivenessState = mozilla::ipc::LivenessState::Start;
208
0
209
0
            if ((!(RecvPGMPVideoDecoderConstructor(actor, aDecryptorId)))) {
210
0
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
211
0
                // Error handled in mozilla::ipc::IPCResult
212
0
                return MsgProcessingError;
213
0
            }
214
0
215
0
            return MsgProcessed;
216
0
        }
217
0
    case PGMPContent::Msg_PGMPVideoEncoderConstructor__ID:
218
0
        {
219
0
            if (mozilla::ipc::LoggingEnabledFor("PGMPContentChild")) {
220
0
                mozilla::ipc::LogMessageForProtocol("PGMPContentChild", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
221
0
            }
222
0
            AUTO_PROFILER_LABEL("PGMPContent::Msg_PGMPVideoEncoderConstructor", OTHER);
223
0
224
0
            PickleIterator iter__(msg__);
225
0
            ActorHandle handle__;
226
0
            PGMPVideoEncoderChild* actor;
227
0
228
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(handle__)))))) {
229
0
                FatalError("Error deserializing 'ActorHandle'");
230
0
                return MsgValueError;
231
0
            }
232
0
            // Sentinel = 'actor'
233
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 875202478)))) {
234
0
                mozilla::ipc::SentinelReadError("Error deserializing 'ActorHandle'");
235
0
                return MsgValueError;
236
0
            }
237
0
            (msg__).EndRead(iter__, (msg__).type());
238
0
            if ((!(StateTransition(false, (&(mLivenessState)))))) {
239
0
                FatalError("Transition error");
240
0
                return MsgValueError;
241
0
            }
242
0
            actor = AllocPGMPVideoEncoderChild();
243
0
            if ((!(actor))) {
244
0
                NS_WARNING("Error constructing actor PGMPVideoEncoderChild");
245
0
                return MsgValueError;
246
0
            }
247
0
            (actor)->SetManagerAndRegister(this, (handle__).mId);
248
0
            (mManagedPGMPVideoEncoderChild).PutEntry(actor);
249
0
            (actor)->mLivenessState = mozilla::ipc::LivenessState::Start;
250
0
251
0
            if ((!(RecvPGMPVideoEncoderConstructor(actor)))) {
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 PGMPContent::Msg_PChromiumCDMConstructor__ID:
260
0
        {
261
0
            if (mozilla::ipc::LoggingEnabledFor("PGMPContentChild")) {
262
0
                mozilla::ipc::LogMessageForProtocol("PGMPContentChild", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
263
0
            }
264
0
            AUTO_PROFILER_LABEL("PGMPContent::Msg_PChromiumCDMConstructor", OTHER);
265
0
266
0
            PickleIterator iter__(msg__);
267
0
            ActorHandle handle__;
268
0
            PChromiumCDMChild* actor;
269
0
270
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(handle__)))))) {
271
0
                FatalError("Error deserializing 'ActorHandle'");
272
0
                return MsgValueError;
273
0
            }
274
0
            // Sentinel = 'actor'
275
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 875202478)))) {
276
0
                mozilla::ipc::SentinelReadError("Error deserializing 'ActorHandle'");
277
0
                return MsgValueError;
278
0
            }
279
0
            (msg__).EndRead(iter__, (msg__).type());
280
0
            if ((!(StateTransition(false, (&(mLivenessState)))))) {
281
0
                FatalError("Transition error");
282
0
                return MsgValueError;
283
0
            }
284
0
            actor = AllocPChromiumCDMChild();
285
0
            if ((!(actor))) {
286
0
                NS_WARNING("Error constructing actor PChromiumCDMChild");
287
0
                return MsgValueError;
288
0
            }
289
0
            (actor)->SetManagerAndRegister(this, (handle__).mId);
290
0
            (mManagedPChromiumCDMChild).PutEntry(actor);
291
0
            (actor)->mLivenessState = mozilla::ipc::LivenessState::Start;
292
0
293
0
            if ((!(RecvPChromiumCDMConstructor(actor)))) {
294
0
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
295
0
                // Error handled in mozilla::ipc::IPCResult
296
0
                return MsgProcessingError;
297
0
            }
298
0
299
0
            return MsgProcessed;
300
0
        }
301
0
    default:
302
0
        {
303
0
            return MsgNotKnown;
304
0
        }
305
0
    case SHMEM_CREATED_MESSAGE_TYPE:
306
0
        {
307
0
            if ((!(ShmemCreated(msg__)))) {
308
0
                return MsgPayloadError;
309
0
            }
310
0
            return MsgProcessed;
311
0
        }
312
0
    case SHMEM_DESTROYED_MESSAGE_TYPE:
313
0
        {
314
0
            if ((!(ShmemDestroyed(msg__)))) {
315
0
                return MsgPayloadError;
316
0
            }
317
0
            return MsgProcessed;
318
0
        }
319
0
    }
320
0
}
321
322
auto PGMPContentChild::OnMessageReceived(
323
        const Message& msg__,
324
        Message*& reply__) -> PGMPContentChild::Result
325
0
{
326
0
    int32_t route__ = (msg__).routing_id();
327
0
    if ((MSG_ROUTING_CONTROL) != (route__)) {
328
0
        IProtocol* routed__ = Lookup(route__);
329
0
        if ((!(routed__))) {
330
0
            return MsgRouteError;
331
0
        }
332
0
        return (routed__)->OnMessageReceived(msg__, reply__);
333
0
    }
334
0
335
0
    return MsgNotKnown;
336
0
}
337
338
auto PGMPContentChild::OnCallReceived(
339
        const Message& msg__,
340
        Message*& reply__) -> PGMPContentChild::Result
341
0
{
342
0
    int32_t route__ = (msg__).routing_id();
343
0
    if ((MSG_ROUTING_CONTROL) != (route__)) {
344
0
        IProtocol* routed__ = Lookup(route__);
345
0
        if ((!(routed__))) {
346
0
            return MsgRouteError;
347
0
        }
348
0
        return (routed__)->OnCallReceived(msg__, reply__);
349
0
    }
350
0
351
0
    return MsgNotKnown;
352
0
}
353
354
auto PGMPContentChild::GetProtocolTypeId() -> int32_t
355
0
{
356
0
    return PGMPContentMsgStart;
357
0
}
358
359
auto PGMPContentChild::OnChannelClose() -> void
360
0
{
361
0
    DestroySubtree(NormalShutdown);
362
0
    DeallocSubtree();
363
0
    DeallocShmems();
364
0
    DeallocPGMPContentChild();
365
0
}
366
367
auto PGMPContentChild::OnChannelError() -> void
368
0
{
369
0
    DestroySubtree(AbnormalShutdown);
370
0
    DeallocSubtree();
371
0
    DeallocShmems();
372
0
    DeallocPGMPContentChild();
373
0
}
374
375
auto PGMPContentChild::ProcessNativeEventsInInterruptCall() -> void
376
0
{
377
#ifdef OS_WIN
378
    ((DowncastState())->GetIPCChannel())->ProcessNativeEventsInInterruptCall();
379
#else
380
    FatalError("This method is Windows-only");
381
0
#endif
382
0
}
383
384
auto PGMPContentChild::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 PGMPVideoDecoder kids
390
0
        nsTArray<PGMPVideoDecoderChild*> kids;
391
0
        // Accumulate kids into a stable structure to iterate over
392
0
        ManagedPGMPVideoDecoderChild(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 ((mManagedPGMPVideoDecoderChild).Contains(kid)) {
396
0
                (kid)->DestroySubtree(subtreewhy);
397
0
            }
398
0
        }
399
0
    }
400
0
    {
401
0
        // Recursively shutting down PGMPVideoEncoder kids
402
0
        nsTArray<PGMPVideoEncoderChild*> kids;
403
0
        // Accumulate kids into a stable structure to iterate over
404
0
        ManagedPGMPVideoEncoderChild(kids);
405
0
        for (auto& kid : kids) {
406
0
            // Guarding against a child removing a sibling from the list during the iteration.
407
0
            if ((mManagedPGMPVideoEncoderChild).Contains(kid)) {
408
0
                (kid)->DestroySubtree(subtreewhy);
409
0
            }
410
0
        }
411
0
    }
412
0
    {
413
0
        // Recursively shutting down PChromiumCDM kids
414
0
        nsTArray<PChromiumCDMChild*> kids;
415
0
        // Accumulate kids into a stable structure to iterate over
416
0
        ManagedPChromiumCDMChild(kids);
417
0
        for (auto& kid : kids) {
418
0
            // Guarding against a child removing a sibling from the list during the iteration.
419
0
            if ((mManagedPChromiumCDMChild).Contains(kid)) {
420
0
                (kid)->DestroySubtree(subtreewhy);
421
0
            }
422
0
        }
423
0
    }
424
0
425
0
    // Reject owning pending responses.
426
0
    (GetIPCChannel())->RejectPendingResponsesForActor(this);
427
0
428
0
    // Finally, destroy "us".
429
0
    ActorDestroy(why);
430
0
}
431
432
auto PGMPContentChild::DeallocSubtree() -> void
433
0
{
434
0
    {
435
0
        // Recursively deleting PGMPVideoDecoder kids
436
0
        for (auto iter = (mManagedPGMPVideoDecoderChild).Iter(); (!((iter).Done())); (iter).Next()) {
437
0
            (((iter).Get())->GetKey())->DeallocSubtree();
438
0
        }
439
0
440
0
        for (auto iter = (mManagedPGMPVideoDecoderChild).Iter(); (!((iter).Done())); (iter).Next()) {
441
0
            DeallocPGMPVideoDecoderChild(((iter).Get())->GetKey());
442
0
        }
443
0
        (mManagedPGMPVideoDecoderChild).Clear();
444
0
    }
445
0
    {
446
0
        // Recursively deleting PGMPVideoEncoder kids
447
0
        for (auto iter = (mManagedPGMPVideoEncoderChild).Iter(); (!((iter).Done())); (iter).Next()) {
448
0
            (((iter).Get())->GetKey())->DeallocSubtree();
449
0
        }
450
0
451
0
        for (auto iter = (mManagedPGMPVideoEncoderChild).Iter(); (!((iter).Done())); (iter).Next()) {
452
0
            DeallocPGMPVideoEncoderChild(((iter).Get())->GetKey());
453
0
        }
454
0
        (mManagedPGMPVideoEncoderChild).Clear();
455
0
    }
456
0
    {
457
0
        // Recursively deleting PChromiumCDM kids
458
0
        for (auto iter = (mManagedPChromiumCDMChild).Iter(); (!((iter).Done())); (iter).Next()) {
459
0
            (((iter).Get())->GetKey())->DeallocSubtree();
460
0
        }
461
0
462
0
        for (auto iter = (mManagedPChromiumCDMChild).Iter(); (!((iter).Done())); (iter).Next()) {
463
0
            DeallocPChromiumCDMChild(((iter).Get())->GetKey());
464
0
        }
465
0
        (mManagedPChromiumCDMChild).Clear();
466
0
    }
467
0
}
468
469
auto PGMPContentChild::DeallocPGMPContentChild() -> void
470
0
{
471
0
}
472
473
474
475
} // namespace gmp
476
} // namespace mozilla
477
namespace mozilla {
478
namespace ipc {
479
auto IPDLParamTraits<mozilla::gmp::PGMPContentChild>::Write(
480
        IPC::Message* aMsg,
481
        mozilla::ipc::IProtocol* aActor,
482
        const paramType& aVar) -> void
483
0
{
484
0
    int32_t id;
485
0
    if ((!(aVar))) {
486
0
        id = 0;
487
0
    }
488
0
    else {
489
0
        id = (aVar)->Id();
490
0
        if ((1) == (id)) {
491
0
            (aActor)->FatalError("actor has been |delete|d");
492
0
        }
493
0
    }
494
0
    WriteIPDLParam(aMsg, aActor, id);
495
0
}
496
497
auto IPDLParamTraits<mozilla::gmp::PGMPContentChild>::Read(
498
        const IPC::Message* aMsg,
499
        PickleIterator* aIter,
500
        mozilla::ipc::IProtocol* aActor,
501
        paramType* aVar) -> bool
502
0
{
503
0
    mozilla::Maybe<mozilla::ipc::IProtocol*> actor = (aActor)->ReadActor(aMsg, aIter, true, "PGMPContent", PGMPContentMsgStart);
504
0
    if ((actor).isNothing()) {
505
0
        return false;
506
0
    }
507
0
508
0
    (*(aVar)) = static_cast<mozilla::gmp::PGMPContentChild*>((actor).value());
509
0
    return true;
510
0
}
511
512
} // namespace ipc
513
} // namespace mozilla