Coverage Report

Created: 2018-09-25 14:53

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