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


#include "mozilla/net/PWebSocketEventListenerChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/net/WebSocketEventListenerChild.h"
#include "mozilla/net/WebSocketFrame.h"

#include "mozilla/net/PNeckoChild.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 net {


auto PWebSocketEventListenerChild::Recv__delete__() -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

MOZ_IMPLICIT PWebSocketEventListenerChild::PWebSocketEventListenerChild() :
    mozilla::ipc::IProtocol(kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PWebSocketEventListenerChild);
}

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

auto PWebSocketEventListenerChild::ActorAlloc() -> void
{
}

auto PWebSocketEventListenerChild::ActorDealloc() -> void
{
    if (Manager()) {
        Manager()->DeallocManagee(kProtocolId, this);
    }
}

auto PWebSocketEventListenerChild::OtherPid() const -> ::base::ProcessId
{
    ::base::ProcessId pid =
        ::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherPidMaybeInvalid();
    MOZ_RELEASE_ASSERT(pid != ::base::kInvalidProcessId);
    return pid;
}

auto PWebSocketEventListenerChild::OtherChildID() const -> ::GeckoChildID
{
    ::GeckoChildID childID =
        ::mozilla::ipc::IProtocol::ToplevelProtocol()->OtherChildIDMaybeInvalid();
    MOZ_RELEASE_ASSERT(childID != -1);
    return childID;
}

auto PWebSocketEventListenerChild::OtherEndpointProcInfo() const -> ::mozilla::ipc::EndpointProcInfo
{
    return ::mozilla::ipc::EndpointProcInfo{OtherPid(), OtherChildID()};
}

auto PWebSocketEventListenerChild::Manager() const -> PNeckoChild*
{
    return static_cast<PNeckoChild*>(IProtocol::Manager());
}

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

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

