Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/ipc/ipdl/PVideoBridgeParent.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/PVideoBridgeParent.h"
8
9
#include "mozilla/layers/PTextureParent.h"
10
11
#include "nsIFile.h"
12
#include "GeckoProfiler.h"
13
14
namespace mozilla {
15
namespace layers {
16
17
18
auto PVideoBridgeParent::RecvPTextureConstructor(
19
        PTextureParent* actor,
20
        const SurfaceDescriptor& aSharedData,
21
        const ReadLockDescriptor& aReadLock,
22
        const LayersBackend& aBackend,
23
        const TextureFlags& aTextureFlags,
24
        const uint64_t& aSerial) -> mozilla::ipc::IPCResult
25
0
{
26
0
    return IPC_OK();
27
0
}
28
29
auto PVideoBridgeParent::ActorDestroy(ActorDestroyReason aWhy) -> void
30
0
{
31
0
}
32
33
auto PVideoBridgeParent::ProcessingError(
34
        Result aCode,
35
        const char* aReason) -> void
36
0
{
37
0
}
38
39
auto PVideoBridgeParent::ShouldContinueFromReplyTimeout() -> bool
40
0
{
41
0
    return true;
42
0
}
43
44
auto PVideoBridgeParent::EnteredCxxStack() -> void
45
0
{
46
0
}
47
48
auto PVideoBridgeParent::ExitedCxxStack() -> void
49
0
{
50
0
}
51
52
auto PVideoBridgeParent::EnteredCall() -> void
53
0
{
54
0
}
55
56
auto PVideoBridgeParent::ExitedCall() -> void
57
0
{
58
0
}
59
60
MOZ_IMPLICIT PVideoBridgeParent::PVideoBridgeParent() :
61
    mozilla::ipc::IToplevelProtocol("PVideoBridgeParent", PVideoBridgeMsgStart, mozilla::ipc::ParentSide),
62
    mLivenessState(mozilla::ipc::LivenessState::Start)
63
0
{
64
0
    MOZ_COUNT_CTOR(PVideoBridgeParent);
65
0
}
66
67
PVideoBridgeParent::~PVideoBridgeParent()
68
0
{
69
0
    MOZ_COUNT_DTOR(PVideoBridgeParent);
70
0
}
71
72
auto PVideoBridgeParent::ManagedPTextureParent(nsTArray<PTextureParent*>& aArr) const -> void
73
0
{
74
0
    (mManagedPTextureParent).ToArray(aArr);
75
0
}
76
77
auto PVideoBridgeParent::ManagedPTextureParent() const -> const ManagedContainer<PTextureParent>&
78
0
{
79
0
    return mManagedPTextureParent;
80
0
}
81
82
auto PVideoBridgeParent::RemoveManagee(
83
        int32_t aProtocolId,
84
        IProtocol* aListener) -> void
85
0
{
86
0
    switch (aProtocolId) {
87
0
    case PTextureMsgStart:
88
0
        {
89
0
            PTextureParent* actor = static_cast<PTextureParent*>(aListener);
90
0
            auto& container = mManagedPTextureParent;
91
0
            MOZ_RELEASE_ASSERT((container).Contains(actor), "actor not managed by this!");
92
0
93
0
            (container).RemoveEntry(actor);
94
0
            DeallocPTextureParent(actor);
95
0
            return;
96
0
        }
97
0
    default:
98
0
        {
99
0
            FatalError("unreached");
100
0
            return;
101
0
        }
102
0
    }
103
0
}
104
105
auto PVideoBridgeParent::OnMessageReceived(const Message& msg__) -> PVideoBridgeParent::Result
106
0
{
107
0
    int32_t route__ = (msg__).routing_id();
108
0
    if ((MSG_ROUTING_CONTROL) != (route__)) {
109
0
        IProtocol* routed__ = Lookup(route__);
110
0
        if ((!(routed__))) {
111
0
            return MsgRouteError;
112
0
        }
113
0
        return (routed__)->OnMessageReceived(msg__);
114
0
    }
115
0
116
0
    switch ((msg__).type()) {
117
0
    case PVideoBridge::Msg_PTextureConstructor__ID:
118
0
        {
119
0
            if (mozilla::ipc::LoggingEnabledFor("PVideoBridgeParent")) {
120
0
                mozilla::ipc::LogMessageForProtocol("PVideoBridgeParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
121
0
            }
122
0
            AUTO_PROFILER_LABEL("PVideoBridge::Msg_PTextureConstructor", OTHER);
123
0
124
0
            PickleIterator iter__(msg__);
125
0
            ActorHandle handle__;
126
0
            PTextureParent* actor;
127
0
            SurfaceDescriptor aSharedData;
128
0
            ReadLockDescriptor aReadLock;
129
0
            LayersBackend aBackend;
130
0
            TextureFlags aTextureFlags;
131
0
            uint64_t aSerial;
132
0
133
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(handle__)))))) {
134
0
                FatalError("Error deserializing 'ActorHandle'");
135
0
                return MsgValueError;
136
0
            }
137
0
            // Sentinel = 'actor'
138
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 875202478)))) {
139
0
                mozilla::ipc::SentinelReadError("Error deserializing 'ActorHandle'");
140
0
                return MsgValueError;
141
0
            }
