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


#include "mozilla/PProcessHangMonitorChild.h"
#ifdef MOZ_CRASHREPORTER
#  include "nsXULAppAPI.h"
#endif


#include "nsIFile.h"
#include "GeckoProfiler.h"

namespace mozilla {


auto PProcessHangMonitorChild::ActorDestroy(ActorDestroyReason aWhy) -> void
{
}

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

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

auto PProcessHangMonitorChild::EnteredCxxStack() -> void
{
}

auto PProcessHangMonitorChild::ExitedCxxStack() -> void
{
}

auto PProcessHangMonitorChild::EnteredCall() -> void
{
}

auto PProcessHangMonitorChild::ExitedCall() -> void
{
}

MOZ_IMPLICIT PProcessHangMonitorChild::PProcessHangMonitorChild() :
    mozilla::ipc::IToplevelProtocol(PProcessHangMonitorMsgStart, mozilla::ipc::ChildSide),
    mChannel(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
    mState(PProcessHangMonitor::__Start)
{
    MOZ_COUNT_CTOR(PProcessHangMonitorChild);
}

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

auto PProcessHangMonitorChild::state() -> PProcessHangMonitor::State
{
    return mState;
}

auto PProcessHangMonitorChild::SendHangEvidence(const HangData& data) -> bool
{
    IPC::Message* msg__ = PProcessHangMonitor::Msg_HangEvidence(MSG_ROUTING_CONTROL);

    Write(data, msg__);
    // Sentinel = 'data'
    (msg__)->WriteSentinel(843352540);




    if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitorChild")) {
        mozilla::ipc::LogMessageForProtocol("PProcessHangMonitorChild", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
    }
    PROFILER_LABEL("PProcessHangMonitor", "Msg_HangEvidence", js::ProfileEntry::Category::OTHER);
    if ((!(PProcessHangMonitor::Transition(Trigger(Trigger::Recv, PProcessHangMonitor::Msg_HangEvidence__ID), (&(mState)))))) {
        NS_WARNING("bad state transition!");
    }

    bool sendok__ = (GetIPCChannel())->Send(msg__);
    return sendok__;
}

auto PProcessHangMonitorChild::SendClearHang() -> bool
{
    IPC::Message* msg__ = PProcessHangMonitor::Msg_ClearHang(MSG_ROUTING_CONTROL);





    if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitorChild")) {
        mozilla::ipc::LogMessageForProtocol("PProcessHangMonitorChild", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
    }
    PROFILER_LABEL("PProcessHangMonitor", "Msg_ClearHang", js::ProfileEntry::Category::OTHER);
    if ((!(PProcessHangMonitor::Transition(Trigger(Trigger::Recv, PProcessHangMonitor::Msg_ClearHang__ID), (&(mState)))))) {
        NS_WARNING("bad state transition!");
    }

    bool sendok__ = (GetIPCChannel())->Send(msg__);
    return sendok__;
}

auto PProcessHangMonitorChild::GetIPCChannel() -> MessageChannel*
{
    return (&(mChannel));
}

auto PProcessHangMonitorChild::GetIPCChannel() const -> const MessageChannel*
{
    return (&(mChannel));
}

auto PProcessHangMonitorChild::RemoveManagee(
        int32_t aProtocolId,
        ProtocolBase* aListener) -> void
{
    FatalError("unreached");
    return;
}

auto PProcessHangMonitorChild::OnMessageReceived(const Message& msg__) -> PProcessHangMonitorChild::Result
{
    switch ((msg__).type()) {
    case PProcessHangMonitor::Msg_TerminateScript__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitorChild")) {
                mozilla::ipc::LogMessageForProtocol("PProcessHangMonitorChild", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
            }
            PROFILER_LABEL("PProcessHangMonitor", "Msg_TerminateScript", js::ProfileEntry::Category::OTHER);

            if ((!(PProcessHangMonitor::Transition(Trigger(Trigger::Send, PProcessHangMonitor::Msg_TerminateScript__ID), (&(mState)))))) {
                NS_WARNING("bad state transition!");
            }
            if ((!(RecvTerminateScript()))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PProcessHangMonitor::Msg_BeginStartingDebugger__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitorChild")) {
                mozilla::ipc::LogMessageForProtocol("PProcessHangMonitorChild", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
            }
            PROFILER_LABEL("PProcessHangMonitor", "Msg_BeginStartingDebugger", js::ProfileEntry::Category::OTHER);

            if ((!(PProcessHangMonitor::Transition(Trigger(Trigger::Send, PProcessHangMonitor::Msg_BeginStartingDebugger__ID), (&(mState)))))) {
                NS_WARNING("bad state transition!");
            }
            if ((!(RecvBeginStartingDebugger()))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PProcessHangMonitor::Msg_EndStartingDebugger__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitorChild")) {
                mozilla::ipc::LogMessageForProtocol("PProcessHangMonitorChild", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
            }
            PROFILER_LABEL("PProcessHangMonitor", "Msg_EndStartingDebugger", js::ProfileEntry::Category::OTHER);

            if ((!(PProcessHangMonitor::Transition(Trigger(Trigger::Send, PProcessHangMonitor::Msg_EndStartingDebugger__ID), (&(mState)))))) {
                NS_WARNING("bad state transition!");
            }
            if ((!(RecvEndStartingDebugger()))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PProcessHangMonitor::Msg_ForcePaint__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitorChild")) {
                mozilla::ipc::LogMessageForProtocol("PProcessHangMonitorChild", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
            }
            PROFILER_LABEL("PProcessHangMonitor", "Msg_ForcePaint", js::ProfileEntry::Category::OTHER);

            PickleIterator iter__ = PickleIterator(msg__);
            TabId tabId;
            uint64_t aLayerObserverEpoch;

            if ((!(Read((&(tabId)), (&(msg__)), (&(iter__)))))) {
                FatalError("Error deserializing 'TabId'");
                return MsgValueError;
            }
            // Sentinel = 'tabId'
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 3419081923)))) {
                FatalError("Error deserializing 'TabId'");
                return MsgValueError;
            }
            if ((!(Read((&(aLayerObserverEpoch)), (&(msg__)), (&(iter__)))))) {
                FatalError("Error deserializing 'uint64_t'");
                return MsgValueError;
            }
            // Sentinel = 'aLayerObserverEpoch'
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 3446156614)))) {
                FatalError("Error deserializing 'uint64_t'");
                return MsgValueError;
            }
            (msg__).EndRead(iter__);
            if ((!(PProcessHangMonitor::Transition(Trigger(Trigger::Send, PProcessHangMonitor::Msg_ForcePaint__ID), (&(mState)))))) {
                NS_WARNING("bad state transition!");
            }
            if ((!(RecvForcePaint(mozilla::Move(tabId), mozilla::Move(aLayerObserverEpoch))))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    default:
        {
            return MsgNotKnown;
        }
    case SHMEM_CREATED_MESSAGE_TYPE:
        {
            FatalError("this protocol tree does not use shmem");
            return MsgNotKnown;
        }
    case SHMEM_DESTROYED_MESSAGE_TYPE:
        {
            FatalError("this protocol tree does not use shmem");
            return MsgNotKnown;
        }
    }
}

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

