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


#include "mozilla/psm/PIPCClientCertsChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/psm/IPCClientCertsChild.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 psm {


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

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

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

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

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

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

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

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

auto PIPCClientCertsChild::SendFindObjects(nsTArray<IPCClientCertObject>* aObjects) -> bool
{
    UniquePtr<IPC::Message> msg__ = PIPCClientCerts::Msg_FindObjects(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};


    UniquePtr<Message> reply__;

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

    bool sendok__ = false;
    {
        AUTO_PROFILER_MARKER("PIPCClientCerts::Msg_FindObjects", IPC);
        sendok__ = ChannelSend(std::move(msg__), (&(reply__)));
    }
    if ((!(sendok__))) {
        return false;
    }

    if (mozilla::ipc::LoggingEnabledFor("PIPCClientCerts", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PIPCClientCertsChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Received reply ",
            reply__->type(),
            mozilla::ipc::MessageDirection::eReceiving);
    }

    IPC::MessageReader reader__{
            (*(reply__)),
            this};

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

    }
    auto& aObjects__reply = *maybe__aObjects__reply;
    // Sentinel = 'aObjects'
    if ((!(((&(reader__)))->ReadSentinel(229573420)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'IPCClientCertObject[]'");
        return false;
    }
    (*(aObjects)) = std::move(aObjects__reply);
    reader__.EndRead();

    return true;
}

auto PIPCClientCertsChild::SendSign(
        const ByteArray& aCert,
        const ByteArray& aData,
        const ByteArray& aParams,
        ByteArray* aSignature) -> bool
{
    UniquePtr<IPC::Message> msg__ = PIPCClientCerts::Msg_Sign(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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

    UniquePtr<Message> reply__;

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

    bool sendok__ = false;
    {
        AUTO_PROFILER_MARKER("PIPCClientCerts::Msg_Sign", IPC);
        sendok__ = ChannelSend(std::move(msg__), (&(reply__)));
    }
    if ((!(sendok__))) {
        return false;
    }

    if (mozilla::ipc::LoggingEnabledFor("PIPCClientCerts", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PIPCClientCertsChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Received reply ",
            reply__->type(),
            mozilla::ipc::MessageDirection::eReceiving);
    }

    IPC::MessageReader reader__{
            (*(reply__)),
            this};

    auto maybe__aSignature__reply = IPC::ReadParam<ByteArray>((&(reader__)));
    if (!maybe__aSignature__reply) {
        FatalError("Error deserializing 'ByteArray'");
        return false;

    }
    auto& aSignature__reply = *maybe__aSignature__reply;
    // Sentinel = 'aSignature'
    if ((!(((&(reader__)))->ReadSentinel(365495316)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'ByteArray'");
        return false;
    }
    (*(aSignature)) = std::move(aSignature__reply);
    reader__.EndRead();

    return true;
}

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

auto PIPCClientCertsChild::OnMessageReceived(const Message& msg__) -> PIPCClientCertsChild::Result
{
    switch (msg__.type()) {
    case PIPCClientCerts::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 PIPCClientCertsChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PIPCClientCertsChild::Result
{
    return MsgNotKnown;
}



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

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

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

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

        return {};
    }
    return static_cast<::mozilla::psm::PIPCClientCertsChild*>(actor);
}

} // namespace IPC