142
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(aSharedData)))))) {
143
0
                FatalError("Error deserializing 'SurfaceDescriptor'");
144
0
                return MsgValueError;
145
0
            }
146
0
            // Sentinel = 'aSharedData'
147
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 3013593029)))) {
148
0
                mozilla::ipc::SentinelReadError("Error deserializing 'SurfaceDescriptor'");
149
0
                return MsgValueError;
150
0
            }
151
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(aReadLock)))))) {
152
0
                FatalError("Error deserializing 'ReadLockDescriptor'");
153
0
                return MsgValueError;
154
0
            }
155
0
            // Sentinel = 'aReadLock'
156
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 1208527801)))) {
157
0
                mozilla::ipc::SentinelReadError("Error deserializing 'ReadLockDescriptor'");
158
0
                return MsgValueError;
159
0
            }
160
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(aBackend)))))) {
161
0
                FatalError("Error deserializing 'LayersBackend'");
162
0
                return MsgValueError;
163
0
            }
164
0
            // Sentinel = 'aBackend'
165
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 2878499283)))) {
166
0
                mozilla::ipc::SentinelReadError("Error deserializing 'LayersBackend'");
167
0
                return MsgValueError;
168
0
            }
169
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(aTextureFlags)))))) {
170
0
                FatalError("Error deserializing 'TextureFlags'");
171
0
                return MsgValueError;
172
0
            }
173
0
            // Sentinel = 'aTextureFlags'
174
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 3005687826)))) {
175
0
                mozilla::ipc::SentinelReadError("Error deserializing 'TextureFlags'");
176
0
                return MsgValueError;
177
0
            }
178
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(aSerial)))))) {
179
0
                FatalError("Error deserializing 'uint64_t'");
180
0
                return MsgValueError;
181
0
            }
182
0
            // Sentinel = 'aSerial'
183
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 1247987114)))) {
184
0
                mozilla::ipc::SentinelReadError("Error deserializing 'uint64_t'");
185
0
                return MsgValueError;
186
0
            }
187
0
            (msg__).EndRead(iter__, (msg__).type());
188
0
            if ((!(StateTransition(false, (&(mLivenessState)))))) {
189
0
                FatalError("Transition error");
190
0
                return MsgValueError;
191
0
            }
192
0
            actor = AllocPTextureParent(aSharedData, aReadLock, aBackend, aTextureFlags, aSerial);
193
0
            if ((!(actor))) {
194
0
                NS_WARNING("Error constructing actor PTextureParent");
195
0
                return MsgValueError;
196
0
            }
197
0
            (actor)->SetManagerAndRegister(this, (handle__).mId);
198
0
            (mManagedPTextureParent).PutEntry(actor);
199
0
            (actor)->mLivenessState = mozilla::ipc::LivenessState::Start;
200
0
201
0
            if ((!(RecvPTextureConstructor(actor, aSharedData, aReadLock, aBackend, aTextureFlags, aSerial)))) {
202
0
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
203
0
                // Error handled in mozilla::ipc::IPCResult
204
0
                return MsgProcessingError;
205
0
            }
206
0
207
0
            return MsgProcessed;
208
0
        }
209
0
    default:
210
0
        {
211
0
            return MsgNotKnown;
212
0
        }
213
0
    case SHMEM_CREATED_MESSAGE_TYPE:
214
0
        {
215
0
            if ((!(ShmemCreated(msg__)))) {
216
0
                return MsgPayloadError;
217
0
            }
218
0
            return MsgProcessed;
219
0
        }
220
0
    case SHMEM_DESTROYED_MESSAGE_TYPE:
221
0
        {
222
0
            if ((!(ShmemDestroyed(msg__)))) {
223
0
                return MsgPayloadError;
224
0
            }
225
0
            return MsgProcessed;
226
0
        }
227
0
    }
228
0
}
229
230
auto PVideoBridgeParent::OnMessageReceived(
231
        const Message& msg__,
232
        Message*& reply__) -> PVideoBridgeParent::Result
