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


#include "mozilla/dom/quota/PRemoteQuotaObjectParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/quota/RemoteQuotaObjectParent.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 dom {
namespace quota {


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

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

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

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

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

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

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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& size = *maybe__size;
            // Sentinel = 'size'
            if ((!(((&(reader__)))->ReadSentinel(73662908)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int64_t'");
                return MsgValueError;
            }
            auto maybe__truncate = IPC::ReadParam<bool>((&(reader__)));
            if (!maybe__truncate) {
                FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& truncate = *maybe__truncate;
            // Sentinel = 'truncate'
            if ((!(((&(reader__)))->ReadSentinel(262538087)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = MSG_ROUTING_CONTROL;
            bool result{};
            mozilla::ipc::IPCResult __ok = (static_cast<RemoteQuotaObjectParent*>(this))->RecvMaybeUpdateSize(std::move(size), std::move(truncate), (&(result)));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            reply__ = PRemoteQuotaObject::Reply_MaybeUpdateSize(id__);
            IPC::MessageWriter writer__{
                    (*(reply__)),
                    this};

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



} // namespace quota
} // namespace dom
} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::dom::quota::PRemoteQuotaObjectParent*>::Write(
        IPC::MessageWriter* aWriter,
        const paramType& aVar) -> void
{
    IPC::WriteParam(aWriter, static_cast<mozilla::ipc::IProtocol*>(aVar));
    // Sentinel = 'PRemoteQuotaObject'
    (aWriter)->WriteSentinel(1117325086);
}

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

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

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

        return {};
    }
    return static_cast<::mozilla::dom::quota::PRemoteQuotaObjectParent*>(actor);
}

} // namespace IPC
