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


#include "mozilla/net/PWebrtcTCPSocketChild.h"
#include "mozilla/ProfilerLabels.h"

#include "mozilla/net/PNeckoChild.h"
#include "mozilla/net/PSocketProcessChild.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 PWebrtcTCPSocketChild::Recv__delete__() -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

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

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

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

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

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

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

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

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

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

auto PWebrtcTCPSocketChild::SendAsyncOpen(
        const nsACString& aHost,
        const int32_t& aPort,
        const nsACString& aLocalAddress,
        const int32_t& aLocalPort,
        const bool& aUseTls,
        const mozilla::Maybe<WebrtcProxyConfig>& aProxyConfig) -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebrtcTCPSocket::Msg_AsyncOpen(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aHost);
    // Sentinel = 'aHost'
    ((&(writer__)))->WriteSentinel(95486464);
    IPC::WriteParam((&(writer__)), aPort);
    // Sentinel = 'aPort'
    ((&(writer__)))->WriteSentinel(97452551);
    IPC::WriteParam((&(writer__)), aLocalAddress);
    // Sentinel = 'aLocalAddress'
    ((&(writer__)))->WriteSentinel(576259347);
    IPC::WriteParam((&(writer__)), aLocalPort);
    // Sentinel = 'aLocalPort'
    ((&(writer__)))->WriteSentinel(351536114);
    IPC::WriteParam((&(writer__)), aUseTls);
    // Sentinel = 'aUseTls'
    ((&(writer__)))->WriteSentinel(180748994);
    IPC::WriteParam((&(writer__)), aProxyConfig);
    // Sentinel = 'aProxyConfig'
    ((&(writer__)))->WriteSentinel(525468890);


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

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

auto PWebrtcTCPSocketChild::SendWrite(mozilla::Span<uint8_t const> aWriteData) -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebrtcTCPSocket::Msg_Write(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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



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

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

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

auto PWebrtcTCPSocketChild::OnMessageReceived(const Message& msg__) -> PWebrtcTCPSocketChild::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 PWebrtcTCPSocket::Msg_OnClose__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebrtcTCPSocket", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebrtcTCPSocketChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebrtcTCPSocket::Msg_OnClose", 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 = (this)->RecvOnClose(std::move(aReason));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PWebrtcTCPSocket::Msg_OnConnected__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebrtcTCPSocket", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebrtcTCPSocketChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebrtcTCPSocket::Msg_OnConnected", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

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

            return MsgProcessed;
        }
    case PWebrtcTCPSocket::Msg_OnRead__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebrtcTCPSocket", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebrtcTCPSocketChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebrtcTCPSocket::Msg_OnRead", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

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

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

            mozilla::ipc::IPCResult __ok = (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 PWebrtcTCPSocketChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PWebrtcTCPSocketChild::Result
{
    return MsgNotKnown;
}



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

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

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

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

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

} // namespace IPC
