Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/ipc/ipdl/PProfilerParent.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/PProfilerParent.h"
8
9
10
#include "nsIFile.h"
11
#include "GeckoProfiler.h"
12
13
namespace mozilla {
14
15
16
auto PProfilerParent::ActorDestroy(ActorDestroyReason aWhy) -> void
17
0
{
18
0
}
19
20
auto PProfilerParent::ProcessingError(
21
        Result aCode,
22
        const char* aReason) -> void
23
0
{
24
0
}
25
26
auto PProfilerParent::ShouldContinueFromReplyTimeout() -> bool
27
0
{
28
0
    return true;
29
0
}
30
31
auto PProfilerParent::EnteredCxxStack() -> void
32
0
{
33
0
}
34
35
auto PProfilerParent::ExitedCxxStack() -> void
36
0
{
37
0
}
38
39
auto PProfilerParent::EnteredCall() -> void
40
0
{
41
0
}
42
43
auto PProfilerParent::ExitedCall() -> void
44
0
{
45
0
}
46
47
MOZ_IMPLICIT PProfilerParent::PProfilerParent() :
48
    mozilla::ipc::IToplevelProtocol("PProfilerParent", PProfilerMsgStart, mozilla::ipc::ParentSide),
49
    mLivenessState(mozilla::ipc::LivenessState::Start)
50
0
{
51
0
    MOZ_COUNT_CTOR(PProfilerParent);
52
0
}
53
54
PProfilerParent::~PProfilerParent()
55
0
{
56
0
    MOZ_COUNT_DTOR(PProfilerParent);
57
0
}
58
59
auto PProfilerParent::SendStart(const ProfilerInitParams& params) -> bool
60
0
{
61
0
    IPC::Message* msg__ = PProfiler::Msg_Start(MSG_ROUTING_CONTROL);
62
0
63
0
    WriteIPDLParam(msg__, this, params);
64
0
    // Sentinel = 'params'
65
0
    (msg__)->WriteSentinel(1677790004);
66
0
67
0
68
0
69
0
70
0
    if (mozilla::ipc::LoggingEnabledFor("PProfilerParent")) {
71
0
        mozilla::ipc::LogMessageForProtocol("PProfilerParent", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
72
0
    }
73
0
    AUTO_PROFILER_LABEL("PProfiler::Msg_Start", OTHER);
74
0
    if ((!(StateTransition(false, (&(mLivenessState)))))) {
75
0
        mozilla::ipc::LogicError("Transition error");
76
0
    }
77
0
78
0
    bool sendok__ = (GetIPCChannel())->Send(msg__);
79
0
    return sendok__;
80
0
}
81
82
auto PProfilerParent::SendEnsureStarted(const ProfilerInitParams& params) -> bool
83
0
{
84
0
    IPC::Message* msg__ = PProfiler::Msg_EnsureStarted(MSG_ROUTING_CONTROL);
85
0
86
0
    WriteIPDLParam(msg__, this, params);
87
0
    // Sentinel = 'params'
88
0
    (msg__)->WriteSentinel(1677790004);
89
0
90
0
91
0
92
0
93
0
    if (mozilla::ipc::LoggingEnabledFor("PProfilerParent")) {
94
0
        mozilla::ipc::LogMessageForProtocol("PProfilerParent", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
95
0
    }
96
0
    AUTO_PROFILER_LABEL("PProfiler::Msg_EnsureStarted", OTHER);
97
0
    if ((!(StateTransition(false, (&(mLivenessState)))))) {
98
0
        mozilla::ipc::LogicError("Transition error");
99
0
    }
100
0
101
0
    bool sendok__ = (GetIPCChannel())->Send(msg__);
102
0
    return sendok__;
103
0
}
104
105
auto PProfilerParent::SendStop() -> bool
106
0
{
107
0
    IPC::Message* msg__ = PProfiler::Msg_Stop(MSG_ROUTING_CONTROL);
108
0
109
0
110
0
111
0
112
0
113
0
    if (mozilla::ipc::LoggingEnabledFor("PProfilerParent")) {
114
0
        mozilla::ipc::LogMessageForProtocol("PProfilerParent", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
115
0
    }
116
0
    AUTO_PROFILER_LABEL("PProfiler::Msg_Stop", OTHER);
117
0
    if ((!(StateTransition(false, (&(mLivenessState)))))) {
118
0
        mozilla::ipc::LogicError("Transition error");
119
0
    }
120
0
121
0
    bool sendok__ = (GetIPCChannel())->Send(msg__);
122
0
    return sendok__;
123
0
}
124
125
auto PProfilerParent::SendPause() -> bool
126
0
{
127
0
    IPC::Message* msg__ = PProfiler::Msg_Pause(MSG_ROUTING_CONTROL);
128
0
129
0
130
0
131
0
132
0
133
0
    if (mozilla::ipc::LoggingEnabledFor("PProfilerParent")) {
134
0
        mozilla::ipc::LogMessageForProtocol("PProfilerParent", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
135
0
    }
136
0
    AUTO_PROFILER_LABEL("PProfiler::Msg_Pause", OTHER);
137
0
    if ((!(StateTransition(false, (&(mLivenessState)))))) {
138
0
        mozilla::ipc::LogicError("Transition error");
139
0
    }
140
0
141
0
    bool sendok__ = (GetIPCChannel())->Send(msg__);
142
0
    return sendok__;
143
0
}
144
145
auto PProfilerParent::SendResume() -> bool
146
0
{
147
0
    IPC::Message* msg__ = PProfiler::Msg_Resume(MSG_ROUTING_CONTROL);
148
0
149
0
150
0
151
0
152
0
153
0
    if (mozilla::ipc::LoggingEnabledFor("PProfilerParent")) {
154
0
        mozilla::ipc::LogMessageForProtocol("PProfilerParent", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
155
0
    }
156
0
    AUTO_PROFILER_LABEL("PProfiler::Msg_Resume", OTHER);
157
0
    if ((!(StateTransition(false, (&(mLivenessState)))))) {
158
0
        mozilla::ipc::LogicError("Transition error");
159
0
    }
160
0
161
0
    bool sendok__ = (GetIPCChannel())->Send(msg__);
162
0
    return sendok__;
163
0
}
164
165
auto PProfilerParent::SendGatherProfile(
166
        mozilla::ipc::ResolveCallback<Shmem>&& aResolve,
167
        mozilla::ipc::RejectCallback&& aReject) -> void
168
0
{
169
0
    IPC::Message* msg__ = PProfiler::Msg_GatherProfile(MSG_ROUTING_CONTROL);
170
0
171
0
172
0
173
0
174
0
175
0
    if (mozilla::ipc::LoggingEnabledFor("PProfilerParent")) {
176
0
        mozilla::ipc::LogMessageForProtocol("PProfilerParent", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
177
0
    }
178
0
    AUTO_PROFILER_LABEL("PProfiler::Msg_GatherProfile", OTHER);
179
0
    if ((!(StateTransition(false, (&(mLivenessState)))))) {
180
0
        mozilla::ipc::LogicError("Transition error");
181
0
    }
182
0
183
0
    (GetIPCChannel())->Send(msg__, this, std::move(aResolve), std::move(aReject));
184
0
    return;
185
0
}
186
187
auto PProfilerParent::SendGatherProfile() -> RefPtr<GatherProfilePromise>
188
0
{
189
0
190
0
    RefPtr<MozPromise<Shmem, ResponseRejectReason, true>::Private> promise__ = new MozPromise<Shmem, ResponseRejectReason, true>::Private(__func__);
191
0
192
0
    SendGatherProfile([promise__](Shmem&& aValue) {
193
0
        (promise__)->Resolve(std::move(aValue), __func__);
194
0
    }, [promise__](ResponseRejectReason aReason) {
195
0
        (promise__)->Reject(aReason, __func__);
196
0
    });
197
0
    return promise__;
198
0
}
199
200
auto PProfilerParent::RemoveManagee(
201
        int32_t aProtocolId,
202
        IProtocol* aListener) -> void
203
0
{
204
0
    FatalError("unreached");
205
0
    return;
206
0
}
207
208
auto PProfilerParent::OnMessageReceived(const Message& msg__) -> PProfilerParent::Result
209
0
{
210
0
    switch ((msg__).type()) {
211
0
    case PProfiler::Reply_GatherProfile__ID:
212
0
        {
213
0
            if (mozilla::ipc::LoggingEnabledFor("PProfilerParent")) {
214
0
                mozilla::ipc::LogMessageForProtocol("PProfilerParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
215
0
            }
216
0
            AUTO_PROFILER_LABEL("PProfiler::Msg_GatherProfile", OTHER);
217
0
218
0
            PickleIterator iter__(msg__);
219
0
            bool resolve__;
220
0
            if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(resolve__)))))) {
221
0
                FatalError("Error deserializing 'resolve__'");
222
0
                return MsgValueError;
223
0
            }
224
0
            // Sentinel = 'resolve__'
225
0
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 3997392463)))) {
226
0
                mozilla::ipc::SentinelReadError("Error deserializing 'resolve__'");
227
0
                return MsgValueError;
228
0
            }
229
0
230
0
            UniquePtr<MessageChannel::UntypedCallbackHolder> untypedCallback = (GetIPCChannel())->PopCallback(msg__);
231
0
            MessageChannel::CallbackHolder<Shmem>* callback = static_cast<MessageChannel::CallbackHolder<Shmem>*>((untypedCallback).get());
232
0
            if ((!(callback))) {
233
0
                FatalError("Error unknown callback");
234
0
                return MsgProcessingError;
235
0
            }
236
0
            if (resolve__) {
237
0
                Shmem profile;
238
0
239
0
                if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(profile)))))) {
240
0
                    FatalError("Error deserializing 'Shmem'");
241
0
                    return MsgValueError;
242
0
                }
