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


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

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

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

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

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

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

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

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

auto PProcessHangMonitorParent::SendTerminateScript() -> bool
{
    UniquePtr<IPC::Message> msg__ = PProcessHangMonitor::Msg_TerminateScript(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PProcessHangMonitorParent::SendRequestContentJSInterrupt() -> bool
{
    UniquePtr<IPC::Message> msg__ = PProcessHangMonitor::Msg_RequestContentJSInterrupt(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PProcessHangMonitorParent::SendBeginStartingDebugger() -> bool
{
    UniquePtr<IPC::Message> msg__ = PProcessHangMonitor::Msg_BeginStartingDebugger(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PProcessHangMonitorParent::SendEndStartingDebugger() -> bool
{
    UniquePtr<IPC::Message> msg__ = PProcessHangMonitor::Msg_EndStartingDebugger(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PProcessHangMonitorParent::SendPaintWhileInterruptingJS(const TabId& tabId) -> bool
{
    UniquePtr<IPC::Message> msg__ = PProcessHangMonitor::Msg_PaintWhileInterruptingJS(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PProcessHangMonitorParent::SendUnloadLayersWhileInterruptingJS(const TabId& tabId) -> bool
{
    UniquePtr<IPC::Message> msg__ = PProcessHangMonitor::Msg_UnloadLayersWhileInterruptingJS(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PProcessHangMonitorParent::SendCancelContentJSExecutionIfRunning(
        const TabId& tabId,
        const NavigationType& aNavigationType,
        const int32_t& aNavigationIndex,
        const mozilla::Maybe<nsCString>& aNavigationURI,
        const int32_t& aEpoch) -> bool
{
    UniquePtr<IPC::Message> msg__ = PProcessHangMonitor::Msg_CancelContentJSExecutionIfRunning(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), tabId);
    // Sentinel = 'tabId'
    ((&(writer__)))->WriteSentinel(99156453);
    IPC::WriteParam((&(writer__)), aNavigationType);
    // Sentinel = 'aNavigationType'
    ((&(writer__)))->WriteSentinel(799540756);
    IPC::WriteParam((&(writer__)), aNavigationIndex);
    // Sentinel = 'aNavigationIndex'
    ((&(writer__)))->WriteSentinel(900531818);
    IPC::WriteParam((&(writer__)), aNavigationURI);
    // Sentinel = 'aNavigationURI'
    ((&(writer__)))->WriteSentinel(690095458);
    IPC::WriteParam((&(writer__)), aEpoch);
    // Sentinel = 'aEpoch'
    ((&(writer__)))->WriteSentinel(132121169);


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

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

auto PProcessHangMonitorParent::SendSetMainThreadQoSPriority(const QoSPriority& qosPriority) -> bool
{
    UniquePtr<IPC::Message> msg__ = PProcessHangMonitor::Msg_SetMainThreadQoSPriority(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

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

            return MsgProcessed;
        }
    case PProcessHangMonitor::Msg_ClearHang__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProcessHangMonitor", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProcessHangMonitorParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PProcessHangMonitor::Msg_ClearHang", OTHER);

            mozilla::ipc::IPCResult __ok = (this)->RecvClearHang();
            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 PProcessHangMonitorParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PProcessHangMonitorParent::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}



} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::PProcessHangMonitorParent*>::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::PProcessHangMonitorParent*>::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::PProcessHangMonitorParent*>(actor);
}

} // namespace IPC
