Coverage Report

Created: 2018-09-25 14:53

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