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


#include "mozilla/PWebBrowserPersistDocumentChild.h"
#include "mozilla/AntiTrackingIPCUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/WebBrowserPersistDocumentChild.h"
#include "mozilla/dom/DomSecurityIPCUtils.h"
#include "mozilla/dom/FeaturePolicyUtils.h"
#include "mozilla/dom/FetchIPCTypes.h"
#include "mozilla/dom/NavigationAPIIPCUtils.h"
#include "mozilla/dom/PropertyBagUtils.h"
#include "mozilla/dom/ReferrerInfoUtils.h"
#include "mozilla/dom/SessionHistoryEntry.h"
#include "mozilla/ipc/IPCCore.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/net/CacheInfoIPCTypes.h"
#include "mozilla/net/ClassOfService.h"
#include "nsDOMNavigationTiming.h"
#include "nsDocShellLoadState.h"
#include "nsHttp.h"
#include "nsHttpResponseHead.h"
#include "nsIPropertyBag2.h"
#include "nsIReferrerInfo.h"

#include "mozilla/dom/PContentChild.h"
#include "mozilla/PWebBrowserPersistResourcesChild.h"
#include "mozilla/PWebBrowserPersistSerializeChild.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 {


auto PWebBrowserPersistDocumentChild::RecvPWebBrowserPersistResourcesConstructor(PWebBrowserPersistResourcesChild* actor) -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

auto PWebBrowserPersistDocumentChild::RecvPWebBrowserPersistSerializeConstructor(
        PWebBrowserPersistSerializeChild* actor,
        const WebBrowserPersistURIMap& aMap,
        const nsACString& aRequestedContentType,
        const uint32_t& aEncoderFlags,
        const uint32_t& aWrapColumn) -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

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

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

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

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

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

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

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

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

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

auto PWebBrowserPersistDocumentChild::ManagedPWebBrowserPersistResourcesChild(nsTArray<PWebBrowserPersistResourcesChild*>& aArr) const -> void
{
    mManagedPWebBrowserPersistResourcesChild.ToArray(aArr);
}

auto PWebBrowserPersistDocumentChild::ManagedPWebBrowserPersistResourcesChild() const -> const ManagedContainer<PWebBrowserPersistResourcesChild>&
{
    return mManagedPWebBrowserPersistResourcesChild;
}

auto PWebBrowserPersistDocumentChild::ManagedPWebBrowserPersistSerializeChild(nsTArray<PWebBrowserPersistSerializeChild*>& aArr) const -> void
{
    mManagedPWebBrowserPersistSerializeChild.ToArray(aArr);
}

auto PWebBrowserPersistDocumentChild::ManagedPWebBrowserPersistSerializeChild() const -> const ManagedContainer<PWebBrowserPersistSerializeChild>&
{
    return mManagedPWebBrowserPersistSerializeChild;
}

auto PWebBrowserPersistDocumentChild::ManagedProtocolIds() const -> mozilla::Span<mozilla::ipc::ProtocolId const>
{
    static constexpr ::mozilla::ipc::ProtocolId sIds[] = {
        PWebBrowserPersistResourcesMsgStart,
        PWebBrowserPersistSerializeMsgStart
    };
    return sIds;
}

auto PWebBrowserPersistDocumentChild::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer*
{
    switch (aProtocol) {
    case PWebBrowserPersistResourcesMsgStart:
        return (&(mManagedPWebBrowserPersistResourcesChild));
    case PWebBrowserPersistSerializeMsgStart:
        return (&(mManagedPWebBrowserPersistSerializeChild));
    default:
        return nullptr;
    }
}

auto PWebBrowserPersistDocumentChild::OpenPWebBrowserPersistResourcesEndpoint(PWebBrowserPersistResourcesChild* aActor) -> ManagedEndpoint<PWebBrowserPersistResourcesParent>
{
    if (!aActor) {
        NS_WARNING("Cannot bind null PWebBrowserPersistResourcesChild actor");
        return ManagedEndpoint<PWebBrowserPersistResourcesParent>();
    }

    if (!aActor->SetManagerAndRegister(this)) {
        NS_WARNING("Failed to bind PWebBrowserPersistResourcesChild actor");
        return ManagedEndpoint<PWebBrowserPersistResourcesParent>();
    }

    // Mark our actor as awaiting the other side to be bound. This will
    // be cleared when a `MANAGED_ENDPOINT_{DROPPED,BOUND}` message is
    // received.
    aActor->mAwaitingManagedEndpointBind = true;
    return ManagedEndpoint<PWebBrowserPersistResourcesParent>(mozilla::ipc::PrivateIPDLInterface(), aActor);
}

