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


#include "mozilla/dom/PBackgroundLSSnapshotChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/dom/localstorage/SerializationHelpers.h"

#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/dom/PBackgroundLSDatabaseChild.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 {


auto PBackgroundLSSnapshotChild::Recv__delete__() -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

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

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

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

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

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

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

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

auto PBackgroundLSSnapshotChild::SendDeleteMe() -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundLSSnapshot::Msg_DeleteMe(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PBackgroundLSSnapshotChild::SendAsyncCheckpoint(mozilla::Span<LSWriteInfo const> writeInfos) -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundLSSnapshot::Msg_AsyncCheckpoint(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PBackgroundLSSnapshotChild::SendAsyncCheckpointAndNotify(mozilla::Span<LSWriteAndNotifyInfo const> writeAndNotifyInfos) -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundLSSnapshot::Msg_AsyncCheckpointAndNotify(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PBackgroundLSSnapshotChild::SendSyncCheckpoint(mozilla::Span<LSWriteInfo const> writeInfos) -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundLSSnapshot::Msg_SyncCheckpoint(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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

    UniquePtr<Message> reply__;

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

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

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

    return true;
}

auto PBackgroundLSSnapshotChild::SendSyncCheckpointAndNotify(mozilla::Span<LSWriteAndNotifyInfo const> writeAndNotifyInfos) -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundLSSnapshot::Msg_SyncCheckpointAndNotify(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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

    UniquePtr<Message> reply__;

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

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

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

    return true;
}

auto PBackgroundLSSnapshotChild::SendAsyncFinish() -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundLSSnapshot::Msg_AsyncFinish(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PBackgroundLSSnapshotChild::SendSyncFinish() -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundLSSnapshot::Msg_SyncFinish(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};


    UniquePtr<Message> reply__;

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

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

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

    return true;
}

auto PBackgroundLSSnapshotChild::SendLoaded() -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundLSSnapshot::Msg_Loaded(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PBackgroundLSSnapshotChild::SendLoadValueAndMoreItems(
        const nsAString& key,
        LSValue* value,
        nsTArray<LSItemInfo>* itemInfos) -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundLSSnapshot::Msg_LoadValueAndMoreItems(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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

    UniquePtr<Message> reply__;

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

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

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

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

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

    }
    auto& value__reply = *maybe__value__reply;
    // Sentinel = 'value'
    if ((!(((&(reader__)))->ReadSentinel(107610654)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'LSValue'");
        return false;
    }
    auto maybe__itemInfos__reply = IPC::ReadParam<nsTArray<LSItemInfo>>((&(reader__)));
    if (!maybe__itemInfos__reply) {
        FatalError("Error deserializing 'LSItemInfo[]'");
        return false;

    }
    auto& itemInfos__reply = *maybe__itemInfos__reply;
    // Sentinel = 'itemInfos'
    if ((!(((&(reader__)))->ReadSentinel(307430319)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'LSItemInfo[]'");
        return false;
    }
    (*(value)) = std::move(value__reply);
    (*(itemInfos)) = std::move(itemInfos__reply);
    reader__.EndRead();

    return true;
}

auto PBackgroundLSSnapshotChild::SendLoadKeys(nsTArray<nsString>* keys) -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundLSSnapshot::Msg_LoadKeys(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};


    UniquePtr<Message> reply__;

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

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

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

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

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

    }
    auto& keys__reply = *maybe__keys__reply;
    // Sentinel = 'keys'
    if ((!(((&(reader__)))->ReadSentinel(71565757)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'nsString[]'");
        return false;
    }
    (*(keys)) = std::move(keys__reply);
    reader__.EndRead();

    return true;
}

auto PBackgroundLSSnapshotChild::SendIncreasePeakUsage(
        const int64_t& minSize,
        int64_t* size) -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundLSSnapshot::Msg_IncreasePeakUsage(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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

    UniquePtr<Message> reply__;

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

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

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

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

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

    }
    auto& size__reply = *maybe__size__reply;
    // Sentinel = 'size'
    if ((!(((&(reader__)))->ReadSentinel(73662908)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'int64_t'");
        return false;
    }
    (*(size)) = std::move(size__reply);
    reader__.EndRead();

    return true;
}

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

auto PBackgroundLSSnapshotChild::OnMessageReceived(const Message& msg__) -> PBackgroundLSSnapshotChild::Result
{
    if (!CanSend()) {
        if (mozilla::ipc::LoggingEnabledFor("PBackgroundLSSnapshot", mozilla::ipc::ChildSide)) {
            mozilla::ipc::LogMessageForProtocol(
                "PBackgroundLSSnapshotChild",
                this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                "Ignored message for dead actor",
                (&(msg__))->type(),
                mozilla::ipc::MessageDirection::eSending);
        }
        return MsgProcessed;

    }
    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 PBackgroundLSSnapshot::Msg_MarkDirty__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PBackgroundLSSnapshot", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PBackgroundLSSnapshotChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PBackgroundLSSnapshot::Msg_MarkDirty", OTHER);

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

            return MsgProcessed;
        }
    case PBackgroundLSSnapshot::Msg___delete____ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PBackgroundLSSnapshot", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PBackgroundLSSnapshotChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PBackgroundLSSnapshot::Msg___delete__", OTHER);

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


            this->ActorDisconnected(Deletion);

            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

auto PBackgroundLSSnapshotChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PBackgroundLSSnapshotChild::Result
{
    if (!CanSend()) {
        return MsgDropped;

    }
    return MsgNotKnown;
}



} // namespace dom
} // namespace mozilla
