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


#include "mozilla/dom/PClientSourceChild.h"
#include "ipc/ErrorIPCUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/ClientIPCUtils.h"

#include "mozilla/dom/PClientManagerChild.h"
#include "mozilla/dom/PClientSourceOpChild.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 PClientSourceChild::RecvPClientSourceOpConstructor(
        PClientSourceOpChild* actor,
        const ClientOpConstructorArgs& aArgs) -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

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

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

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

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

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

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

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

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

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

auto PClientSourceChild::ManagedPClientSourceOpChild(nsTArray<PClientSourceOpChild*>& aArr) const -> void
{
    mManagedPClientSourceOpChild.ToArray(aArr);
}

auto PClientSourceChild::ManagedPClientSourceOpChild() const -> const ManagedContainer<PClientSourceOpChild>&
{
    return mManagedPClientSourceOpChild;
}

auto PClientSourceChild::ManagedProtocolIds() const -> mozilla::Span<mozilla::ipc::ProtocolId const>
{
    static constexpr ::mozilla::ipc::ProtocolId sIds[] = {
        PClientSourceOpMsgStart
    };
    return sIds;
}

auto PClientSourceChild::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer*
{
    switch (aProtocol) {
    case PClientSourceOpMsgStart:
        return (&(mManagedPClientSourceOpChild));
    default:
        return nullptr;
    }
}

auto PClientSourceChild::OpenPClientSourceOpEndpoint(PClientSourceOpChild* aActor) -> ManagedEndpoint<PClientSourceOpParent>
{
    if (!aActor) {
        NS_WARNING("Cannot bind null PClientSourceOpChild actor");
        return ManagedEndpoint<PClientSourceOpParent>();
    }

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

    // 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<PClientSourceOpParent>(mozilla::ipc::PrivateIPDLInterface(), aActor);
}

auto PClientSourceChild::BindPClientSourceOpEndpoint(
        ManagedEndpoint<PClientSourceOpChild> aEndpoint,
        PClientSourceOpChild* aActor) -> bool
{
    return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this);
}

auto PClientSourceChild::SendWorkerSyncPing() -> bool
{
    UniquePtr<IPC::Message> msg__ = PClientSource::Msg_WorkerSyncPing(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};


    UniquePtr<Message> reply__;

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

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

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

    return true;
}

auto PClientSourceChild::SendTeardown() -> bool
{
    UniquePtr<IPC::Message> msg__ = PClientSource::Msg_Teardown(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PClientSourceChild::SendExecutionReady(const ClientSourceExecutionReadyArgs& aArgs) -> bool
{
    UniquePtr<IPC::Message> msg__ = PClientSource::Msg_ExecutionReady(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PClientSourceChild::SendFreeze() -> bool
{
    UniquePtr<IPC::Message> msg__ = PClientSource::Msg_Freeze(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PClientSourceChild::SendThaw() -> bool
{
    UniquePtr<IPC::Message> msg__ = PClientSource::Msg_Thaw(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PClientSourceChild::SendInheritController(const ClientControlledArgs& aArgs) -> bool
{
    UniquePtr<IPC::Message> msg__ = PClientSource::Msg_InheritController(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PClientSourceChild::SendNoteDOMContentLoaded() -> bool
{
    UniquePtr<IPC::Message> msg__ = PClientSource::Msg_NoteDOMContentLoaded(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PClientSourceChild::DeallocManagee(
        mozilla::ipc::ProtocolId aProtocolId,
        IProtocol* aListener) -> void
{
    switch (aProtocolId) {
    case PClientSourceOpMsgStart:
        this->DeallocPClientSourceOpChild(static_cast<PClientSourceOpChild*>(aListener));
        return;
    default:
        FatalError("unreached");
        return;
    }
}

auto PClientSourceChild::OnMessageReceived(const Message& msg__) -> PClientSourceChild::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 PClientSource::Msg_PClientSourceOpConstructor__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PClientSource", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PClientSourceChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PClientSource::Msg_PClientSourceOpConstructor", 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__aArgs = IPC::ReadParam<ClientOpConstructorArgs>((&(reader__)));
            if (!maybe__aArgs) {
                FatalError("Error deserializing 'ClientOpConstructorArgs'");
                return MsgValueError;

            }
            auto& aArgs = *maybe__aArgs;
            // Sentinel = 'aArgs'
            if ((!(((&(reader__)))->ReadSentinel(92602863)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ClientOpConstructorArgs'");
                return MsgValueError;
            }
            reader__.EndRead();
            PClientSourceOpChild* actor = (this)->AllocPClientSourceOpChild(aArgs);
            if (!actor) {
                NS_WARNING("Cannot bind null PClientSourceOpChild actor");
                return MsgValueError;
            }

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

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

            return MsgProcessed;
        }
    case PClientSource::Msg_EvictFromBFCache__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PClientSource", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PClientSourceChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PClientSource::Msg_EvictFromBFCache", OTHER);

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

            return MsgProcessed;
        }
    case PClientSource::Msg___delete____ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PClientSource", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PClientSourceChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PClientSource::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 PClientSourceChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PClientSourceChild::Result
{
    return MsgNotKnown;
}



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

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

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

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

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

} // namespace IPC
