//
// Automatically generated by ipdlc.
// Edit at your own risk
//


#include "mozilla/PProfilerParent.h"
#include "ProfileAdditionalInformation.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/TimeStamp.h"


#include "ipc/IPCMessageUtils.h"
#include "ipc/IPCMessageUtilsSpecializations.h"
#include "nsIFile.h"
#include "mozilla/ipc/Endpoint.h"
#include "mozilla/ipc/ProtocolMessageUtils.h"
#include "mozilla/ipc/ProtocolUtils.h"
#include "mozilla/ipc/ShmemMessageUtils.h"
#include "mozilla/ipc/TaintingIPCUtils.h"

namespace mozilla {


auto PProfilerParent::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

auto PProfilerParent::ShouldContinueFromReplyTimeout() -> bool
{
    return true;
}

MOZ_IMPLICIT PProfilerParent::PProfilerParent() :
    mozilla::ipc::IToplevelProtocol("PProfilerParent", kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PProfilerParent);
}

PProfilerParent::~PProfilerParent()
{
    MOZ_COUNT_DTOR(PProfilerParent);
}

auto PProfilerParent::ActorAlloc() -> void
{
    MOZ_RELEASE_ASSERT(XRE_IsParentProcess(), "Invalid process for `PProfilerParent'");
    AddRef();
}

auto PProfilerParent::ActorDealloc() -> void
{
    Release();
}

auto PProfilerParent::ManagedProtocolIds() const -> mozilla::Span<mozilla::ipc::ProtocolId const>
{
    return {};
}

auto PProfilerParent::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer*
{
    switch (aProtocol) {
    default:
        return nullptr;
    }
}

auto PProfilerParent::RejectPendingResponses(ResponseRejectReason aReason) -> void
{
    mAsyncCallbacks.RejectPendingResponses(aReason);
}