243
0
                // Sentinel = 'profile'
244
0
                if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 1885624768)))) {
245
0
                    mozilla::ipc::SentinelReadError("Error deserializing 'Shmem'");
246
0
                    return MsgValueError;
247
0
                }
248
0
                (msg__).EndRead(iter__, (msg__).type());
249
0
                (callback)->Resolve(std::move(profile));
250
0
            }
251
0
            else {
252
0
                ResponseRejectReason reason__;
253
0
                if ((!(ReadIPDLParam((&(msg__)), (&(iter__)), this, (&(reason__)))))) {
254
0
                    FatalError("Error deserializing 'reason__'");
255
0
                    return MsgValueError;
256
0
                }
257
0
                // Sentinel = 'reason__'
258
0
                if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 913452670)))) {
259
0
                    mozilla::ipc::SentinelReadError("Error deserializing 'reason__'");
260
0
                    return MsgValueError;
261
0
                }
262
0
                (msg__).EndRead(iter__, (msg__).type());
263
0
                (callback)->Reject(reason__);
264
0
            }
265
0
            return MsgProcessed;
266
0
        }
267
0
    default:
268
0
        {
269
0
            return MsgNotKnown;
270
0
        }
271
0
    case SHMEM_CREATED_MESSAGE_TYPE:
