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


#include "mozilla/net/PSocketProcessBackgroundChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/net/SocketProcessBackgroundChild.h"

#include "mozilla/psm/PVerifySSLServerCertChild.h"
#include "mozilla/psm/PSelectTLSClientAuthCertChild.h"
#include "mozilla/psm/PIPCClientCertsChild.h"
#include "mozilla/net/PWebSocketConnectionChild.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 PSocketProcessBackgroundChild::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

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

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

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

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

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

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

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

auto PSocketProcessBackgroundChild::SendInitVerifySSLServerCert(
        Endpoint<::mozilla::psm::PVerifySSLServerCertParent>&& aEndpoint,
        mozilla::Span<ByteArray const> aPeerCertChain,
        const nsACString& aHostName,
        const int32_t& aPort,
        const OriginAttributes& aOriginAttributes,
        const mozilla::Maybe<ByteArray>& aStapledOCSPResponse,
        const mozilla::Maybe<ByteArray>& aSctsFromTLSExtension,
        const mozilla::Maybe<DelegatedCredentialInfoArg>& aDcInfo,
        const uint32_t& aProviderFlags,
        const uint32_t& aCertVerifierFlags) -> bool
{
    UniquePtr<IPC::Message> msg__ = PSocketProcessBackground::Msg_InitVerifySSLServerCert(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), std::move(aEndpoint));
    // Sentinel = 'aEndpoint'
    ((&(writer__)))->WriteSentinel(292225955);
    IPC::WriteParam((&(writer__)), aPeerCertChain);
    // Sentinel = 'aPeerCertChain'
    ((&(writer__)))->WriteSentinel(664667487);
    IPC::WriteParam((&(writer__)), aHostName);
    // Sentinel = 'aHostName'
    ((&(writer__)))->WriteSentinel(290128769);
    IPC::WriteParam((&(writer__)), aPort);
    // Sentinel = 'aPort'
    ((&(writer__)))->WriteSentinel(97452551);
    IPC::WriteParam((&(writer__)), aOriginAttributes);
    // Sentinel = 'aOriginAttributes'
    ((&(writer__)))->WriteSentinel(1021839089);
    IPC::WriteParam((&(writer__)), aStapledOCSPResponse);
    // Sentinel = 'aStapledOCSPResponse'
    ((&(writer__)))->WriteSentinel(1333856179);
    IPC::WriteParam((&(writer__)), aSctsFromTLSExtension);
    // Sentinel = 'aSctsFromTLSExtension'
    ((&(writer__)))->WriteSentinel(1492453443);
    IPC::WriteParam((&(writer__)), aDcInfo);
    // Sentinel = 'aDcInfo'
    ((&(writer__)))->WriteSentinel(165544597);
    IPC::WriteParam((&(writer__)), aProviderFlags);
    // Sentinel = 'aProviderFlags'
    ((&(writer__)))->WriteSentinel(701957530);
    IPC::WriteParam((&(writer__)), aCertVerifierFlags);
    // Sentinel = 'aCertVerifierFlags'
    ((&(writer__)))->WriteSentinel(1116079897);


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

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

auto PSocketProcessBackgroundChild::SendInitSelectTLSClientAuthCert(
        Endpoint<::mozilla::psm::PSelectTLSClientAuthCertParent>&& aEndpoint,
        const nsACString& aHostName,
        const OriginAttributes& aOriginAttributes,
        const int32_t& aPort,
        const uint32_t& aProviderFlags,
        const uint32_t& aProviderTlsFlags,
        const ByteArray& aServerCertBytes,
        mozilla::Span<ByteArray const> aCANames,
        const uint64_t& aBrowserId) -> bool
{
    UniquePtr<IPC::Message> msg__ = PSocketProcessBackground::Msg_InitSelectTLSClientAuthCert(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), std::move(aEndpoint));
    // Sentinel = 'aEndpoint'
    ((&(writer__)))->WriteSentinel(292225955);
    IPC::WriteParam((&(writer__)), aHostName);
    // Sentinel = 'aHostName'
    ((&(writer__)))->WriteSentinel(290128769);
    IPC::WriteParam((&(writer__)), aOriginAttributes);
    // Sentinel = 'aOriginAttributes'
    ((&(writer__)))->WriteSentinel(1021839089);
    IPC::WriteParam((&(writer__)), aPort);
    // Sentinel = 'aPort'
    ((&(writer__)))->WriteSentinel(97452551);
    IPC::WriteParam((&(writer__)), aProviderFlags);
    // Sentinel = 'aProviderFlags'
    ((&(writer__)))->WriteSentinel(701957530);
    IPC::WriteParam((&(writer__)), aProviderTlsFlags);
    // Sentinel = 'aProviderTlsFlags'
    ((&(writer__)))->WriteSentinel(1025771213);
    IPC::WriteParam((&(writer__)), aServerCertBytes);
    // Sentinel = 'aServerCertBytes'
    ((&(writer__)))->WriteSentinel(901777006);
    IPC::WriteParam((&(writer__)), aCANames);
    // Sentinel = 'aCANames'
    ((&(writer__)))->WriteSentinel(200868570);
    IPC::WriteParam((&(writer__)), aBrowserId);
    // Sentinel = 'aBrowserId'
    ((&(writer__)))->WriteSentinel(363332595);


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

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

auto PSocketProcessBackgroundChild::SendInitIPCClientCerts(Endpoint<::mozilla::psm::PIPCClientCertsParent>&& aEndpoint) -> bool
{
    UniquePtr<IPC::Message> msg__ = PSocketProcessBackground::Msg_InitIPCClientCerts(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), std::move(aEndpoint));
    // Sentinel = 'aEndpoint'
    ((&(writer__)))->WriteSentinel(292225955);


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

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

auto PSocketProcessBackgroundChild::SendInitWebSocketConnection(
        Endpoint<::mozilla::net::PWebSocketConnectionParent>&& aEndpoint,
        const uint32_t& aListenerId) -> bool
{
    UniquePtr<IPC::Message> msg__ = PSocketProcessBackground::Msg_InitWebSocketConnection(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), std::move(aEndpoint));
    // Sentinel = 'aEndpoint'
    ((&(writer__)))->WriteSentinel(292225955);
    IPC::WriteParam((&(writer__)), aListenerId);
    // Sentinel = 'aListenerId'
    ((&(writer__)))->WriteSentinel(436667477);


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

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

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

auto PSocketProcessBackgroundChild::OnMessageReceived(const Message& msg__) -> PSocketProcessBackgroundChild::Result
{
    if (!CanSend()) {
        if (mozilla::ipc::LoggingEnabledFor("PSocketProcessBackground", mozilla::ipc::ChildSide)) {
            mozilla::ipc::LogMessageForProtocol(
                "PSocketProcessBackgroundChild",
                this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                "Ignored message for dead actor",
                (&(msg__))->type(),
                mozilla::ipc::MessageDirection::eSending);
        }
        return MsgProcessed;

    }
    switch (msg__.type()) {
    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 PSocketProcessBackgroundChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PSocketProcessBackgroundChild::Result
{
    if (!CanSend()) {
        return MsgDropped;

    }
    return MsgNotKnown;
}



} // namespace net
} // namespace mozilla
