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


#include "mozilla/net/PWebSocketConnectionParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ipc/TransportSecurityInfoUtils.h"
#include "mozilla/net/WebSocketConnectionParent.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 PWebSocketConnectionParent::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

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

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

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

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

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

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

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

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

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


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

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

auto PWebSocketConnectionParent::SendStartReading() -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebSocketConnection::Msg_StartReading(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PWebSocketConnectionParent::SendDrainSocketData() -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebSocketConnection::Msg_DrainSocketData(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aSecurityInfo = *maybe__aSecurityInfo;
            // Sentinel = 'aSecurityInfo'
            if ((!(((&(reader__)))->ReadSentinel(610075974)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsITransportSecurityInfo'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<WebSocketConnectionParent*>(this))->RecvOnTransportAvailable(aSecurityInfo);
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PWebSocketConnection::Msg_OnError__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketConnection", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketConnectionParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketConnection::Msg_OnError", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aStatus = *maybe__aStatus;
            // Sentinel = 'aStatus'
            if ((!(((&(reader__)))->ReadSentinel(186712806)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsresult'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<WebSocketConnectionParent*>(this))->RecvOnError(std::move(aStatus));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PWebSocketConnection::Msg_OnTCPClosed__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketConnection", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketConnectionParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketConnection::Msg_OnTCPClosed", OTHER);

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

            return MsgProcessed;
        }
    case PWebSocketConnection::Msg_OnDataReceived__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketConnection", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketConnectionParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketConnection::Msg_OnDataReceived", 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<WebSocketConnectionParent*>(this))->RecvOnDataReceived(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_OnUpgradeFailed__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebSocketConnection", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebSocketConnectionParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebSocketConnection::Msg_OnUpgradeFailed", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

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

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



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

} // namespace IPC