233
0
{
234
0
    int32_t route__ = (msg__).routing_id();
235
0
    if ((MSG_ROUTING_CONTROL) != (route__)) {
236
0
        IProtocol* routed__ = Lookup(route__);
237
0
        if ((!(routed__))) {
238
0
            return MsgRouteError;
239
0
        }
240
0
        return (routed__)->OnMessageReceived(msg__, reply__);
241
0
    }
242
0
243
0
    return MsgNotKnown;
244
0
}
245
246
auto PVideoBridgeParent::OnCallReceived(
247
        const Message& msg__,
248
        Message*& reply__) -> PVideoBridgeParent::Result
249
0
{
250
0
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
251
0
    return MsgNotKnown;
252
0
}
253
254
auto PVideoBridgeParent::GetProtocolTypeId() -> int32_t
255
0
{
256
0
    return PVideoBridgeMsgStart;
257
0
}
258
259
auto PVideoBridgeParent::OnChannelClose() -> void
260
0
{
261
0
    DestroySubtree(NormalShutdown);
262
0
    DeallocSubtree();
263
0
    DeallocShmems();
264
0
    DeallocPVideoBridgeParent();
265
0
}
266
267
auto PVideoBridgeParent::OnChannelError() -> void
268
0
{
269
0
    DestroySubtree(AbnormalShutdown);
270
0
    DeallocSubtree();
271
0
    DeallocShmems();
272
0
    DeallocPVideoBridgeParent();
273
0
}
274
275
auto PVideoBridgeParent::DestroySubtree(ActorDestroyReason why) -> void
276
0
{
277
0
    ActorDestroyReason subtreewhy = (((why) == (Deletion)) || ((why) == (FailedConstructor)) ? AncestorDeletion : why);
278
0
279
0
    {
280
0
        // Recursively shutting down PTexture kids
281
0
        nsTArray<PTextureParent*> kids;
282
0
        // Accumulate kids into a stable structure to iterate over
283
0
        ManagedPTextureParent(kids);
284
0
        for (auto& kid : kids) {
285
0
            // Guarding against a child removing a sibling from the list during the iteration.
286
0
            if ((mManagedPTextureParent).Contains(kid)) {
287
0
                (kid)->DestroySubtree(subtreewhy);
288
0
            }
289
0
        }
290
0
    }
291
0
292
0
    // Reject owning pending responses.
293
0
    (GetIPCChannel())->RejectPendingResponsesForActor(this);
294
0
295
0
    // Finally, destroy "us".
296
0
    ActorDestroy(why);
297
0
}
298
299
auto PVideoBridgeParent::DeallocSubtree() -> void
300
0
{
301
0
    {
302
0
        // Recursively deleting PTexture kids
303
0
        for (auto iter = (mManagedPTextureParent).Iter(); (!((iter).Done())); (iter).Next()) {
304
0
            (((iter).Get())->GetKey())->DeallocSubtree();
305
0
        }
306
0
307
0
        for (auto iter = (mManagedPTextureParent).Iter(); (!((iter).Done())); (iter).Next()) {
308
0
            DeallocPTextureParent(((iter).Get())->GetKey());
309
0
        }
310
0
        (mManagedPTextureParent).Clear();
311
0
    }
312
0
}
313
314
auto PVideoBridgeParent::DeallocPVideoBridgeParent() -> void
315
0
{
316
0
}
317
318
319
320
} // namespace layers
321
} // namespace mozilla
322
namespace mozilla {
323
namespace ipc {
324
auto IPDLParamTraits<mozilla::layers::PVideoBridgeParent>::Write(
325
        IPC::Message* aMsg,
326
        mozilla::ipc::IProtocol* aActor,
327
        const paramType& aVar) -> void
328
0
{
329
0
    int32_t id;
330
0
    if ((!(aVar))) {
331
0
        id = 0;
332
0
    }
333
0
    else {
334
0
        id = (aVar)->Id();
335
0
        if ((1) == (id)) {
336
0
            (aActor)->FatalError("actor has been |delete|d");
337
0
        }
338
0
    }
339
0
    WriteIPDLParam(aMsg, aActor, id);
340
0
}
341
342
auto IPDLParamTraits<mozilla::layers::PVideoBridgeParent>::Read(
343
        const IPC::Message* aMsg,
344
        PickleIterator* aIter,
345
        mozilla::ipc::IProtocol* aActor,
346
        paramType* aVar) -> bool
347
0
{
348
0
    mozilla::Maybe<mozilla::ipc::IProtocol*> actor = (aActor)->ReadActor(aMsg, aIter, true, "PVideoBridge", PVideoBridgeMsgStart);
349
0
    if ((actor).isNothing()) {
350
0
        return false;
351
0
    }
352
0
353
0
    (*(aVar)) = static_cast<mozilla::layers::PVideoBridgeParent*>((actor).value());
354
0
    return true;
355
0
}
356
357
} // namespace ipc
358
} // namespace mozilla