auto PWebSocketEventListenerChild::SendClose() -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebSocketEventListener::Msg_Close(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

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

auto PWebSocketEventListenerChild::OnMessageReceived(const Message& msg__) -> PWebSocketEventListenerChild::Result
{
    switch (msg__.type()) {
    case MANAGED_ENDPOINT_BOUND_MESSAGE_TYPE:
        {
            if (!mAwaitingManagedEndpointBind) {
                NS_WARNING("Unexpected managed endpoint lifecycle message after actor bound!");
                return MsgNotAllowed;
            }
            mAwaitingManagedEndpointBind = false;
            return MsgProcessed;
        }
    case MANAGED_ENDPOINT_DROPPED_MESSAGE_TYPE:
        {
            if (!mAwaitingManagedEndpointBind) {
                NS_WARNING("Unexpected managed endpoint lifecycle message after actor bound!");
                return MsgNotAllowed;
            }
            mAwaitingManagedEndpointBind = false;
            this->ActorDisconnected(ManagedEndpointDropped);
            return MsgProcessed;
        }
    case PWebSocketEventListener::Msg_WebSocketCreated__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketEventListener", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketEventListenerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketEventListener::Msg_WebSocketCreated", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& awebSocketSerialID = *maybe__awebSocketSerialID;
            // Sentinel = 'awebSocketSerialID'
            if ((!(((&(reader__)))->ReadSentinel(1140524790)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            auto maybe__aURI = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aURI) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aURI = *maybe__aURI;
            // Sentinel = 'aURI'
            if ((!(((&(reader__)))->ReadSentinel(57934162)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aProtocols = IPC::ReadParam<nsCString>((&(reader__)));
            if (!maybe__aProtocols) {
                FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& aProtocols = *maybe__aProtocols;
            // Sentinel = 'aProtocols'
            if ((!(((&(reader__)))->ReadSentinel(373556263)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<WebSocketEventListenerChild*>(this))->RecvWebSocketCreated(std::move(awebSocketSerialID), std::move(aURI), std::move(aProtocols));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PWebSocketEventListener::Msg_WebSocketOpened__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketEventListener", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketEventListenerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketEventListener::Msg_WebSocketOpened", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& awebSocketSerialID = *maybe__awebSocketSerialID;
            // Sentinel = 'awebSocketSerialID'
            if ((!(((&(reader__)))->ReadSentinel(1140524790)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            auto maybe__aEffectiveURI = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aEffectiveURI) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aEffectiveURI = *maybe__aEffectiveURI;
            // Sentinel = 'aEffectiveURI'
            if ((!(((&(reader__)))->ReadSentinel(581502179)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aProtocols = IPC::ReadParam<nsCString>((&(reader__)));
            if (!maybe__aProtocols) {
                FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& aProtocols = *maybe__aProtocols;
            // Sentinel = 'aProtocols'
            if ((!(((&(reader__)))->ReadSentinel(373556263)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__aExtensions = IPC::ReadParam<nsCString>((&(reader__)));
            if (!maybe__aExtensions) {
                FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& aExtensions = *maybe__aExtensions;
            // Sentinel = 'aExtensions'
            if ((!(((&(reader__)))->ReadSentinel(446039186)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__aHttpChannelId = IPC::ReadParam<uint64_t>((&(reader__)));
            if (!maybe__aHttpChannelId) {
                FatalError("Error deserializing 'uint64_t'");
                return MsgValueError;

            }
            auto& aHttpChannelId = *maybe__aHttpChannelId;
            // Sentinel = 'aHttpChannelId'
            if ((!(((&(reader__)))->ReadSentinel(681182568)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint64_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<WebSocketEventListenerChild*>(this))->RecvWebSocketOpened(std::move(awebSocketSerialID), std::move(aEffectiveURI), std::move(aProtocols), std::move(aExtensions), std::move(aHttpChannelId));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PWebSocketEventListener::Msg_WebSocketMessageAvailable__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketEventListener", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketEventListenerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketEventListener::Msg_WebSocketMessageAvailable", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& awebSocketSerialID = *maybe__awebSocketSerialID;
            // Sentinel = 'awebSocketSerialID'
            if ((!(((&(reader__)))->ReadSentinel(1140524790)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            auto maybe__aData = IPC::ReadParam<nsCString>((&(reader__)));
            if (!maybe__aData) {
                FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& aData = *maybe__aData;
            // Sentinel = 'aData'
            if ((!(((&(reader__)))->ReadSentinel(90571228)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__aMessageType = IPC::ReadParam<uint16_t>((&(reader__)));
            if (!maybe__aMessageType) {
                FatalError("Error deserializing 'uint16_t'");
                return MsgValueError;

            }
            auto& aMessageType = *maybe__aMessageType;
            // Sentinel = 'aMessageType'
            if ((!(((&(reader__)))->ReadSentinel(512099529)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint16_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<WebSocketEventListenerChild*>(this))->RecvWebSocketMessageAvailable(std::move(awebSocketSerialID), std::move(aData), std::move(aMessageType));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PWebSocketEventListener::Msg_WebSocketClosed__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketEventListener", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketEventListenerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketEventListener::Msg_WebSocketClosed", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& awebSocketSerialID = *maybe__awebSocketSerialID;
            // Sentinel = 'awebSocketSerialID'
            if ((!(((&(reader__)))->ReadSentinel(1140524790)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            auto maybe__aWasClean = IPC::ReadParam<bool>((&(reader__)));
            if (!maybe__aWasClean) {
                FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& aWasClean = *maybe__aWasClean;
            // Sentinel = 'aWasClean'
            if ((!(((&(reader__)))->ReadSentinel(283181936)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            auto maybe__aCode = IPC::ReadParam<uint16_t>((&(reader__)));
            if (!maybe__aCode) {
                FatalError("Error deserializing 'uint16_t'");
                return MsgValueError;

            }
            auto& aCode = *maybe__aCode;
            // Sentinel = 'aCode'
            if ((!(((&(reader__)))->ReadSentinel(91226589)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint16_t'");
                return MsgValueError;
            }
            auto maybe__aReason = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aReason) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aReason = *maybe__aReason;
            // Sentinel = 'aReason'
            if ((!(((&(reader__)))->ReadSentinel(180093642)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<WebSocketEventListenerChild*>(this))->RecvWebSocketClosed(std::move(awebSocketSerialID), std::move(aWasClean), std::move(aCode), std::move(aReason));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PWebSocketEventListener::Msg_FrameReceived__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketEventListener", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketEventListenerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketEventListener::Msg_FrameReceived", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aWebSocketSerialID = *maybe__aWebSocketSerialID;
            // Sentinel = 'aWebSocketSerialID'
            if ((!(((&(reader__)))->ReadSentinel(1104873174)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            auto maybe__aFrameData = IPC::ReadParam<WebSocketFrameData>((&(reader__)));
            if (!maybe__aFrameData) {
                FatalError("Error deserializing 'WebSocketFrameData'");
                return MsgValueError;

            }
            auto& aFrameData = *maybe__aFrameData;
            // Sentinel = 'aFrameData'
            if ((!(((&(reader__)))->ReadSentinel(344196039)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'WebSocketFrameData'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<WebSocketEventListenerChild*>(this))->RecvFrameReceived(std::move(aWebSocketSerialID), std::move(aFrameData));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PWebSocketEventListener::Msg_FrameSent__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketEventListener", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketEventListenerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketEventListener::Msg_FrameSent", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aWebSocketSerialID = *maybe__aWebSocketSerialID;
            // Sentinel = 'aWebSocketSerialID'
            if ((!(((&(reader__)))->ReadSentinel(1104873174)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            auto maybe__aFrameData = IPC::ReadParam<WebSocketFrameData>((&(reader__)));
            if (!maybe__aFrameData) {
                FatalError("Error deserializing 'WebSocketFrameData'");
                return MsgValueError;

            }
            auto& aFrameData = *maybe__aFrameData;
            // Sentinel = 'aFrameData'
            if ((!(((&(reader__)))->ReadSentinel(344196039)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'WebSocketFrameData'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<WebSocketEventListenerChild*>(this))->RecvFrameSent(std::move(aWebSocketSerialID), std::move(aFrameData));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PWebSocketEventListener::Msg___delete____ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketEventListener", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketEventListenerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketEventListener::Msg___delete__", OTHER);

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


            this->ActorDisconnected(Deletion);

            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

auto PWebSocketEventListenerChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PWebSocketEventListenerChild::Result
{
    return MsgNotKnown;
}



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

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

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

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

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

} // namespace IPC
