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


#include "mozilla/psm/PIPCClientCertsParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/psm/IPCClientCertsParent.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 PIPCClientCertsParent::Recv__delete__() -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

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

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

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

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

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

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

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

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

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

auto PIPCClientCertsParent::OnMessageReceived(const Message& msg__) -> PIPCClientCertsParent::Result
{
    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 PIPCClientCertsParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PIPCClientCertsParent::Result
{
    switch (msg__.type()) {
    case PIPCClientCerts::Msg_FindObjects__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PIPCClientCerts", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIPCClientCertsParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PIPCClientCerts::Msg_FindObjects", OTHER);

            mozilla::ipc::ActorId id__ = MSG_ROUTING_CONTROL;
            nsTArray<IPCClientCertObject> aObjects{};
            mozilla::ipc::IPCResult __ok = (static_cast<IPCClientCertsParent*>(this))->RecvFindObjects((&(aObjects)));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            reply__ = PIPCClientCerts::Reply_FindObjects(id__);
            IPC::MessageWriter writer__{
                    (*(reply__)),
                    this};

            IPC::WriteParam((&(writer__)), aObjects);
            // Sentinel = 'aObjects'
            ((&(writer__)))->WriteSentinel(229573420);
            if (mozilla::ipc::LoggingEnabledFor("PIPCClientCerts", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIPCClientCertsParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Sending reply ",
                    reply__->type(),
                    mozilla::ipc::MessageDirection::eSending);
            }
            return MsgProcessed;
        }
    case PIPCClientCerts::Msg_Sign__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PIPCClientCerts", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIPCClientCertsParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PIPCClientCerts::Msg_Sign", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aCert = *maybe__aCert;
            // Sentinel = 'aCert'
            if ((!(((&(reader__)))->ReadSentinel(92078576)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ByteArray'");
                return MsgValueError;
            }
            auto maybe__aData = IPC::ReadParam<ByteArray>((&(reader__)));
            if (!maybe__aData) {
                FatalError("Error deserializing 'ByteArray'");
                return MsgValueError;

            }
            auto& aData = *maybe__aData;
            // Sentinel = 'aData'
            if ((!(((&(reader__)))->ReadSentinel(90571228)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ByteArray'");
                return MsgValueError;
            }
            auto maybe__aParams = IPC::ReadParam<ByteArray>((&(reader__)));
            if (!maybe__aParams) {
                FatalError("Error deserializing 'ByteArray'");
                return MsgValueError;

            }
            auto& aParams = *maybe__aParams;
            // Sentinel = 'aParams'
            if ((!(((&(reader__)))->ReadSentinel(178979526)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ByteArray'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = MSG_ROUTING_CONTROL;
            ByteArray aSignature{};
            mozilla::ipc::IPCResult __ok = (static_cast<IPCClientCertsParent*>(this))->RecvSign(std::move(aCert), std::move(aData), std::move(aParams), (&(aSignature)));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            reply__ = PIPCClientCerts::Reply_Sign(id__);
            IPC::MessageWriter writer__{
                    (*(reply__)),
                    this};

            IPC::WriteParam((&(writer__)), aSignature);
            // Sentinel = 'aSignature'
            ((&(writer__)))->WriteSentinel(365495316);
            if (mozilla::ipc::LoggingEnabledFor("PIPCClientCerts", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIPCClientCertsParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Sending reply ",
                    reply__->type(),
                    mozilla::ipc::MessageDirection::eSending);
            }
            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}



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

} // namespace IPC
