Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/ipc/ipdl/PBackgroundIDBFactoryChild.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/dom/indexedDB/PBackgroundIDBFactoryChild.h"
8
#include "ipc/IPCMessageUtils.h"
9
10
#include "mozilla/ipc/PBackgroundChild.h"
11
#include "mozilla/dom/indexedDB/PBackgroundIDBDatabaseChild.h"
12
#include "mozilla/dom/indexedDB/PBackgroundIDBFactoryRequestChild.h"
13
14
#include "nsIFile.h"
15
#include "GeckoProfiler.h"
16
17
namespace mozilla {
18
namespace dom {
19
namespace indexedDB {
20
21
22
auto PBackgroundIDBFactoryChild::Recv__delete__() -> mozilla::ipc::IPCResult
23
0
{
24
0
    return IPC_OK();
25
0
}
26
27
auto PBackgroundIDBFactoryChild::RecvPBackgroundIDBDatabaseConstructor(
28
        PBackgroundIDBDatabaseChild* actor,
29
        const DatabaseSpec& spec,
30
        PBackgroundIDBFactoryRequestChild* request) -> mozilla::ipc::IPCResult
31
0
{
32
0
    return IPC_OK();
33
0
}
34
35
auto PBackgroundIDBFactoryChild::ActorDestroy(ActorDestroyReason aWhy) -> void
36
0
{
37
0
}
38
39
MOZ_IMPLICIT PBackgroundIDBFactoryChild::PBackgroundIDBFactoryChild() :
40
    mozilla::ipc::IProtocol(mozilla::ipc::ChildSide),
41
    mLivenessState(mozilla::ipc::LivenessState::Dead)
42
0
{
43
0
    MOZ_COUNT_CTOR(PBackgroundIDBFactoryChild);
44
0
}
45
46
PBackgroundIDBFactoryChild::~PBackgroundIDBFactoryChild()
47
0
{
48
0
    MOZ_COUNT_DTOR(PBackgroundIDBFactoryChild);
49
0
}
50
51
auto PBackgroundIDBFactoryChild::Manager() const -> PBackgroundChild*
52
0
{
53
0
    return static_cast<PBackgroundChild*>(IProtocol::Manager());
54
0
}
55
56
auto PBackgroundIDBFactoryChild::ManagedPBackgroundIDBDatabaseChild(nsTArray<PBackgroundIDBDatabaseChild*>& aArr) const -> void
57
0
{
58
0
    (mManagedPBackgroundIDBDatabaseChild).ToArray(aArr);
59
0
}
60
61
auto PBackgroundIDBFactoryChild::ManagedPBackgroundIDBDatabaseChild() const -> const ManagedContainer<PBackgroundIDBDatabaseChild>&
62
0
{
63
0
    return mManagedPBackgroundIDBDatabaseChild;
64
0
}
65
66
auto PBackgroundIDBFactoryChild::ManagedPBackgroundIDBFactoryRequestChild(nsTArray<PBackgroundIDBFactoryRequestChild*>& aArr) const -> void
67
0
{
68
0
    (mManagedPBackgroundIDBFactoryRequestChild).ToArray(aArr);
69
0
}
70
71
auto PBackgroundIDBFactoryChild::ManagedPBackgroundIDBFactoryRequestChild() const -> const ManagedContainer<PBackgroundIDBFactoryRequestChild>&
72
0
{
73
0
    return mManagedPBackgroundIDBFactoryRequestChild;
74
0
}
75
76
auto PBackgroundIDBFactoryChild::SendDeleteMe() -> bool
77
0
{
78
0
    IPC::Message* msg__ = PBackgroundIDBFactory::Msg_DeleteMe(Id());
79
0
80
0
81
0
82
0
83
0
84
0
    if (mozilla::ipc::LoggingEnabledFor("PBackgroundIDBFactoryChild")) {
85
0
        mozilla::ipc::LogMessageForProtocol("PBackgroundIDBFactoryChild", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
86
0
    }
87
0
    AUTO_PROFILER_LABEL("PBackgroundIDBFactory::Msg_DeleteMe", OTHER);
88
0
    if ((!(StateTransition(false, (&(mLivenessState)))))) {
89
0
        mozilla::ipc::LogicError("Transition error");
90
0
    }
91
0
92
0
    bool sendok__ = (GetIPCChannel())->Send(msg__);
93
0
    return sendok__;
94
0
}
95
96
auto PBackgroundIDBFactoryChild::SendPBackgroundIDBFactoryRequestConstructor(const FactoryRequestParams& params) -> PBackgroundIDBFactoryRequestChild*
97
0
{
98
0
    return SendPBackgroundIDBFactoryRequestConstructor(AllocPBackgroundIDBFactoryRequestChild(params), params);
99
0
}
100
101
auto PBackgroundIDBFactoryChild::SendPBackgroundIDBFactoryRequestConstructor(
102
        PBackgroundIDBFactoryRequestChild* actor,
103
        const FactoryRequestParams& params) -> PBackgroundIDBFactoryRequestChild*
104
0
{
105
0
    if ((!(actor))) {
106
0
        NS_WARNING("Error constructing actor PBackgroundIDBFactoryRequestChild");
107
0
        return nullptr;
108
0
    }
109
0
    (actor)->SetManagerAndRegister(this);
110
0
    (mManagedPBackgroundIDBFactoryRequestChild).PutEntry(actor);
111
0
    (actor)->mLivenessState = mozilla::ipc::LivenessState::Start;
112
0
113
0
    IPC::Message* msg__ = PBackgroundIDBFactory::Msg_PBackgroundIDBFactoryRequestConstructor(Id());
114
0
115
0
    MOZ_RELEASE_ASSERT(actor, "NULL actor value passed to non-nullable param");
116
0
    WriteIPDLParam(msg__, this, actor);
117
0
    // Sentinel = 'actor'
118
0
    (msg__)->WriteSentinel(875202478);
119
0
    WriteIPDLParam(msg__, this, params);
120
0
    // Sentinel = 'params'
121
0
    (msg__)->WriteSentinel(1677790004);
122
0
123
0
124
0
125
0
    if (mozilla::ipc::LoggingEnabledFor("PBackgroundIDBFactoryChild")) {
126
0
        mozilla::ipc::LogMessageForProtocol("PBackgroundIDBFactoryChild", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
127
0
    }
128
0
    AUTO_PROFILER_LABEL("PBackgroundIDBFactory::Msg_PBackgroundIDBFactoryRequestConstructor", OTHER);
129
0
    if ((!(StateTransition(false, (&(mLivenessState)))))) {
130
0
        mozilla::ipc::LogicError("Transition error");
131
0
    }
132
0
133
0
    bool sendok__ = (GetIPCChannel())->Send(msg__);
134
0
    if ((!(sendok__))) {
135
0
        FatalError("constructor for actor failed");
136
0
        return nullptr;
137
0
    }
138
0
    return actor;
139
0
}
140
141
auto PBackgroundIDBFactoryChild::SendIncrementLoggingRequestSerialNumber() -> bool
142
0
{
143
0
    IPC::Message* msg__ = PBackgroundIDBFactory::Msg_IncrementLoggingRequestSerialNumber(Id());
144
0
145
0
146
0
147
0
148
0
149
0
    if (mozilla::ipc::LoggingEnabledFor("PBackgroundIDBFactoryChild")) {
150
0
        mozilla::ipc::LogMessageForProtocol("PBackgroundIDBFactoryChild", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
151
0
    }
152
0
    AUTO_PROFILER_LABEL("PBackgroundIDBFactory::Msg_IncrementLoggingRequestSerialNumber", OTHER);
153
0
    if ((!(StateTransition(false, (&(mLivenessState)))))) {
154
0
        mozilla::ipc::LogicError("Transition error");
155
0
    }
156
0
157
0
    bool sendok__ = (GetIPCChannel())->Send(msg__);
158
0
    return sendok__;
159
0
}
160
161
auto PBackgroundIDBFactoryChild::RemoveManagee(
162
        int32_t aProtocolId,
163
        IProtocol* aListener) -> void
164
0
{
165
0
    switch (aProtocolId) {
166
0
    case PBackgroundIDBDatabaseMsgStart:
167
0
        {
168
0
            PBackgroundIDBDatabaseChild* actor = static_cast<PBackgroundIDBDatabaseChild*>(aListener);
169
0
            auto& container = mManagedPBackgroundIDBDatabaseChild;
170
0
            MOZ_RELEASE_ASSERT((container).Contains(actor), "actor not managed by this!");
171
0
172
0
            (container).RemoveEntry(actor);
173
0
            DeallocPBackgroundIDBDatabaseChild(actor);
174
0
            return;
175
0
        }
176
0
    case PBackgroundIDBFactoryRequestMsgStart:
177
0
        {
178
0
            PBackgroundIDBFactoryRequestChild* actor = static_cast<PBackgroundIDBFactoryRequestChild*>(aListener);
179
0
            auto& container = mManagedPBackgroundIDBFactoryRequestChild;
180
0
            MOZ_RELEASE_ASSERT((container).Contains(actor), "actor not managed by this!");
181
0
182
0
            (container).RemoveEntry(actor);
183
0
            DeallocPBackgroundIDBFactoryRequestChild(actor);
184
0
            return;
185
0
        }
186
0
    default:
187
0
        {
188
0
            FatalError("unreached");
189
0
            return;
190
0
        }
191
0
    }
192
0
}
193
194
auto PBackgroundIDBFactoryChild::OnMessageReceived(const Message& msg__) -> PBackgroundIDBFactoryChild::Result
195
0
{
196
0
    switch ((msg__).type()) {
197
0
    case PBackgroundIDBFactory::Reply_PBackgroundIDBFactoryRequestConstructor__ID:
198
0
        {
199
0
            return MsgProcessed;
200
0
        }
201
0
    case PBackgroundIDBFactory::Msg___delete____ID:
202
0
        {
203
0
            if (mozilla::ipc::LoggingEnabledFor("PBackgroundIDBFactoryChild")) {
204
0
                mozilla::ipc::LogMessageForProtocol("PBackgroundIDBFactoryChild", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
205
0
            }
206
0
            AUTO_PROFILER_LABEL("PBackgroundIDBFactory::Msg___delete__", OTHER);
207
0
208
0
            PickleIterator iter__(msg__);
209
0
            PBackgroundIDBFactoryChild* actor;
210
0
211
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(actor)))))) {
212
0
                FatalError("Error deserializing 'PBackgroundIDBFactoryChild'");
213
0
                return MsgValueError;
214
0
            }
215
0
            if ((!((*((&(actor))))))) {
216
0
                FatalError("Error deserializing 'PBackgroundIDBFactoryChild'");
217
0
                return MsgValueError;
218
0
            }
219
0
            // Sentinel = 'actor'
220
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 875202478)))) {
221
0
                mozilla::ipc::SentinelReadError("Error deserializing 'PBackgroundIDBFactoryChild'");
222
0
                return MsgValueError;
223
0
            }
224
0
            (msg__).EndRead(iter__, (msg__).type());
225
0
            if ((!(StateTransition(true, (&(mLivenessState)))))) {
226
0
                FatalError("Transition error");
227
0
                return MsgValueError;
228
0
            }
229
0
            if ((!(Recv__delete__()))) {
230
0
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
231
0
                // Error handled in mozilla::ipc::IPCResult
232
0
                return MsgProcessingError;
233
0
            }
234
0
235
0
236
0
            IProtocol* mgr = (actor)->Manager();
237
0
            (actor)->DestroySubtree(Deletion);
238
0
            (actor)->DeallocSubtree();
239
0
            (mgr)->RemoveManagee(PBackgroundIDBFactoryMsgStart, actor);
240
0
241
0
            return MsgProcessed;
242
0
        }