auto PProcessHangMonitorChild::OnCallReceived(
        const Message& msg__,
        Message*& reply__) -> PProcessHangMonitorChild::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}

auto PProcessHangMonitorChild::GetProtocolTypeId() -> int32_t
{
    return PProcessHangMonitorMsgStart;
}

auto PProcessHangMonitorChild::OnChannelClose() -> void
{
    DestroySubtree(NormalShutdown);
    DeallocSubtree();
    DeallocShmems();
    DeallocPProcessHangMonitorChild();
}

auto PProcessHangMonitorChild::OnChannelError() -> void
{
    DestroySubtree(AbnormalShutdown);
    DeallocSubtree();
    DeallocShmems();
    DeallocPProcessHangMonitorChild();
}

auto PProcessHangMonitorChild::ProtocolName() const -> const char*
{
    return "PProcessHangMonitorChild";
}

auto PProcessHangMonitorChild::DestroySubtree(ActorDestroyReason why) -> void
{
    // Finally, destroy "us".
    ActorDestroy(why);
}

auto PProcessHangMonitorChild::DeallocSubtree() -> void
{
}

auto PProcessHangMonitorChild::DeallocPProcessHangMonitorChild() -> void
{
}

auto PProcessHangMonitorChild::Write(
        const HangData& v__,
        Message* msg__) -> void
{
    typedef HangData type__;
    Write(int((v__).type()), msg__);
    // Sentinel = 'HangData'
    (msg__)->WriteSentinel(424813128);

    switch ((v__).type()) {
    case type__::TSlowScriptData:
        {
            Write((v__).get_SlowScriptData(), msg__);
            // Sentinel = 'TSlowScriptData'
            (msg__)->WriteSentinel(2725568093);
            return;
        }
    case type__::TPluginHangData:
        {
            Write((v__).get_PluginHangData(), msg__);
            // Sentinel = 'TPluginHangData'
            (msg__)->WriteSentinel(2781280854);
            return;
        }
    default:
        {
            FatalError("unknown union type");
            return;
        }
    }
}

