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


#include "mozilla/gmp/PGMPStorageChild.h"
#include "GMPMessageUtils.h"
#include "GMPStorageChild.h"
#include "mozilla/ProfilerLabels.h"

#include "mozilla/gmp/PGMPChild.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 gmp {


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

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

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

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

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

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

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

auto PGMPStorageChild::Manager() const -> PGMPChild*
{
    return static_cast<PGMPChild*>(IProtocol::Manager());
}

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

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

auto PGMPStorageChild::SendOpen(const nsACString& aRecordName) -> bool
{
    UniquePtr<IPC::Message> msg__ = PGMPStorage::Msg_Open(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PGMPStorageChild::SendRead(const nsACString& aRecordName) -> bool
{
    UniquePtr<IPC::Message> msg__ = PGMPStorage::Msg_Read(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PGMPStorageChild::SendWrite(
        const nsACString& aRecordName,
        mozilla::Span<uint8_t const> aBytes) -> bool
{
    UniquePtr<IPC::Message> msg__ = PGMPStorage::Msg_Write(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aRecordName);
    // Sentinel = 'aRecordName'
    ((&(writer__)))->WriteSentinel(424805442);
    IPC::WriteParam((&(writer__)), aBytes);
    // Sentinel = 'aBytes'
    ((&(writer__)))->WriteSentinel(135463529);


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

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

auto PGMPStorageChild::SendClose(const nsACString& aRecordName) -> bool
{
    UniquePtr<IPC::Message> msg__ = PGMPStorage::Msg_Close(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PGMPStorageChild::Send__delete__(PGMPStorageChild* actor) -> bool
{
    if (!actor || !actor->CanSend()) {
        NS_WARNING("Attempt to __delete__ missing or closed actor");
        return false;
    }
    UniquePtr<IPC::Message> msg__ = PGMPStorage::Msg___delete__((actor)->Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            actor};


    if (mozilla::ipc::LoggingEnabledFor("PGMPStorage", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PGMPStorageChild",
            actor->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PGMPStorage::Msg___delete__", OTHER);

    bool sendok__ = (actor)->ChannelSend(std::move(msg__));

    actor->ActorDisconnected(Deletion);
    return sendok__;
}

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

auto PGMPStorageChild::OnMessageReceived(const Message& msg__) -> PGMPStorageChild::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 PGMPStorage::Msg_OpenComplete__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PGMPStorage", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PGMPStorageChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PGMPStorage::Msg_OpenComplete", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aRecordName = *maybe__aRecordName;
            // Sentinel = 'aRecordName'
            if ((!(((&(reader__)))->ReadSentinel(424805442)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__aStatus = IPC::ReadParam<GMPErr>((&(reader__)));
            if (!maybe__aStatus) {
                FatalError("Error deserializing 'GMPErr'");
                return MsgValueError;

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

            return MsgProcessed;
        }
    case PGMPStorage::Msg_ReadComplete__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PGMPStorage", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PGMPStorageChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PGMPStorage::Msg_ReadComplete", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aRecordName = *maybe__aRecordName;
            // Sentinel = 'aRecordName'
            if ((!(((&(reader__)))->ReadSentinel(424805442)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__aStatus = IPC::ReadParam<GMPErr>((&(reader__)));
            if (!maybe__aStatus) {
                FatalError("Error deserializing 'GMPErr'");
                return MsgValueError;

            }
            auto& aStatus = *maybe__aStatus;
            // Sentinel = 'aStatus'
            if ((!(((&(reader__)))->ReadSentinel(186712806)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'GMPErr'");
                return MsgValueError;
            }
            auto maybe__aBytes = IPC::ReadParam<nsTArray<uint8_t>>((&(reader__)));
            if (!maybe__aBytes) {
                FatalError("Error deserializing 'uint8_t[]'");
                return MsgValueError;

            }
            auto& aBytes = *maybe__aBytes;
            // Sentinel = 'aBytes'
            if ((!(((&(reader__)))->ReadSentinel(135463529)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint8_t[]'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<GMPStorageChild*>(this))->RecvReadComplete(std::move(aRecordName), std::move(aStatus), std::move(aBytes));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PGMPStorage::Msg_WriteComplete__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PGMPStorage", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PGMPStorageChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PGMPStorage::Msg_WriteComplete", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aRecordName = *maybe__aRecordName;
            // Sentinel = 'aRecordName'
            if ((!(((&(reader__)))->ReadSentinel(424805442)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__aStatus = IPC::ReadParam<GMPErr>((&(reader__)));
            if (!maybe__aStatus) {
                FatalError("Error deserializing 'GMPErr'");
                return MsgValueError;

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

            return MsgProcessed;
        }
    case PGMPStorage::Msg_Shutdown__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PGMPStorage", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PGMPStorageChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PGMPStorage::Msg_Shutdown", OTHER);

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

            return MsgProcessed;
        }
    case PGMPStorage::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

auto PGMPStorageChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PGMPStorageChild::Result
{
    return MsgNotKnown;
}



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

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

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

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

        return {};
    }
    return static_cast<::mozilla::gmp::PGMPStorageChild*>(actor);
}

} // namespace IPC
