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


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


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

namespace mozilla {



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

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

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

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

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

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

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

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

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

auto PProcessHangMonitorParent::SendTerminateScript() -> bool
{
    IPC::Message* msg__ = PProcessHangMonitor::Msg_TerminateScript(MSG_ROUTING_CONTROL);





    if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitorParent")) {
        mozilla::ipc::LogMessageForProtocol("PProcessHangMonitorParent", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
    }
    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!");
    }

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

auto PProcessHangMonitorParent::SendBeginStartingDebugger() -> bool
{
    IPC::Message* msg__ = PProcessHangMonitor::Msg_BeginStartingDebugger(MSG_ROUTING_CONTROL);





    if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitorParent")) {
        mozilla::ipc::LogMessageForProtocol("PProcessHangMonitorParent", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
    }
    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!");
    }

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

auto PProcessHangMonitorParent::SendEndStartingDebugger() -> bool
{
    IPC::Message* msg__ = PProcessHangMonitor::Msg_EndStartingDebugger(MSG_ROUTING_CONTROL);





    if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitorParent")) {
        mozilla::ipc::LogMessageForProtocol("PProcessHangMonitorParent", OtherPid(), "Sending ", (msg__)->type(), mozilla::ipc::MessageDirection::eSending);
    }
    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!");
    }

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

auto PProcessHangMonitorParent::SendForcePaint(
        const TabId& tabId,
        const uint64_t& aLayerObserverEpoch) -> bool
{
    IPC::Message* msg__ = PProcessHangMonitor::Msg_ForcePaint(MSG_ROUTING_CONTROL);

    Write(tabId, msg__);
    // Sentinel = 'tabId'
    (msg__)->WriteSentinel(3419081923);
    Write(aLayerObserverEpoch, msg__);
    // Sentinel = 'aLayerObserverEpoch'
    (msg__)->WriteSentinel(3446156614);




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

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

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

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

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

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

            PickleIterator iter__ = PickleIterator(msg__);
            HangData data;

            if ((!(Read((&(data)), (&(msg__)), (&(iter__)))))) {
                FatalError("Error deserializing 'HangData'");
                return MsgValueError;
            }
            // Sentinel = 'data'
            if ((!(((&(msg__)))->ReadSentinel((&(iter__)), 843352540)))) {
                FatalError("Error deserializing 'HangData'");
                return MsgValueError;
            }
            (msg__).EndRead(iter__);
            if ((!(PProcessHangMonitor::Transition(Trigger(Trigger::Recv, PProcessHangMonitor::Msg_HangEvidence__ID), (&(mState)))))) {
                NS_WARNING("bad state transition!");
            }
            if ((!(RecvHangEvidence(mozilla::Move(data))))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PProcessHangMonitor::Msg_ClearHang__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitorParent")) {
                mozilla::ipc::LogMessageForProtocol("PProcessHangMonitorParent", OtherPid(), "Received ", ((&(msg__)))->type(), mozilla::ipc::MessageDirection::eReceiving);
            }
            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!");
            }
            if ((!(RecvClearHang()))) {
                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 PProcessHangMonitorParent::OnMessageReceived(
        const Message& msg__,
        Message*& reply__) -> PProcessHangMonitorParent::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}

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

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

auto PProcessHangMonitorParent::OnChannelClose() -> void
{
    DestroySubtree(NormalShutdown);
    DeallocSubtree();
    DeallocShmems();
    DeallocPProcessHangMonitorParent();
}

auto PProcessHangMonitorParent::OnChannelError() -> void
{
    DestroySubtree(AbnormalShutdown);
    DeallocSubtree();
    DeallocShmems();
    DeallocPProcessHangMonitorParent();
}

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

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

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

auto PProcessHangMonitorParent::DeallocPProcessHangMonitorParent() -> void
{
}

auto PProcessHangMonitorParent::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 PProcessHangMonitorParent::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 PProcessHangMonitorParent::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 PProcessHangMonitorParent::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 PProcessHangMonitorParent::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 PProcessHangMonitorParent::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
