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


#include "mozilla/dom/PSessionStoreParent.h"
#include "mozilla/GfxMessageUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/SessionStoreMessageUtils.h"
#include "mozilla/dom/SessionStoreParent.h"
#include "nsPoint.h"

#include "mozilla/dom/PBrowserParent.h"
#include "mozilla/dom/PInProcessParent.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 {


MOZ_IMPLICIT PSessionStoreParent::PSessionStoreParent() :
    mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PSessionStoreParent);
}

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

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

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

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

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

auto PSessionStoreParent::RejectPendingResponses(ResponseRejectReason aReason) -> void
{
    mAsyncCallbacks.RejectPendingResponses(aReason);
}

auto PSessionStoreParent::SendFlushTabState(
        mozilla::ipc::ResolveCallback<bool>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PSessionStore::Msg_FlushTabState(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



    if (mozilla::ipc::LoggingEnabledFor("PSessionStore", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PSessionStoreParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PSessionStore::Msg_FlushTabState", OTHER);

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PSessionStore::Reply_FlushTabState__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__aHadContext = IPC::ReadParam<bool>(aReader);
            if (!maybe__aHadContext) {
                (aReader)->FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& aHadContext = *maybe__aHadContext;
            // Sentinel = 'aHadContext'
            if ((!((aReader)->ReadSentinel(411501652)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(aHadContext));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PSessionStoreParent::SendFlushTabState() -> RefPtr<FlushTabStatePromise>
{
    RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendFlushTabState([promise__](bool&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

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


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

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

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

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

auto PSessionStoreParent::OnMessageReceived(const Message& msg__) -> PSessionStoreParent::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 PSessionStore::Msg_SessionStoreUpdate__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PSessionStore", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PSessionStoreParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PSessionStore::Msg_SessionStoreUpdate", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aDocShellCaps = *maybe__aDocShellCaps;
            // Sentinel = 'aDocShellCaps'
            if ((!(((&(reader__)))->ReadSentinel(568394999)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString?'");
                return MsgValueError;
            }
            auto maybe__aPrivateMode = IPC::ReadParam<mozilla::Maybe<bool>>((&(reader__)));
            if (!maybe__aPrivateMode) {
                FatalError("Error deserializing 'bool?'");
                return MsgValueError;

            }
            auto& aPrivateMode = *maybe__aPrivateMode;
            // Sentinel = 'aPrivateMode'
            if ((!(((&(reader__)))->ReadSentinel(518194370)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool?'");
                return MsgValueError;
            }
            auto maybe__aZoom = IPC::ReadParam<MaybeSessionStoreZoom>((&(reader__)));
            if (!maybe__aZoom) {
                FatalError("Error deserializing 'MaybeSessionStoreZoom'");
                return MsgValueError;

            }
            auto& aZoom = *maybe__aZoom;
            // Sentinel = 'aZoom'
            if ((!(((&(reader__)))->ReadSentinel(99222023)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'MaybeSessionStoreZoom'");
                return MsgValueError;
            }
            auto maybe__aNeedCollectSHistory = IPC::ReadParam<bool>((&(reader__)));
            if (!maybe__aNeedCollectSHistory) {
                FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& aNeedCollectSHistory = *maybe__aNeedCollectSHistory;
            // Sentinel = 'aNeedCollectSHistory'
            if ((!(((&(reader__)))->ReadSentinel(1343490025)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            auto maybe__aEpoch = IPC::ReadParam<uint32_t>((&(reader__)));
            if (!maybe__aEpoch) {
                FatalError("Error deserializing 'uint32_t'");
                return MsgValueError;

            }
            auto& aEpoch = *maybe__aEpoch;
            // Sentinel = 'aEpoch'
            if ((!(((&(reader__)))->ReadSentinel(132121169)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<SessionStoreParent*>(this))->RecvSessionStoreUpdate(std::move(aDocShellCaps), std::move(aPrivateMode), std::move(aZoom), std::move(aNeedCollectSHistory), std::move(aEpoch));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PSessionStore::Msg_IncrementalSessionStoreUpdate__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PSessionStore", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PSessionStoreParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PSessionStore::Msg_IncrementalSessionStoreUpdate", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aBrowsingContext = *maybe__aBrowsingContext;
            // Sentinel = 'aBrowsingContext'
            if ((!(((&(reader__)))->ReadSentinel(915015314)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'MaybeDiscardedBrowsingContext'");
                return MsgValueError;
            }
            auto maybe__aFormData = IPC::ReadParam<mozilla::Maybe<FormData>>((&(reader__)));
            if (!maybe__aFormData) {
                FatalError("Error deserializing 'FormData?'");
                return MsgValueError;

            }
            auto& aFormData = *maybe__aFormData;
            // Sentinel = 'aFormData'
            if ((!(((&(reader__)))->ReadSentinel(284427120)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'FormData?'");
                return MsgValueError;
            }
            auto maybe__aScrollPosition = IPC::ReadParam<mozilla::Maybe<nsPoint>>((&(reader__)));
            if (!maybe__aScrollPosition) {
                FatalError("Error deserializing 'nsPoint?'");
                return MsgValueError;

            }
            auto& aScrollPosition = *maybe__aScrollPosition;
            // Sentinel = 'aScrollPosition'
            if ((!(((&(reader__)))->ReadSentinel(806290982)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsPoint?'");
                return MsgValueError;
            }
            auto maybe__aEpoch = IPC::ReadParam<uint32_t>((&(reader__)));
            if (!maybe__aEpoch) {
                FatalError("Error deserializing 'uint32_t'");
                return MsgValueError;

            }
            auto& aEpoch = *maybe__aEpoch;
            // Sentinel = 'aEpoch'
            if ((!(((&(reader__)))->ReadSentinel(132121169)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<SessionStoreParent*>(this))->RecvIncrementalSessionStoreUpdate(std::move(aBrowsingContext), std::move(aFormData), std::move(aScrollPosition), std::move(aEpoch));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PSessionStore::Msg_ResetSessionStore__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PSessionStore", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PSessionStoreParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PSessionStore::Msg_ResetSessionStore", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aBrowsingContext = *maybe__aBrowsingContext;
            // Sentinel = 'aBrowsingContext'
            if ((!(((&(reader__)))->ReadSentinel(915015314)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'MaybeDiscardedBrowsingContext'");
                return MsgValueError;
            }
            auto maybe__aEpoch = IPC::ReadParam<uint32_t>((&(reader__)));
            if (!maybe__aEpoch) {
                FatalError("Error deserializing 'uint32_t'");
                return MsgValueError;

            }
            auto& aEpoch = *maybe__aEpoch;
            // Sentinel = 'aEpoch'
            if ((!(((&(reader__)))->ReadSentinel(132121169)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<SessionStoreParent*>(this))->RecvResetSessionStore(std::move(aBrowsingContext), std::move(aEpoch));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PSessionStore::Reply_FlushTabState__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PSessionStore", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PSessionStoreParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PSessionStore::Msg_FlushTabState", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PSessionStore::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

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



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

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

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

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

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

} // namespace IPC