243
0
    case PBackgroundIDBFactory::Msg_PBackgroundIDBDatabaseConstructor__ID:
244
0
        {
245
0
            if (mozilla::ipc::LoggingEnabledFor("PBackgroundIDBFactoryChild")) {
246
0
                mozilla::ipc::LogMessageForProtocol("PBackgroundIDBFactoryChild", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
247
0
            }
248
0
            AUTO_PROFILER_LABEL("PBackgroundIDBFactory::Msg_PBackgroundIDBDatabaseConstructor", OTHER);
249
0
250
0
            PickleIterator iter__(msg__);
251
0
            ActorHandle handle__;
252
0
            PBackgroundIDBDatabaseChild* actor;
253
0
            DatabaseSpec spec;
254
0
            PBackgroundIDBFactoryRequestChild* request;
255
0
256
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(handle__)))))) {
257
0
                FatalError("Error deserializing 'ActorHandle'");
258
0
                return MsgValueError;
259
0
            }
260
0
            // Sentinel = 'actor'
261
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 875202478)))) {
262
0
                mozilla::ipc::SentinelReadError("Error deserializing 'ActorHandle'");
263
0
                return MsgValueError;
264
0
            }
265
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(spec)))))) {
266
0
                FatalError("Error deserializing 'DatabaseSpec'");
267
0
                return MsgValueError;
268
0
            }
