Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/ipc/ipdl/PBackgroundSDBConnectionParent.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/PBackgroundSDBConnectionParent.h"
8
9
#include "mozilla/ipc/PBackgroundParent.h"
10
#include "mozilla/dom/PBackgroundSDBRequestParent.h"
11
12
#include "nsIFile.h"
13
#include "GeckoProfiler.h"
14
15
namespace mozilla {
16
namespace dom {
17
18
19
auto PBackgroundSDBConnectionParent::RecvPBackgroundSDBRequestConstructor(
20
        PBackgroundSDBRequestParent* actor,
21
        const SDBRequestParams& params) -> mozilla::ipc::IPCResult
22
0
{
23
0
    return IPC_OK();
24
0
}
25
26
auto PBackgroundSDBConnectionParent::ActorDestroy(ActorDestroyReason aWhy) -> void
27
0
{
28
0
}
29
30
MOZ_IMPLICIT PBackgroundSDBConnectionParent::PBackgroundSDBConnectionParent() :
31
    mozilla::ipc::IProtocol(mozilla::ipc::ParentSide),
32
    mLivenessState(mozilla::ipc::LivenessState::Dead)
33
0
{
34
0
    MOZ_COUNT_CTOR(PBackgroundSDBConnectionParent);
35
0
}
36
37
PBackgroundSDBConnectionParent::~PBackgroundSDBConnectionParent()
38
0
{
39
0
    MOZ_COUNT_DTOR(PBackgroundSDBConnectionParent);
40
0
}
41
42
auto PBackgroundSDBConnectionParent::Manager() const -> PBackgroundParent*
43
0
{
44
0
    return static_cast<PBackgroundParent*>(IProtocol::Manager());
45
0
}
46
47
auto PBackgroundSDBConnectionParent::ManagedPBackgroundSDBRequestParent(nsTArray<PBackgroundSDBRequestParent*>& aArr) const -> void
48
0
{
49
0
    (mManagedPBackgroundSDBRequestParent).ToArray(aArr);
50
0
}
51
52
auto PBackgroundSDBConnectionParent::ManagedPBackgroundSDBRequestParent() const -> const ManagedContainer<PBackgroundSDBRequestParent>&
53
0
{
54
0
    return mManagedPBackgroundSDBRequestParent;
55
0
}
56
57
auto PBackgroundSDBConnectionParent::Send__delete__(PBackgroundSDBConnectionParent* actor) -> bool
58
0
{
59
0
    if ((!(actor))) {
60
0
        return false;
61
0
    }
62
0
63
0
    IPC::Message* msg__ = PBackgroundSDBConnection::Msg___delete__((actor)->Id());
64
0
65
0
    MOZ_RELEASE_ASSERT(actor, "NULL actor value passed to non-nullable param");
66
0
    WriteIPDLParam(msg__, actor, actor);
67
0
    // Sentinel = 'actor'
68
0
    (msg__)->WriteSentinel(875202478);
69
0
70
0
71
0
72
0
    if (mozilla::ipc::LoggingEnabledFor("PBackgroundSDBConnectionParent")) {
73
0
        mozilla::ipc::LogMessageForProtocol("PBackgroundSDBConnectionParent", (actor)->OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
74
0
    }
75
0
    AUTO_PROFILER_LABEL("PBackgroundSDBConnection::Msg___delete__", OTHER);
76
0
    if ((!(StateTransition(true, (&((actor)->mLivenessState)))))) {
77
0
        mozilla::ipc::LogicError("Transition error");
78
0
    }
79
0
80
0
    bool sendok__ = ((actor)->GetIPCChannel())->Send(msg__);
81
0
82
0
    IProtocol* mgr = (actor)->Manager();
83
0
    (actor)->DestroySubtree(Deletion);
84
0
    (actor)->DeallocSubtree();
85
0
    (mgr)->RemoveManagee(PBackgroundSDBConnectionMsgStart, actor);
86
0
    return sendok__;
87
0
}
88
89
auto PBackgroundSDBConnectionParent::SendAllowToClose() -> bool
90
0
{
91
0
    IPC::Message* msg__ = PBackgroundSDBConnection::Msg_AllowToClose(Id());
92
0
93
0
94
0
95
0
96
0
97
0
    if (mozilla::ipc::LoggingEnabledFor("PBackgroundSDBConnectionParent")) {
98
0
        mozilla::ipc::LogMessageForProtocol("PBackgroundSDBConnectionParent", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
99
0
    }
100
0
    AUTO_PROFILER_LABEL("PBackgroundSDBConnection::Msg_AllowToClose", 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 PBackgroundSDBConnectionParent::SendClosed() -> bool
110
0
{
111
0
    IPC::Message* msg__ = PBackgroundSDBConnection::Msg_Closed(Id());
112
0
113
0
114
0
115
0
116
0
117
0
    if (mozilla::ipc::LoggingEnabledFor("PBackgroundSDBConnectionParent")) {
118
0
        mozilla::ipc::LogMessageForProtocol("PBackgroundSDBConnectionParent", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
119
0
    }
120
0
    AUTO_PROFILER_LABEL("PBackgroundSDBConnection::Msg_Closed", OTHER);
121
0
    if ((!(StateTransition(false, (&(mLivenessState)))))) {
122
0
        mozilla::ipc::LogicError("Transition error");
123
0
    }
124
0
125
0
    bool sendok__ = (GetIPCChannel())->Send(msg__);
126
0
    return sendok__;
127
0
}
128
129
auto PBackgroundSDBConnectionParent::RemoveManagee(
130
        int32_t aProtocolId,
131
        IProtocol* aListener) -> void
132
0
{
133
0
    switch (aProtocolId) {
134
0
    case PBackgroundSDBRequestMsgStart:
135
0
        {
136
0
            PBackgroundSDBRequestParent* actor = static_cast<PBackgroundSDBRequestParent*>(aListener);
137
0
            auto& container = mManagedPBackgroundSDBRequestParent;
138
0
            MOZ_RELEASE_ASSERT((container).Contains(actor), "actor not managed by this!");
139
0
140
0
            (container).RemoveEntry(actor);
141
0
            DeallocPBackgroundSDBRequestParent(actor);
142
0
            return;
143
0
        }
144
0
    default:
145
0
        {
146
0
            FatalError("unreached");
147
0
            return;
148
0
        }
149
0
    }
150
0
}
151
152
auto PBackgroundSDBConnectionParent::OnMessageReceived(const Message& msg__) -> PBackgroundSDBConnectionParent::Result
153
0
{
154
0
    switch ((msg__).type()) {
155
0
    case PBackgroundSDBConnection::Msg_DeleteMe__ID:
156
0
        {
157
0
            if (mozilla::ipc::LoggingEnabledFor("PBackgroundSDBConnectionParent")) {
158
0
                mozilla::ipc::LogMessageForProtocol("PBackgroundSDBConnectionParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
159
0
            }
160
0
            AUTO_PROFILER_LABEL("PBackgroundSDBConnection::Msg_DeleteMe", OTHER);
161
0
162
0
            if ((!(StateTransition(false, (&(mLivenessState)))))) {
163
0
                FatalError("Transition error");
164
0
                return MsgValueError;
165
0
            }
166
0
            if ((!(RecvDeleteMe()))) {
167
0
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
168
0
                // Error handled in mozilla::ipc::IPCResult
169
0
                return MsgProcessingError;
170
0
            }
171
0
172
0
            return MsgProcessed;
173
0
        }
174
0
    case PBackgroundSDBConnection::Msg_PBackgroundSDBRequestConstructor__ID:
175
0
        {
176
0
            if (mozilla::ipc::LoggingEnabledFor("PBackgroundSDBConnectionParent")) {
177
0
                mozilla::ipc::LogMessageForProtocol("PBackgroundSDBConnectionParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
178
0
            }
179
0
            AUTO_PROFILER_LABEL("PBackgroundSDBConnection::Msg_PBackgroundSDBRequestConstructor", OTHER);
180
0
181
0
            PickleIterator iter__(msg__);
182
0
            ActorHandle handle__;
183
0
            PBackgroundSDBRequestParent* actor;
184
0
            SDBRequestParams params;
185
0
186
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(handle__)))))) {
187
0
                FatalError("Error deserializing 'ActorHandle'");
188
0
                return MsgValueError;
189
0
            }
190
0
            // Sentinel = 'actor'
191
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 875202478)))) {
192
0
                mozilla::ipc::SentinelReadError("Error deserializing 'ActorHandle'");
193
0
                return MsgValueError;
194
0
            }
195
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(params)))))) {
196
0
                FatalError("Error deserializing 'SDBRequestParams'");
197
0
                return MsgValueError;
198
0
            }
