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


#include "mozilla/PProcessHangMonitorChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/TabMessageUtils.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 PProcessHangMonitorChild::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

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

MOZ_IMPLICIT PProcessHangMonitorChild::PProcessHangMonitorChild() :
    mozilla::ipc::IToplevelProtocol("PProcessHangMonitorChild", kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PProcessHangMonitorChild);
}

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

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

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

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

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

auto PProcessHangMonitorChild::SendHangEvidence(const SlowScriptData& data) -> bool
{
    UniquePtr<IPC::Message> msg__ = PProcessHangMonitor::Msg_HangEvidence(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


    if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitor", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProcessHangMonitorChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProcessHangMonitor::Msg_HangEvidence", OTHER);

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

auto PProcessHangMonitorChild::SendClearHang() -> bool
{
    UniquePtr<IPC::Message> msg__ = PProcessHangMonitor::Msg_ClearHang(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



    if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitor", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PProcessHangMonitorChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PProcessHangMonitor::Msg_ClearHang", OTHER);

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

auto PProcessHangMonitorChild::DeallocManagee(
        mozilla::ipc::ProtocolId aProtocolId,
        IProtocol* 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("PProcessHangMonitor", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProcessHangMonitorChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PProcessHangMonitor::Msg_TerminateScript", OTHER);

            mozilla::ipc::IPCResult __ok = (this)->RecvTerminateScript();
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PProcessHangMonitor::Msg_RequestContentJSInterrupt__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitor", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProcessHangMonitorChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PProcessHangMonitor::Msg_RequestContentJSInterrupt", OTHER);

            mozilla::ipc::IPCResult __ok = (this)->RecvRequestContentJSInterrupt();
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PProcessHangMonitor::Msg_BeginStartingDebugger__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitor", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProcessHangMonitorChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PProcessHangMonitor::Msg_BeginStartingDebugger", OTHER);

            mozilla::ipc::IPCResult __ok = (this)->RecvBeginStartingDebugger();
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PProcessHangMonitor::Msg_EndStartingDebugger__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitor", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProcessHangMonitorChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PProcessHangMonitor::Msg_EndStartingDebugger", OTHER);

            mozilla::ipc::IPCResult __ok = (this)->RecvEndStartingDebugger();
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PProcessHangMonitor::Msg_PaintWhileInterruptingJS__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitor", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProcessHangMonitorChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PProcessHangMonitor::Msg_PaintWhileInterruptingJS", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__tabId = IPC::ReadParam<TabId>((&(reader__)));
            if (!maybe__tabId) {
                FatalError("Error deserializing 'TabId'");
                return MsgValueError;

            }
            auto& tabId = *maybe__tabId;
            // Sentinel = 'tabId'
            if ((!(((&(reader__)))->ReadSentinel(99156453)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'TabId'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvPaintWhileInterruptingJS(std::move(tabId));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PProcessHangMonitor::Msg_UnloadLayersWhileInterruptingJS__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitor", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProcessHangMonitorChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PProcessHangMonitor::Msg_UnloadLayersWhileInterruptingJS", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__tabId = IPC::ReadParam<TabId>((&(reader__)));
            if (!maybe__tabId) {
                FatalError("Error deserializing 'TabId'");
                return MsgValueError;

            }
            auto& tabId = *maybe__tabId;
            // Sentinel = 'tabId'
            if ((!(((&(reader__)))->ReadSentinel(99156453)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'TabId'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvUnloadLayersWhileInterruptingJS(std::move(tabId));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PProcessHangMonitor::Msg_CancelContentJSExecutionIfRunning__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitor", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProcessHangMonitorChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PProcessHangMonitor::Msg_CancelContentJSExecutionIfRunning", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__tabId = IPC::ReadParam<TabId>((&(reader__)));
            if (!maybe__tabId) {
                FatalError("Error deserializing 'TabId'");
                return MsgValueError;

            }
            auto& tabId = *maybe__tabId;
            // Sentinel = 'tabId'
            if ((!(((&(reader__)))->ReadSentinel(99156453)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'TabId'");
                return MsgValueError;
            }
            auto maybe__aNavigationType = IPC::ReadParam<NavigationType>((&(reader__)));
            if (!maybe__aNavigationType) {
                FatalError("Error deserializing 'NavigationType'");
                return MsgValueError;

            }
            auto& aNavigationType = *maybe__aNavigationType;
            // Sentinel = 'aNavigationType'
            if ((!(((&(reader__)))->ReadSentinel(799540756)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'NavigationType'");
                return MsgValueError;
            }
            auto maybe__aNavigationIndex = IPC::ReadParam<int32_t>((&(reader__)));
            if (!maybe__aNavigationIndex) {
                FatalError("Error deserializing 'int32_t'");
                return MsgValueError;

            }
            auto& aNavigationIndex = *maybe__aNavigationIndex;
            // Sentinel = 'aNavigationIndex'
            if ((!(((&(reader__)))->ReadSentinel(900531818)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int32_t'");
                return MsgValueError;
            }
            auto maybe__aNavigationURI = IPC::ReadParam<mozilla::Maybe<nsCString>>((&(reader__)));
            if (!maybe__aNavigationURI) {
                FatalError("Error deserializing 'nsCString?'");
                return MsgValueError;

            }
            auto& aNavigationURI = *maybe__aNavigationURI;
            // Sentinel = 'aNavigationURI'
            if ((!(((&(reader__)))->ReadSentinel(690095458)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString?'");
                return MsgValueError;
            }
            auto maybe__aEpoch = IPC::ReadParam<int32_t>((&(reader__)));
            if (!maybe__aEpoch) {
                FatalError("Error deserializing 'int32_t'");
                return MsgValueError;

            }
            auto& aEpoch = *maybe__aEpoch;
            // Sentinel = 'aEpoch'
            if ((!(((&(reader__)))->ReadSentinel(132121169)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvCancelContentJSExecutionIfRunning(std::move(tabId), std::move(aNavigationType), std::move(aNavigationIndex), std::move(aNavigationURI), std::move(aEpoch));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PProcessHangMonitor::Msg_SetMainThreadQoSPriority__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitor", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProcessHangMonitorChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PProcessHangMonitor::Msg_SetMainThreadQoSPriority", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__qosPriority = IPC::ReadParam<QoSPriority>((&(reader__)));
            if (!maybe__qosPriority) {
                FatalError("Error deserializing 'QoSPriority'");
                return MsgValueError;

            }
            auto& qosPriority = *maybe__qosPriority;
            // Sentinel = 'qosPriority'
            if ((!(((&(reader__)))->ReadSentinel(468321462)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'QoSPriority'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvSetMainThreadQoSPriority(std::move(qosPriority));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    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 PProcessHangMonitorChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PProcessHangMonitorChild::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}



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

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

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

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

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

} // namespace IPC
