Coverage Report

Created: 2018-09-25 14:53

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