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


#include "mozilla/net/PWebSocketConnectionChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ipc/TransportSecurityInfoUtils.h"
#include "mozilla/net/WebSocketConnectionChild.h"
#include "nsITransportSecurityInfo.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 PWebSocketConnectionChild::Recv__delete__() -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

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

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

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

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

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

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

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

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

auto PWebSocketConnectionChild::SendOnTransportAvailable(nsITransportSecurityInfo* aSecurityInfo) -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebSocketConnection::Msg_OnTransportAvailable(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PWebSocketConnectionChild::SendOnError(const nsresult& aStatus) -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebSocketConnection::Msg_OnError(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PWebSocketConnectionChild::SendOnTCPClosed() -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebSocketConnection::Msg_OnTCPClosed(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PWebSocketConnectionChild::SendOnDataReceived(mozilla::Span<uint8_t const> aData) -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebSocketConnection::Msg_OnDataReceived(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PWebSocketConnectionChild::SendOnUpgradeFailed(const nsresult& aReason) -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebSocketConnection::Msg_OnUpgradeFailed(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__aData = IPC::ReadParam<nsTArray<uint8_t>>((&(reader__)));
            if (!maybe__aData) {
                FatalError("Error deserializing 'uint8_t[]'");
                return MsgValueError;

            }
            auto& aData = *maybe__aData;
            // Sentinel = 'aData'
            if ((!(((&(reader__)))->ReadSentinel(90571228)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint8_t[]'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<WebSocketConnectionChild*>(this))->RecvWriteOutputData(std::move(aData));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PWebSocketConnection::Msg_StartReading__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketConnection", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketConnectionChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketConnection::Msg_StartReading", OTHER);

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

            return MsgProcessed;
        }
    case PWebSocketConnection::Msg_DrainSocketData__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketConnection", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketConnectionChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketConnection::Msg_DrainSocketData", OTHER);

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



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

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

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

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

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

} // namespace IPC