auto PProcessHangMonitorChild::Read(
        HangData* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    typedef HangData type__;
    int type;
    if ((!(Read((&(type)), msg__, iter__)))) {
        mozilla::ipc::UnionTypeReadError("HangData");
        return false;
    }
    // Sentinel = 'HangData'
    if ((!((msg__)->ReadSentinel(iter__, 424813128)))) {
        mozilla::ipc::UnionTypeReadError("HangData");
        return false;
    }

    switch (type) {
    case type__::TSlowScriptData:
        {
            SlowScriptData tmp = SlowScriptData();
            (*(v__)) = tmp;
            if ((!(Read((&((v__)->get_SlowScriptData())), msg__, iter__)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            // Sentinel = 'TSlowScriptData'
            if ((!((msg__)->ReadSentinel(iter__, 2725568093)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            return true;
        }
    case type__::TPluginHangData:
        {
            PluginHangData tmp = PluginHangData();
            (*(v__)) = tmp;
            if ((!(Read((&((v__)->get_PluginHangData())), msg__, iter__)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            // Sentinel = 'TPluginHangData'
            if ((!((msg__)->ReadSentinel(iter__, 2781280854)))) {
                FatalError("Error deserializing Union type");
                return false;
            }
            return true;
        }
    default:
        {
            FatalError("unknown union type");
            return false;
        }
    }
}

auto PProcessHangMonitorChild::Write(
        const PluginHangData& v__,
        Message* msg__) -> void
{
    Write((v__).pluginId(), msg__);
    // Sentinel = 'pluginId'
    (msg__)->WriteSentinel(1563488274);
    Write((v__).contentProcessId(), msg__);
    // Sentinel = 'contentProcessId'
    (msg__)->WriteSentinel(3482197741);
}

auto PProcessHangMonitorChild::Read(
        PluginHangData* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    if ((!(Read((&((v__)->pluginId())), msg__, iter__)))) {
        FatalError("Error deserializing 'pluginId' (uint32_t) member of 'PluginHangData'");
        return false;
    }
    // Sentinel = 'pluginId'
    if ((!((msg__)->ReadSentinel(iter__, 1563488274)))) {
        FatalError("Error deserializing 'pluginId' (uint32_t) member of 'PluginHangData'");
        return false;
    }
    if ((!(Read((&((v__)->contentProcessId())), msg__, iter__)))) {
        FatalError("Error deserializing 'contentProcessId' (ProcessId) member of 'PluginHangData'");
        return false;
    }
    // Sentinel = 'contentProcessId'
    if ((!((msg__)->ReadSentinel(iter__, 3482197741)))) {
        FatalError("Error deserializing 'contentProcessId' (ProcessId) member of 'PluginHangData'");
        return false;
    }
    return true;
}

auto PProcessHangMonitorChild::Write(
        const SlowScriptData& v__,
        Message* msg__) -> void
{
    Write((v__).tabId(), msg__);
    // Sentinel = 'tabId'
    (msg__)->WriteSentinel(3419081923);
    Write((v__).filename(), msg__);
    // Sentinel = 'filename'
    (msg__)->WriteSentinel(1198638255);
    Write((v__).lineno(), msg__);
    // Sentinel = 'lineno'
    (msg__)->WriteSentinel(948236981);
}

auto PProcessHangMonitorChild::Read(
        SlowScriptData* v__,
        const Message* msg__,
        PickleIterator* iter__) -> bool
{
    if ((!(Read((&((v__)->tabId())), msg__, iter__)))) {
        FatalError("Error deserializing 'tabId' (TabId) member of 'SlowScriptData'");
        return false;
    }
    // Sentinel = 'tabId'
    if ((!((msg__)->ReadSentinel(iter__, 3419081923)))) {
        FatalError("Error deserializing 'tabId' (TabId) member of 'SlowScriptData'");
        return false;
    }
    if ((!(Read((&((v__)->filename())), msg__, iter__)))) {
        FatalError("Error deserializing 'filename' (nsCString) member of 'SlowScriptData'");
        return false;
    }
    // Sentinel = 'filename'
    if ((!((msg__)->ReadSentinel(iter__, 1198638255)))) {
        FatalError("Error deserializing 'filename' (nsCString) member of 'SlowScriptData'");
        return false;
    }
    if ((!(Read((&((v__)->lineno())), msg__, iter__)))) {
        FatalError("Error deserializing 'lineno' (uint32_t) member of 'SlowScriptData'");
        return false;
    }
    // Sentinel = 'lineno'
    if ((!((msg__)->ReadSentinel(iter__, 948236981)))) {
        FatalError("Error deserializing 'lineno' (uint32_t) member of 'SlowScriptData'");
        return false;
    }
    return true;
}



} // namespace mozilla