272
0
        {
273
0
            if ((!(ShmemCreated(msg__)))) {
274
0
                return MsgPayloadError;
275
0
            }
276
0
            return MsgProcessed;
277
0
        }
278
0
    case SHMEM_DESTROYED_MESSAGE_TYPE:
279
0
        {
280
0
            if ((!(ShmemDestroyed(msg__)))) {
281
0
                return MsgPayloadError;
282
0
            }
283
0
            return MsgProcessed;
284
0
        }
285
0
    }
286
0
}
287
288
auto PProfilerParent::OnMessageReceived(
289
        const Message& msg__,
290
        Message*& reply__) -> PProfilerParent::Result
291
0
{
292
0
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
293
0
    return MsgNotKnown;
294
0
}
295
296
auto PProfilerParent::OnCallReceived(
297
        const Message& msg__,
298
        Message*& reply__) -> PProfilerParent::Result
299
0
{
300
0
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
301
0
    return MsgNotKnown;
302
0
}
303
304
auto PProfilerParent::GetProtocolTypeId() -> int32_t
305
0
{
306
0
    return PProfilerMsgStart;
307
0
}
308
309
auto PProfilerParent::OnChannelClose() -> void
310
0
{
311
0
    DestroySubtree(NormalShutdown);
312
0
    DeallocSubtree();
313
0
    DeallocShmems();
314
0
    DeallocPProfilerParent();
315
0
}
316
317
auto PProfilerParent::OnChannelError() -> void
318
0
{
319
0
    DestroySubtree(AbnormalShutdown);
320
0
    DeallocSubtree();
321
0
    DeallocShmems();
322
0
    DeallocPProfilerParent();
323
0
}
324
325
auto PProfilerParent::DestroySubtree(ActorDestroyReason why) -> void
326
0
{
327
0
    // Reject owning pending responses.
328
0
    (GetIPCChannel())->RejectPendingResponsesForActor(this);
329
0
330
0
    // Finally, destroy "us".
331
0
    ActorDestroy(why);
332
0
}
333
334
auto PProfilerParent::DeallocSubtree() -> void
335
0
{
336
0
}
337
338
auto PProfilerParent::DeallocPProfilerParent() -> void
339
0
{
340
0
}
341
342
343
344
} // namespace mozilla
345
namespace mozilla {
346
namespace ipc {
347
auto IPDLParamTraits<mozilla::PProfilerParent>::Write(
348
        IPC::Message* aMsg,
349
        mozilla::ipc::IProtocol* aActor,
350
        const paramType& aVar) -> void
351
0
{
352
0
    int32_t id;
353
0
    if ((!(aVar))) {
354
0
        id = 0;
355
0
    }
356
0
    else {
357
0
        id = (aVar)->Id();
358
0
        if ((1) == (id)) {
359
0
            (aActor)->FatalError("actor has been |delete|d");
360
0
        }
361
0
    }
362
0
    WriteIPDLParam(aMsg, aActor, id);
363
0
}
364
365
auto IPDLParamTraits<mozilla::PProfilerParent>::Read(
366
        const IPC::Message* aMsg,
367
        PickleIterator* aIter,
368
        mozilla::ipc::IProtocol* aActor,
369
        paramType* aVar) -> bool
370
0
{
371
0
    mozilla::Maybe<mozilla::ipc::IProtocol*> actor = (aActor)->ReadActor(aMsg, aIter, true, "PProfiler", PProfilerMsgStart);
372
0
    if ((actor).isNothing()) {
373
0
        return false;
374
0
    }
375
0
376
0
    (*(aVar)) = static_cast<mozilla::PProfilerParent*>((actor).value());
377
0
    return true;
378
0
}
379
380
} // namespace ipc
381
} // namespace mozilla