Coverage Report

Created: 2018-09-25 14:53

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