Coverage Report

Created: 2018-09-25 14:53

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