199
0
            // Sentinel = 'params'
200
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 1677790004)))) {
201
0
                mozilla::ipc::SentinelReadError("Error deserializing 'SDBRequestParams'");
202
0
                return MsgValueError;
203
0
            }
204
0
            (msg__).EndRead(iter__, (msg__).type());
205
0
            if ((!(StateTransition(false, (&(mLivenessState)))))) {
206
0
                FatalError("Transition error");
207
0
                return MsgValueError;
208
0
            }
209
0
            actor = AllocPBackgroundSDBRequestParent(params);
210
0
            if ((!(actor))) {
211
0
                NS_WARNING("Error constructing actor PBackgroundSDBRequestParent");
212
0
                return MsgValueError;
213
0
            }
214
0
            (actor)->SetManagerAndRegister(this, (handle__).mId);
215
0
            (mManagedPBackgroundSDBRequestParent).PutEntry(actor);
216
0
            (actor)->mLivenessState = mozilla::ipc::LivenessState::Start;
217
0
218
0
            if ((!(RecvPBackgroundSDBRequestConstructor(actor, params)))) {
219
0
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
220
0
                // Error handled in mozilla::ipc::IPCResult
221
0
                return MsgProcessingError;
222
0
            }
223
0
224
0
            return MsgProcessed;
225
0
        }
