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


#include "mozilla/dom/PBackgroundSessionStorageCacheChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/dom/DomSecurityIPCUtils.h"
#include "mozilla/ipc/IPCCore.h"

#include "mozilla/ipc/PBackgroundChild.h"
#include "mozilla/dom/PBackgroundSessionStorageManagerChild.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 PBackgroundSessionStorageCacheChild::Recv__delete__() -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

MOZ_IMPLICIT PBackgroundSessionStorageCacheChild::PBackgroundSessionStorageCacheChild() :
    mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PBackgroundSessionStorageCacheChild);
}

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

auto PBackgroundSessionStorageCacheChild::ActorAlloc() -> void
{
    AddRef();
}

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

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

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

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

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

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

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

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



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

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

auto PBackgroundSessionStorageCacheChild::SendLoad(nsTArray<SSSetItemInfo>* aData) -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundSessionStorageCache::Msg_Load(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};


    UniquePtr<Message> reply__;

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

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

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

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

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

    }
    auto& aData__reply = *maybe__aData__reply;
    // Sentinel = 'aData'
    if ((!(((&(reader__)))->ReadSentinel(90571228)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'SSSetItemInfo[]'");
        return false;
    }
    (*(aData)) = std::move(aData__reply);
    reader__.EndRead();

    return true;
}

auto PBackgroundSessionStorageCacheChild::SendCheckpoint(mozilla::Span<SSWriteInfo const> aWriteInfos) -> bool
{
    UniquePtr<IPC::Message> msg__ = PBackgroundSessionStorageCache::Msg_Checkpoint(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

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

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



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

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

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

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

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

} // namespace IPC