269
0
            // Sentinel = 'spec'
270
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 1630740541)))) {
271
0
                mozilla::ipc::SentinelReadError("Error deserializing 'DatabaseSpec'");
272
0
                return MsgValueError;
273
0
            }
274
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(request)))))) {
275
0
                FatalError("Error deserializing 'PBackgroundIDBFactoryRequestChild'");
276
0
                return MsgValueError;
277
0
            }
278
0
            if ((!((*((&(request))))))) {
279
0
                FatalError("Error deserializing 'PBackgroundIDBFactoryRequestChild'");
280
0
                return MsgValueError;
281
0
            }
282
0
            // Sentinel = 'request'
283
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 2366856172)))) {
284
0
                mozilla::ipc::SentinelReadError("Error deserializing 'PBackgroundIDBFactoryRequestChild'");
285
0
                return MsgValueError;
286
0
            }
287
0
            (msg__).EndRead(iter__, (msg__).type());
288
0
            if ((!(StateTransition(false, (&(mLivenessState)))))) {
289
0
                FatalError("Transition error");
290
0
                return MsgValueError;
291
0
            }
292
0
            actor = AllocPBackgroundIDBDatabaseChild(spec, request);
293
0
            if ((!(actor))) {
294
0
                NS_WARNING("Error constructing actor PBackgroundIDBDatabaseChild");
295
0
                return MsgValueError;
296
0
            }
