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


#include "mozilla/ipc/PIdleSchedulerParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ipc/IdleSchedulerParent.h"

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


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

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

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

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

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

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

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

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

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

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

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

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

auto PIdleSchedulerParent::SendIdleTime(
        const uint64_t& id,
        const TimeDuration& budget) -> bool
{
    UniquePtr<IPC::Message> msg__ = PIdleScheduler::Msg_IdleTime(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), id);
    // Sentinel = 'id'
    ((&(writer__)))->WriteSentinel(20447438);
    IPC::WriteParam((&(writer__)), budget);
    // Sentinel = 'budget'
    ((&(writer__)))->WriteSentinel(144573052);


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

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

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

auto PIdleSchedulerParent::OnMessageReceived(const Message& msg__) -> PIdleSchedulerParent::Result
{
    if (!CanSend()) {
        if (mozilla::ipc::LoggingEnabledFor("PIdleScheduler", mozilla::ipc::ParentSide)) {
            mozilla::ipc::LogMessageForProtocol(
                "PIdleSchedulerParent",
                this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                "Ignored message for dead actor",
                (&(msg__))->type(),
                mozilla::ipc::MessageDirection::eSending);
        }
        return MsgProcessed;

    }
    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 PIdleScheduler::Msg_InitForIdleUse__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PIdleScheduler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIdleSchedulerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PIdleScheduler::Msg_InitForIdleUse", OTHER);

            mozilla::ipc::ActorId id__ = Id();
            UniquePtr<IPC::Message> reply__(PIdleScheduler::Reply_InitForIdleUse(id__));
            reply__->set_seqno(msg__.seqno());

            RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
                new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);

            InitForIdleUseResolver resolver = [resolver__ = std::move(resolver__)](std::tuple<mozilla::Maybe<MutableSharedMemoryHandle>&&, const uint32_t&> aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), std::move(std::get<0>(aParam)));
                    // Sentinel = 'state'
                    ((&(writer__)))->WriteSentinel(109314594);
                    IPC::WriteParam((&(writer__)), std::get<1>(aParam));
                    // Sentinel = 'childId'
                    ((&(writer__)))->WriteSentinel(185270962);

                    if (mozilla::ipc::LoggingEnabledFor("PIdleScheduler", mozilla::ipc::ParentSide)) {
                        mozilla::ipc::LogMessageForProtocol(
                            "PIdleSchedulerParent",
                            self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
                            "Sending reply ",
                            reply__->type(),
                            mozilla::ipc::MessageDirection::eSending);
                    }

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

            return MsgProcessed;
        }
    case PIdleScheduler::Msg_RequestIdleTime__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PIdleScheduler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIdleSchedulerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PIdleScheduler::Msg_RequestIdleTime", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& id = *maybe__id;
            // Sentinel = 'id'
            if ((!(((&(reader__)))->ReadSentinel(20447438)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint64_t'");
                return MsgValueError;
            }
            auto maybe__budget = IPC::ReadParam<TimeDuration>((&(reader__)));
            if (!maybe__budget) {
                FatalError("Error deserializing 'TimeDuration'");
                return MsgValueError;

            }
            auto& budget = *maybe__budget;
            // Sentinel = 'budget'
            if ((!(((&(reader__)))->ReadSentinel(144573052)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'TimeDuration'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::ipc::IdleSchedulerParent*>(this))->RecvRequestIdleTime(std::move(id), std::move(budget));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PIdleScheduler::Msg_IdleTimeUsed__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PIdleScheduler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIdleSchedulerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PIdleScheduler::Msg_IdleTimeUsed", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& id = *maybe__id;
            // Sentinel = 'id'
            if ((!(((&(reader__)))->ReadSentinel(20447438)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint64_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::ipc::IdleSchedulerParent*>(this))->RecvIdleTimeUsed(std::move(id));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PIdleScheduler::Msg_Schedule__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PIdleScheduler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIdleSchedulerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PIdleScheduler::Msg_Schedule", OTHER);

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

            return MsgProcessed;
        }
    case PIdleScheduler::Msg_RunningPrioritizedOperation__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PIdleScheduler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIdleSchedulerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PIdleScheduler::Msg_RunningPrioritizedOperation", OTHER);

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

            return MsgProcessed;
        }
    case PIdleScheduler::Msg_PrioritizedOperationDone__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PIdleScheduler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIdleSchedulerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PIdleScheduler::Msg_PrioritizedOperationDone", OTHER);

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

            return MsgProcessed;
        }
    case PIdleScheduler::Msg_RequestGC__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PIdleScheduler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIdleSchedulerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PIdleScheduler::Msg_RequestGC", OTHER);

            mozilla::ipc::ActorId id__ = Id();
            UniquePtr<IPC::Message> reply__(PIdleScheduler::Reply_RequestGC(id__));
            reply__->set_seqno(msg__.seqno());

            RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
                new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);

            RequestGCResolver resolver = [resolver__ = std::move(resolver__)](const bool& aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), aParam);
                    // Sentinel = 'may_gc'
                    ((&(writer__)))->WriteSentinel(145425009);

                    if (mozilla::ipc::LoggingEnabledFor("PIdleScheduler", mozilla::ipc::ParentSide)) {
                        mozilla::ipc::LogMessageForProtocol(
                            "PIdleSchedulerParent",
                            self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
                            "Sending reply ",
                            reply__->type(),
                            mozilla::ipc::MessageDirection::eSending);
                    }

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

            return MsgProcessed;
        }
    case PIdleScheduler::Msg_StartedGC__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PIdleScheduler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIdleSchedulerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PIdleScheduler::Msg_StartedGC", OTHER);

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

            return MsgProcessed;
        }
    case PIdleScheduler::Msg_DoneGC__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PIdleScheduler", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PIdleSchedulerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PIdleScheduler::Msg_DoneGC", OTHER);

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

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

            DoomSubtree();
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::ipc::IdleSchedulerParent*>(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 PIdleSchedulerParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PIdleSchedulerParent::Result
{
    if (!CanSend()) {
        return MsgDropped;

    }
    return MsgNotKnown;
}



} // namespace ipc
} // namespace mozilla
