Coverage Report

Created: 2018-09-25 14:53

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