Coverage Report

Created: 2018-09-25 14:53

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