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


#include "mozilla/PWebBrowserPersistSerializeChild.h"
#include "mozilla/ProfilerLabels.h"

#include "mozilla/PWebBrowserPersistDocumentChild.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 {


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

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

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

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

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

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

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

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

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

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

auto PWebBrowserPersistSerializeChild::SendWriteData(mozilla::Span<uint8_t const> aData) -> bool
{
    UniquePtr<IPC::Message> msg__ = PWebBrowserPersistSerialize::Msg_WriteData(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PWebBrowserPersistSerializeChild::Send__delete__(
        PWebBrowserPersistSerializeChild* actor,
        const nsACString& aContentType,
        const nsresult& aStatus) -> bool
{
    if (!actor || !actor->CanSend()) {
        NS_WARNING("Attempt to __delete__ missing or closed actor");
        return false;
    }
    UniquePtr<IPC::Message> msg__ = PWebBrowserPersistSerialize::Msg___delete__((actor)->Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            actor};

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

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

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

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

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

auto PWebBrowserPersistSerializeChild::OnMessageReceived(const Message& msg__) -> PWebBrowserPersistSerializeChild::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 PWebBrowserPersistSerialize::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

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



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

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

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

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

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

} // namespace IPC
