Coverage Report

Created: 2018-09-25 14:53

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