auto PProfilerParent::SendStart(
        const ProfilerInitParams& params,
        mozilla::ipc::ResolveCallback<bool>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_Start(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), params);
    // Sentinel = 'params'
    ((&(writer__)))->WriteSentinel(146997893);


    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_Start", OTHER);

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PProfiler::Reply_Start__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__unused = IPC::ReadParam<bool>(aReader);
            if (!maybe__unused) {
                (aReader)->FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& unused = *maybe__unused;
            // Sentinel = 'unused'
            if ((!((aReader)->ReadSentinel(155517589)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(unused));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PProfilerParent::SendStart(const ProfilerInitParams& params) -> RefPtr<StartPromise>
{
    RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendStart(std::move(params), [promise__](bool&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PProfilerParent::SendEnsureStarted(
        const ProfilerInitParams& params,
        mozilla::ipc::ResolveCallback<bool>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_EnsureStarted(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), params);
    // Sentinel = 'params'
    ((&(writer__)))->WriteSentinel(146997893);


    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_EnsureStarted", OTHER);

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PProfiler::Reply_EnsureStarted__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__unused = IPC::ReadParam<bool>(aReader);
            if (!maybe__unused) {
                (aReader)->FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& unused = *maybe__unused;
            // Sentinel = 'unused'
            if ((!((aReader)->ReadSentinel(155517589)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(unused));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PProfilerParent::SendEnsureStarted(const ProfilerInitParams& params) -> RefPtr<EnsureStartedPromise>
{
    RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendEnsureStarted(std::move(params), [promise__](bool&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PProfilerParent::SendStop(
        mozilla::ipc::ResolveCallback<bool>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_Stop(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_Stop", OTHER);

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PProfiler::Reply_Stop__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__unused = IPC::ReadParam<bool>(aReader);
            if (!maybe__unused) {
                (aReader)->FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& unused = *maybe__unused;
            // Sentinel = 'unused'
            if ((!((aReader)->ReadSentinel(155517589)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(unused));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PProfilerParent::SendStop() -> RefPtr<StopPromise>
{
    RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendStop([promise__](bool&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PProfilerParent::SendPause(
        mozilla::ipc::ResolveCallback<bool>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_Pause(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_Pause", OTHER);

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PProfiler::Reply_Pause__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__unused = IPC::ReadParam<bool>(aReader);
            if (!maybe__unused) {
                (aReader)->FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& unused = *maybe__unused;
            // Sentinel = 'unused'
            if ((!((aReader)->ReadSentinel(155517589)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(unused));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PProfilerParent::SendPause() -> RefPtr<PausePromise>
{
    RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendPause([promise__](bool&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PProfilerParent::SendResume(
        mozilla::ipc::ResolveCallback<bool>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_Resume(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_Resume", OTHER);

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PProfiler::Reply_Resume__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__unused = IPC::ReadParam<bool>(aReader);
            if (!maybe__unused) {
                (aReader)->FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& unused = *maybe__unused;
            // Sentinel = 'unused'
            if ((!((aReader)->ReadSentinel(155517589)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(unused));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PProfilerParent::SendResume() -> RefPtr<ResumePromise>
{
    RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendResume([promise__](bool&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PProfilerParent::SendPauseSampling(
        mozilla::ipc::ResolveCallback<bool>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_PauseSampling(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_PauseSampling", OTHER);

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PProfiler::Reply_PauseSampling__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__unused = IPC::ReadParam<bool>(aReader);
            if (!maybe__unused) {
                (aReader)->FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& unused = *maybe__unused;
            // Sentinel = 'unused'
            if ((!((aReader)->ReadSentinel(155517589)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(unused));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PProfilerParent::SendPauseSampling() -> RefPtr<PauseSamplingPromise>
{
    RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendPauseSampling([promise__](bool&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PProfilerParent::SendResumeSampling(
        mozilla::ipc::ResolveCallback<bool>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_ResumeSampling(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_ResumeSampling", OTHER);

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PProfiler::Reply_ResumeSampling__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__unused = IPC::ReadParam<bool>(aReader);
            if (!maybe__unused) {
                (aReader)->FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& unused = *maybe__unused;
            // Sentinel = 'unused'
            if ((!((aReader)->ReadSentinel(155517589)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(unused));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PProfilerParent::SendResumeSampling() -> RefPtr<ResumeSamplingPromise>
{
    RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendResumeSampling([promise__](bool&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PProfilerParent::SendWaitOnePeriodicSampling(
        mozilla::ipc::ResolveCallback<bool>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_WaitOnePeriodicSampling(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_WaitOnePeriodicSampling", OTHER);

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PProfiler::Reply_WaitOnePeriodicSampling__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__sampled = IPC::ReadParam<bool>(aReader);
            if (!maybe__sampled) {
                (aReader)->FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& sampled = *maybe__sampled;
            // Sentinel = 'sampled'
            if ((!((aReader)->ReadSentinel(197460711)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(sampled));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PProfilerParent::SendWaitOnePeriodicSampling() -> RefPtr<WaitOnePeriodicSamplingPromise>
{
    RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendWaitOnePeriodicSampling([promise__](bool&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PProfilerParent::SendAwaitNextChunkManagerUpdate(
        mozilla::ipc::ResolveCallback<ProfileBufferChunkManagerUpdate>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_AwaitNextChunkManagerUpdate(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_AwaitNextChunkManagerUpdate", OTHER);

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PProfiler::Reply_AwaitNextChunkManagerUpdate__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__update = IPC::ReadParam<ProfileBufferChunkManagerUpdate>(aReader);
            if (!maybe__update) {
                (aReader)->FatalError("Error deserializing 'ProfileBufferChunkManagerUpdate'");
                return MsgValueError;

            }
            auto& update = *maybe__update;
            // Sentinel = 'update'
            if ((!((aReader)->ReadSentinel(150209156)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ProfileBufferChunkManagerUpdate'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(update));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PProfilerParent::SendAwaitNextChunkManagerUpdate() -> RefPtr<AwaitNextChunkManagerUpdatePromise>
{
    RefPtr<MozPromise<ProfileBufferChunkManagerUpdate, ResponseRejectReason, true>::Private> promise__ = new MozPromise<ProfileBufferChunkManagerUpdate, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendAwaitNextChunkManagerUpdate([promise__](ProfileBufferChunkManagerUpdate&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PProfilerParent::SendDestroyReleasedChunksAtOrBefore(const TimeStamp& timeStamp) -> bool
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_DestroyReleasedChunksAtOrBefore(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), timeStamp);
    // Sentinel = 'timeStamp'
    ((&(writer__)))->WriteSentinel(312083381);


    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_DestroyReleasedChunksAtOrBefore", OTHER);

    bool sendok__ = ChannelSend(std::move(msg__));
    return sendok__;
}

auto PProfilerParent::SendGatherProfile(
        mozilla::ipc::ResolveCallback<IPCProfileAndAdditionalInformation>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_GatherProfile(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_GatherProfile", OTHER);

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PProfiler::Reply_GatherProfile__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__profileAndAdditionalInformation = IPC::ReadParam<IPCProfileAndAdditionalInformation>(aReader);
            if (!maybe__profileAndAdditionalInformation) {
                (aReader)->FatalError("Error deserializing 'IPCProfileAndAdditionalInformation'");
                return MsgValueError;

            }
            auto& profileAndAdditionalInformation = *maybe__profileAndAdditionalInformation;
            // Sentinel = 'profileAndAdditionalInformation'
            if ((!((aReader)->ReadSentinel(3328052356)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'IPCProfileAndAdditionalInformation'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(profileAndAdditionalInformation));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PProfilerParent::SendGatherProfile() -> RefPtr<GatherProfilePromise>
{
    RefPtr<MozPromise<IPCProfileAndAdditionalInformation, ResponseRejectReason, true>::Private> promise__ = new MozPromise<IPCProfileAndAdditionalInformation, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendGatherProfile([promise__](IPCProfileAndAdditionalInformation&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PProfilerParent::SendGetGatherProfileProgress(
        mozilla::ipc::ResolveCallback<GatherProfileProgress>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_GetGatherProfileProgress(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_GetGatherProfileProgress", OTHER);

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PProfiler::Reply_GetGatherProfileProgress__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__progress = IPC::ReadParam<GatherProfileProgress>(aReader);
            if (!maybe__progress) {
                (aReader)->FatalError("Error deserializing 'GatherProfileProgress'");
                return MsgValueError;

            }
            auto& progress = *maybe__progress;
            // Sentinel = 'progress'
            if ((!((aReader)->ReadSentinel(261292918)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'GatherProfileProgress'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(progress));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PProfilerParent::SendGetGatherProfileProgress() -> RefPtr<GetGatherProfileProgressPromise>
{
    RefPtr<MozPromise<GatherProfileProgress, ResponseRejectReason, true>::Private> promise__ = new MozPromise<GatherProfileProgress, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendGetGatherProfileProgress([promise__](GatherProfileProgress&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PProfilerParent::SendClearAllPages() -> bool
{
    UniquePtr<IPC::Message> msg__ = PProfiler::Msg_ClearAllPages(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



    if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProfilerParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProfiler::Msg_ClearAllPages", OTHER);

    bool sendok__ = ChannelSend(std::move(msg__));
    return sendok__;
}

auto PProfilerParent::DeallocManagee(
        mozilla::ipc::ProtocolId aProtocolId,
        IProtocol* aListener) -> void
{
    FatalError("unreached");
    return;
}

auto PProfilerParent::OnMessageReceived(const Message& msg__) -> PProfilerParent::Result
{
    switch (msg__.type()) {
    case PProfiler::Reply_Start__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProfilerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PProfiler::Msg_Start", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PProfiler::Reply_EnsureStarted__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProfilerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PProfiler::Msg_EnsureStarted", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PProfiler::Reply_Stop__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProfilerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PProfiler::Msg_Stop", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PProfiler::Reply_Pause__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProfilerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PProfiler::Msg_Pause", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PProfiler::Reply_Resume__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProfilerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PProfiler::Msg_Resume", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PProfiler::Reply_PauseSampling__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProfilerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PProfiler::Msg_PauseSampling", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PProfiler::Reply_ResumeSampling__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProfilerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PProfiler::Msg_ResumeSampling", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PProfiler::Reply_WaitOnePeriodicSampling__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProfilerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PProfiler::Msg_WaitOnePeriodicSampling", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PProfiler::Reply_AwaitNextChunkManagerUpdate__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProfilerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PProfiler::Msg_AwaitNextChunkManagerUpdate", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PProfiler::Reply_GatherProfile__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProfilerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PProfiler::Msg_GatherProfile", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PProfiler::Reply_GetGatherProfileProgress__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProfiler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProfilerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PProfiler::Msg_GetGatherProfileProgress", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    default:
        return MsgNotKnown;
    case SHMEM_CREATED_MESSAGE_TYPE:
        {
            if (!ShmemCreated(msg__)) {
                return MsgPayloadError;
            }
            return MsgProcessed;
        }
    case SHMEM_DESTROYED_MESSAGE_TYPE:
        {
            if (!ShmemDestroyed(msg__)) {
                return MsgPayloadError;
            }
            return MsgProcessed;
        }
    }
}

auto PProfilerParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PProfilerParent::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}



} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::PProfilerParent*>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, static_cast<mozilla::ipc::IProtocol*>(aVar));
    // Sentinel = 'PProfiler'
    (aWriter)->WriteSentinel(288555924);
}

auto ParamTraits<::mozilla::PProfilerParent*>::Read(IPC::MessageReader* aReader) -> IPC::ReadResult<paramType>
{
    auto maybe__actor = IPC::ReadParam<mozilla::ipc::IProtocol*>(aReader);
    if (!maybe__actor) {
        aReader->FatalError("Error deserializing managed PProfiler actor");
        return {};

    }
    auto& actor = *maybe__actor;
    // Sentinel = 'PProfiler'
    if ((!((aReader)->ReadSentinel(288555924)))) {
        mozilla::ipc::SentinelReadError("Error deserializing managed PProfiler actor");
        return {};
    }

    if (actor && actor->GetProtocolId() != PProfilerMsgStart) {
        aReader->FatalError("Unexpected actor type (expected PProfiler)");

        return {};
    }
    return static_cast<::mozilla::PProfilerParent*>(actor);
}

} // namespace IPC