226
0
    case PBackgroundSDBConnection::Reply___delete____ID:
227
0
        {
228
0
            return MsgProcessed;
229
0
        }
230
0
    default:
231
0
        {
232
0
            return MsgNotKnown;
233
0
        }
234
0
    }
235
0
}
236
237
auto PBackgroundSDBConnectionParent::OnMessageReceived(
238
        const Message& msg__,
239
        Message*& reply__) -> PBackgroundSDBConnectionParent::Result
240
0
{
241
0
    return MsgNotKnown;
242
0
}
243
244
auto PBackgroundSDBConnectionParent::OnCallReceived(
245
        const Message& msg__,
246
        Message*& reply__) -> PBackgroundSDBConnectionParent::Result
247
0
{
248
0
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
249
0
    return MsgNotKnown;
250
0
}
251
252
auto PBackgroundSDBConnectionParent::GetProtocolTypeId() -> int32_t
253
0
{
254
0
    return PBackgroundSDBConnectionMsgStart;
255
0
}
256
257
auto PBackgroundSDBConnectionParent::DestroySubtree(ActorDestroyReason why) -> void
258
0
{
259
0
    // Unregister from our manager.
260
0
    Unregister(Id());
261
0
262
0
    ActorDestroyReason subtreewhy = (((why) == (Deletion)) || ((why) == (FailedConstructor)) ? AncestorDeletion : why);
263
0
264
0
    {
265
0
        // Recursively shutting down PBackgroundSDBRequest kids
266
0
        nsTArray<PBackgroundSDBRequestParent*> kids;
267
0
        // Accumulate kids into a stable structure to iterate over
268
0
        ManagedPBackgroundSDBRequestParent(kids);
269
0
        for (auto& kid : kids) {
270
0
            // Guarding against a child removing a sibling from the list during the iteration.
271
0
            if ((mManagedPBackgroundSDBRequestParent).Contains(kid)) {
272
0
                (kid)->DestroySubtree(subtreewhy);
273
0
            }
274
0
        }
275
0
    }
276
0
277
0
    // Reject owning pending responses.
278
0
    (GetIPCChannel())->RejectPendingResponsesForActor(this);
279
0
280
0
    // Finally, destroy "us".
281
0
    ActorDestroy(why);
282
0
}
283
284
auto PBackgroundSDBConnectionParent::DeallocSubtree() -> void
285
0
{
286
0
    {
287
0
        // Recursively deleting PBackgroundSDBRequest kids
288
0
        for (auto iter = (mManagedPBackgroundSDBRequestParent).Iter(); (!((iter).Done())); (iter).Next()) {
289
0
            (((iter).Get())->GetKey())->DeallocSubtree();
290
0
        }
291
0
292
0
        for (auto iter = (mManagedPBackgroundSDBRequestParent).Iter(); (!((iter).Done())); (iter).Next()) {
293
0
            DeallocPBackgroundSDBRequestParent(((iter).Get())->GetKey());
294
0
        }
295
0
        (mManagedPBackgroundSDBRequestParent).Clear();
296
0
    }
297
0
}
298
299
300
301
} // namespace dom
302
} // namespace mozilla
303
namespace mozilla {
304
namespace ipc {
305
auto IPDLParamTraits<mozilla::dom::PBackgroundSDBConnectionParent>::Write(
306
        IPC::Message* aMsg,
307
        mozilla::ipc::IProtocol* aActor,
308
        const paramType& aVar) -> void
309
0
{
310
0
    int32_t id;
311
0
    if ((!(aVar))) {
312
0
        id = 0;
313
0
    }
314
0
    else {
315
0
        id = (aVar)->Id();
316
0
        if ((1) == (id)) {
317
0
            (aActor)->FatalError("actor has been |delete|d");
318
0
        }
319
0
    }
320
0
    WriteIPDLParam(aMsg, aActor, id);
321
0
}
322
323
auto IPDLParamTraits<mozilla::dom::PBackgroundSDBConnectionParent>::Read(
324
        const IPC::Message* aMsg,
325
        PickleIterator* aIter,
326
        mozilla::ipc::IProtocol* aActor,
327
        paramType* aVar) -> bool
328
0
{
329
0
    mozilla::Maybe<mozilla::ipc::IProtocol*> actor = (aActor)->ReadActor(aMsg, aIter, true, "PBackgroundSDBConnection", PBackgroundSDBConnectionMsgStart);
330
0
    if ((actor).isNothing()) {
331
0
        return false;
332
0
    }
333
0
334
0
    (*(aVar)) = static_cast<mozilla::dom::PBackgroundSDBConnectionParent*>((actor).value());
335
0
    return true;
336
0
}
337
338
} // namespace ipc
339
} // namespace mozilla