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


#include "mozilla/dom/quota/PRemoteQuotaObjectChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/dom/quota/RemoteQuotaObjectChild.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 PRemoteQuotaObjectChild::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

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

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

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

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

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

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

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

auto PRemoteQuotaObjectChild::SendMaybeUpdateSize(
        const int64_t& size,
        const bool& truncate,
        bool* result) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemoteQuotaObject::Msg_MaybeUpdateSize(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), size);
    // Sentinel = 'size'
    ((&(writer__)))->WriteSentinel(73662908);
    IPC::WriteParam((&(writer__)), truncate);
    // Sentinel = 'truncate'
    ((&(writer__)))->WriteSentinel(262538087);

    UniquePtr<Message> reply__;

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

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

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

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

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

    }
    auto& result__reply = *maybe__result__reply;
    // Sentinel = 'result'
    if ((!(((&(reader__)))->ReadSentinel(153223840)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
        return false;
    }
    (*(result)) = std::move(result__reply);
    reader__.EndRead();

    return true;
}

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

auto PRemoteQuotaObjectChild::OnMessageReceived(const Message& msg__) -> PRemoteQuotaObjectChild::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 PRemoteQuotaObjectChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PRemoteQuotaObjectChild::Result
{
    return MsgNotKnown;
}



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

} // namespace IPC