auto PWebBrowserPersistDocumentChild::BindPWebBrowserPersistResourcesEndpoint(
        ManagedEndpoint<PWebBrowserPersistResourcesChild> aEndpoint,
        PWebBrowserPersistResourcesChild* aActor) -> bool
{
    return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this);
}

auto PWebBrowserPersistDocumentChild::OpenPWebBrowserPersistSerializeEndpoint(PWebBrowserPersistSerializeChild* aActor) -> ManagedEndpoint<PWebBrowserPersistSerializeParent>
{
    if (!aActor) {
        NS_WARNING("Cannot bind null PWebBrowserPersistSerializeChild actor");
        return ManagedEndpoint<PWebBrowserPersistSerializeParent>();
    }

    if (!aActor->SetManagerAndRegister(this)) {
        NS_WARNING("Failed to bind PWebBrowserPersistSerializeChild actor");
        return ManagedEndpoint<PWebBrowserPersistSerializeParent>();
    }

    // Mark our actor as awaiting the other side to be bound. This will
    // be cleared when a `MANAGED_ENDPOINT_{DROPPED,BOUND}` message is
    // received.
    aActor->mAwaitingManagedEndpointBind = true;
    return ManagedEndpoint<PWebBrowserPersistSerializeParent>(mozilla::ipc::PrivateIPDLInterface(), aActor);
}

auto PWebBrowserPersistDocumentChild::BindPWebBrowserPersistSerializeEndpoint(
        ManagedEndpoint<PWebBrowserPersistSerializeChild> aEndpoint,
        PWebBrowserPersistSerializeChild* aActor) -> bool
{
    return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this);
}

auto PWebBrowserPersistDocumentChild::SendAttributes(
        const WebBrowserPersistDocumentAttrs& aAttrs,
        const mozilla::Maybe<IPCStream>& stream) -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebBrowserPersistDocument::Msg_Attributes(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aAttrs);
    // Sentinel = 'aAttrs'
    ((&(writer__)))->WriteSentinel(135529072);
    IPC::WriteParam((&(writer__)), stream);
    // Sentinel = 'stream'
    ((&(writer__)))->WriteSentinel(153223821);


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

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