297
0
            (actor)->SetManagerAndRegister(this, (handle__).mId);
298
0
            (mManagedPBackgroundIDBDatabaseChild).PutEntry(actor);
299
0
            (actor)->mLivenessState = mozilla::ipc::LivenessState::Start;
300
0
301
0
            if ((!(RecvPBackgroundIDBDatabaseConstructor(actor, spec, request)))) {
302
0
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
303
0
                // Error handled in mozilla::ipc::IPCResult
304
0
                return MsgProcessingError;
305
0
            }
306
0
307
0
            return MsgProcessed;
308
0
        }
309
0
    default:
310
0
        {
311
0
            return MsgNotKnown;
312
0
        }
313
0
    }
314
0
}
315
316
auto PBackgroundIDBFactoryChild::OnMessageReceived(
317
        const Message& msg__,
318
        Message*& reply__) -> PBackgroundIDBFactoryChild::Result
319
0
{
320
0
    return MsgNotKnown;
321
0
}
322
323
auto PBackgroundIDBFactoryChild::OnCallReceived(
324
        const Message& msg__,
325
        Message*& reply__) -> PBackgroundIDBFactoryChild::Result
326
0
{
327
0
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
328
0
    return MsgNotKnown;
329
0
}
330
331
auto PBackgroundIDBFactoryChild::GetProtocolTypeId() -> int32_t
332
0
{
333
0
    return PBackgroundIDBFactoryMsgStart;
334
0
}
335
336
auto PBackgroundIDBFactoryChild::DestroySubtree(ActorDestroyReason why) -> void
337
0
{
338
0
    // Unregister from our manager.
339
0
    Unregister(Id());
340
0
341
0
    ActorDestroyReason subtreewhy = (((why) == (Deletion)) || ((why) == (FailedConstructor)) ? AncestorDeletion : why);
342
0
343
0
    {
344
0
        // Recursively shutting down PBackgroundIDBDatabase kids
345
0
        nsTArray<PBackgroundIDBDatabaseChild*> kids;
346
0
        // Accumulate kids into a stable structure to iterate over
347
0
        ManagedPBackgroundIDBDatabaseChild(kids);
348
0
        for (auto& kid : kids) {
349
0
            // Guarding against a child removing a sibling from the list during the iteration.
350
0
            if ((mManagedPBackgroundIDBDatabaseChild).Contains(kid)) {
351
0
                (kid)->DestroySubtree(subtreewhy);
352
0
            }
353
0
        }
354
0
    }
355
0
    {
356
0
        // Recursively shutting down PBackgroundIDBFactoryRequest kids
357
0
        nsTArray<PBackgroundIDBFactoryRequestChild*> kids;
358
0
        // Accumulate kids into a stable structure to iterate over
359
0
        ManagedPBackgroundIDBFactoryRequestChild(kids);
360
0
        for (auto& kid : kids) {
361
0
            // Guarding against a child removing a sibling from the list during the iteration.
362
0
            if ((mManagedPBackgroundIDBFactoryRequestChild).Contains(kid)) {
363
0
                (kid)->DestroySubtree(subtreewhy);
364
0
            }
365
0
        }
366
0
    }
367
0
368
0
    // Reject owning pending responses.
369
0
    (GetIPCChannel())->RejectPendingResponsesForActor(this);
370
0
371
0
    // Finally, destroy "us".
372
0
    ActorDestroy(why);
373
0
}
374
375
auto PBackgroundIDBFactoryChild::DeallocSubtree() -> void
376
0
{
377
0
    {
378
0
        // Recursively deleting PBackgroundIDBDatabase kids
379
0
        for (auto iter = (mManagedPBackgroundIDBDatabaseChild).Iter(); (!((iter).Done())); (iter).Next()) {
380
0
            (((iter).Get())->GetKey())->DeallocSubtree();
381
0
        }
382
0
383
0
        for (auto iter = (mManagedPBackgroundIDBDatabaseChild).Iter(); (!((iter).Done())); (iter).Next()) {
384
0
            DeallocPBackgroundIDBDatabaseChild(((iter).Get())->GetKey());
385
0
        }
386
0
        (mManagedPBackgroundIDBDatabaseChild).Clear();
387
0
    }
388
0
    {
389
0
        // Recursively deleting PBackgroundIDBFactoryRequest kids
390
0
        for (auto iter = (mManagedPBackgroundIDBFactoryRequestChild).Iter(); (!((iter).Done())); (iter).Next()) {
391
0
            (((iter).Get())->GetKey())->DeallocSubtree();
392
0
        }
393
0
394
0
        for (auto iter = (mManagedPBackgroundIDBFactoryRequestChild).Iter(); (!((iter).Done())); (iter).Next()) {
395
0
            DeallocPBackgroundIDBFactoryRequestChild(((iter).Get())->GetKey());
396
0
        }
397
0
        (mManagedPBackgroundIDBFactoryRequestChild).Clear();
398
0
    }
399
0
}
400
401
402
403
} // namespace indexedDB
404
} // namespace dom
405
} // namespace mozilla
406
namespace mozilla {
407
namespace ipc {
408
auto IPDLParamTraits<mozilla::dom::indexedDB::PBackgroundIDBFactoryChild>::Write(
409
        IPC::Message* aMsg,
410
        mozilla::ipc::IProtocol* aActor,
411
        const paramType& aVar) -> void
412
0
{
413
0
    int32_t id;
414
0
    if ((!(aVar))) {
415
0
        id = 0;
416
0
    }
417
0
    else {
418
0
        id = (aVar)->Id();
419
0
        if ((1) == (id)) {
420
0
            (aActor)->FatalError("actor has been |delete|d");
421
0
        }
422
0
    }
423
0
    WriteIPDLParam(aMsg, aActor, id);
424
0
}
425
426
auto IPDLParamTraits<mozilla::dom::indexedDB::PBackgroundIDBFactoryChild>::Read(
427
        const IPC::Message* aMsg,
428
        PickleIterator* aIter,
429
        mozilla::ipc::IProtocol* aActor,
430
        paramType* aVar) -> bool
431
0
{
432
0
    mozilla::Maybe<mozilla::ipc::IProtocol*> actor = (aActor)->ReadActor(aMsg, aIter, true, "PBackgroundIDBFactory", PBackgroundIDBFactoryMsgStart);
433
0
    if ((actor).isNothing()) {
434
0
        return false;
435
0
    }
436
0
437
0
    (*(aVar)) = static_cast<mozilla::dom::indexedDB::PBackgroundIDBFactoryChild*>((actor).value());
438
0
    return true;
439
0
}
440
441
} // namespace ipc
442
} // namespace mozilla