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


#include "mozilla/dom/PRemoteWorkerDebuggerChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/ClientIPCUtils.h"
#include "mozilla/dom/ReferrerInfoUtils.h"
#include "mozilla/dom/RemoteWorkerDebuggerChild.h"
#include "mozilla/dom/WorkerIPCUtils.h"
#include "mozilla/ipc/IPCCore.h"
#include "nsIPrincipal.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 {
namespace dom {


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

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

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

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

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

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

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

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

auto PRemoteWorkerDebuggerChild::SendUnregister() -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemoteWorkerDebugger::Msg_Unregister(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PRemoteWorkerDebuggerChild::SendPostMessageToDebugger(const nsAString& aMessage) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemoteWorkerDebugger::Msg_PostMessageToDebugger(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PRemoteWorkerDebuggerChild::SendReportErrorToDebugger(const RemoteWorkerDebuggerErrorInfo& aErrorInfo) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemoteWorkerDebugger::Msg_ReportErrorToDebugger(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PRemoteWorkerDebuggerChild::SendSetAsInitialized() -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemoteWorkerDebugger::Msg_SetAsInitialized(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PRemoteWorkerDebuggerChild::SendSetAsClosed() -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemoteWorkerDebugger::Msg_SetAsClosed(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PRemoteWorkerDebuggerChild::SendAddWindowID(const uint64_t& aWindowID) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemoteWorkerDebugger::Msg_AddWindowID(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PRemoteWorkerDebuggerChild::SendRemoveWindowID(const uint64_t& aWindowID) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemoteWorkerDebugger::Msg_RemoveWindowID(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

auto PRemoteWorkerDebuggerChild::OnMessageReceived(const Message& msg__) -> PRemoteWorkerDebuggerChild::Result
{
    switch (msg__.type()) {
    case PRemoteWorkerDebugger::Msg_RegisterDone__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerDebugger", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteWorkerDebuggerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteWorkerDebugger::Msg_RegisterDone", OTHER);

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

            return MsgProcessed;
        }
    case PRemoteWorkerDebugger::Msg_UnregisterDone__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerDebugger", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteWorkerDebuggerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteWorkerDebugger::Msg_UnregisterDone", OTHER);

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

            return MsgProcessed;
        }
    case PRemoteWorkerDebugger::Msg_Initialize__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerDebugger", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteWorkerDebuggerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteWorkerDebugger::Msg_Initialize", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aURL = *maybe__aURL;
            // Sentinel = 'aURL'
            if ((!(((&(reader__)))->ReadSentinel(58130773)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<RemoteWorkerDebuggerChild*>(this))->RecvInitialize(std::move(aURL));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PRemoteWorkerDebugger::Msg_PostMessage__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerDebugger", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteWorkerDebuggerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteWorkerDebugger::Msg_PostMessage", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aMessage = *maybe__aMessage;
            // Sentinel = 'aMessage'
            if ((!(((&(reader__)))->ReadSentinel(233440039)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<RemoteWorkerDebuggerChild*>(this))->RecvPostMessage(std::move(aMessage));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PRemoteWorkerDebugger::Msg_SetDebuggerReady__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerDebugger", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteWorkerDebuggerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteWorkerDebugger::Msg_SetDebuggerReady", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aReady = *maybe__aReady;
            // Sentinel = 'aReady'
            if ((!(((&(reader__)))->ReadSentinel(131990103)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<RemoteWorkerDebuggerChild*>(this))->RecvSetDebuggerReady(std::move(aReady));
            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 PRemoteWorkerDebuggerChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PRemoteWorkerDebuggerChild::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}



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

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

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

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

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

} // namespace IPC