auto PWebBrowserPersistDocumentChild::SendInitFailure(const nsresult& aStatus) -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebBrowserPersistDocument::Msg_InitFailure(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PWebBrowserPersistDocumentChild::DeallocManagee(
        mozilla::ipc::ProtocolId aProtocolId,
        IProtocol* aListener) -> void
{
    switch (aProtocolId) {
    case PWebBrowserPersistResourcesMsgStart:
        static_cast<WebBrowserPersistDocumentChild*>(this)->DeallocPWebBrowserPersistResourcesChild(static_cast<PWebBrowserPersistResourcesChild*>(aListener));
        return;
    case PWebBrowserPersistSerializeMsgStart:
        static_cast<WebBrowserPersistDocumentChild*>(this)->DeallocPWebBrowserPersistSerializeChild(static_cast<PWebBrowserPersistSerializeChild*>(aListener));
        return;
    default:
        FatalError("unreached");
        return;
    }
}

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aNewFlags = *maybe__aNewFlags;
            // Sentinel = 'aNewFlags'
            if ((!(((&(reader__)))->ReadSentinel(283181945)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<WebBrowserPersistDocumentChild*>(this))->RecvSetPersistFlags(std::move(aNewFlags));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PWebBrowserPersistDocument::Msg_PWebBrowserPersistResourcesConstructor__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebBrowserPersistDocument", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebBrowserPersistDocumentChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebBrowserPersistDocument::Msg_PWebBrowserPersistResourcesConstructor", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__actorid__ = IPC::ReadParam<mozilla::ipc::ActorId>((&(reader__)));
            if (!maybe__actorid__) {
                FatalError("Error deserializing 'mozilla::ipc::ActorId'");
                return MsgValueError;

            }
            auto& actorid__ = *maybe__actorid__;
            // Sentinel = 'actorid'
            if ((!(((&(reader__)))->ReadSentinel(193725159)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'mozilla::ipc::ActorId'");
                return MsgValueError;
            }
            reader__.EndRead();
            PWebBrowserPersistResourcesChild* actor = (static_cast<WebBrowserPersistDocumentChild*>(this))->AllocPWebBrowserPersistResourcesChild();
            if (!actor) {
                NS_WARNING("Cannot bind null PWebBrowserPersistResourcesChild actor");
                return MsgValueError;
            }

            if (!actor->SetManagerAndRegister(this, actorid__)) {
                NS_WARNING("Failed to bind PWebBrowserPersistResourcesChild actor");
                return MsgValueError;
            }

            mozilla::ipc::IPCResult __ok = (static_cast<WebBrowserPersistDocumentChild*>(this))->RecvPWebBrowserPersistResourcesConstructor(std::move(actor));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PWebBrowserPersistDocument::Msg_PWebBrowserPersistSerializeConstructor__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PWebBrowserPersistDocument", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PWebBrowserPersistDocumentChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PWebBrowserPersistDocument::Msg_PWebBrowserPersistSerializeConstructor", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__actorid__ = IPC::ReadParam<mozilla::ipc::ActorId>((&(reader__)));
            if (!maybe__actorid__) {
                FatalError("Error deserializing 'mozilla::ipc::ActorId'");
                return MsgValueError;

            }
            auto& actorid__ = *maybe__actorid__;
            // Sentinel = 'actorid'
            if ((!(((&(reader__)))->ReadSentinel(193725159)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'mozilla::ipc::ActorId'");
                return MsgValueError;
            }
            auto maybe__aMap = IPC::ReadParam<WebBrowserPersistURIMap>((&(reader__)));
            if (!maybe__aMap) {
                FatalError("Error deserializing 'WebBrowserPersistURIMap'");
                return MsgValueError;

            }
            auto& aMap = *maybe__aMap;
            // Sentinel = 'aMap'
            if ((!(((&(reader__)))->ReadSentinel(60883328)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'WebBrowserPersistURIMap'");
                return MsgValueError;
            }
            auto maybe__aRequestedContentType = IPC::ReadParam<nsCString>((&(reader__)));
            if (!maybe__aRequestedContentType) {
                FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& aRequestedContentType = *maybe__aRequestedContentType;
            // Sentinel = 'aRequestedContentType'
            if ((!(((&(reader__)))->ReadSentinel(1563297937)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__aEncoderFlags = IPC::ReadParam<uint32_t>((&(reader__)));
            if (!maybe__aEncoderFlags) {
                FatalError("Error deserializing 'uint32_t'");
                return MsgValueError;

            }
            auto& aEncoderFlags = *maybe__aEncoderFlags;
            // Sentinel = 'aEncoderFlags'
            if ((!(((&(reader__)))->ReadSentinel(582354191)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            auto maybe__aWrapColumn = IPC::ReadParam<uint32_t>((&(reader__)));
            if (!maybe__aWrapColumn) {
                FatalError("Error deserializing 'uint32_t'");
                return MsgValueError;

            }
            auto& aWrapColumn = *maybe__aWrapColumn;
            // Sentinel = 'aWrapColumn'
            if ((!(((&(reader__)))->ReadSentinel(432669802)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            PWebBrowserPersistSerializeChild* actor = (static_cast<WebBrowserPersistDocumentChild*>(this))->AllocPWebBrowserPersistSerializeChild(aMap, aRequestedContentType, aEncoderFlags, aWrapColumn);
            if (!actor) {
                NS_WARNING("Cannot bind null PWebBrowserPersistSerializeChild actor");
                return MsgValueError;
            }

            if (!actor->SetManagerAndRegister(this, actorid__)) {
                NS_WARNING("Failed to bind PWebBrowserPersistSerializeChild actor");
                return MsgValueError;
            }

            mozilla::ipc::IPCResult __ok = (static_cast<WebBrowserPersistDocumentChild*>(this))->RecvPWebBrowserPersistSerializeConstructor(std::move(actor), std::move(aMap), std::move(aRequestedContentType), std::move(aEncoderFlags), std::move(aWrapColumn));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

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

            mozilla::ipc::IPCResult __ok = (static_cast<WebBrowserPersistDocumentChild*>(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 PWebBrowserPersistDocumentChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PWebBrowserPersistDocumentChild::Result
{
    return MsgNotKnown;
}



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

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

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

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

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

} // namespace IPC
