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


#include "mozilla/layout/PRemotePrintJobChild.h"
#include "mozilla/ProfilerLabels.h"

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


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

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

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

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

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

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

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

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

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

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

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

auto PRemotePrintJobChild::SendAbortPrint(const nsresult& aRv) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemotePrintJob::Msg_AbortPrint(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PRemotePrintJobChild::SendInitializePrint(
        const nsAString& aDocumentTitle,
        const MaybeDiscardedWindowContext& aWindowContext,
        const int32_t& aStartPage,
        const int32_t& aEndPage) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemotePrintJob::Msg_InitializePrint(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aDocumentTitle);
    // Sentinel = 'aDocumentTitle'
    ((&(writer__)))->WriteSentinel(695141795);
    IPC::WriteParam((&(writer__)), aWindowContext);
    // Sentinel = 'aWindowContext'
    ((&(writer__)))->WriteSentinel(703333823);
    IPC::WriteParam((&(writer__)), aStartPage);
    // Sentinel = 'aStartPage'
    ((&(writer__)))->WriteSentinel(361497581);
    IPC::WriteParam((&(writer__)), aEndPage);
    // Sentinel = 'aEndPage'
    ((&(writer__)))->WriteSentinel(219218678);


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

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

auto PRemotePrintJobChild::SendProcessPage(
        const int32_t& aWidthInPoints,
        const int32_t& aHeightInPoints,
        mozilla::Span<uint64_t const> aDeps) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemotePrintJob::Msg_ProcessPage(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aWidthInPoints);
    // Sentinel = 'aWidthInPoints'
    ((&(writer__)))->WriteSentinel(684524950);
    IPC::WriteParam((&(writer__)), aHeightInPoints);
    // Sentinel = 'aHeightInPoints'
    ((&(writer__)))->WriteSentinel(770311663);
    IPC::WriteParam((&(writer__)), aDeps);
    // Sentinel = 'aDeps'
    ((&(writer__)))->WriteSentinel(92013038);


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

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

auto PRemotePrintJobChild::SendFinalizePrint() -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemotePrintJob::Msg_FinalizePrint(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PRemotePrintJobChild::SendProgressChange(
        const long& aCurSelfProgress,
        const long& aMaxSelfProgress,
        const long& aCurTotalProgress,
        const long& aMaxTotalProgress) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemotePrintJob::Msg_ProgressChange(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aCurSelfProgress);
    // Sentinel = 'aCurSelfProgress'
    ((&(writer__)))->WriteSentinel(886113899);
    IPC::WriteParam((&(writer__)), aMaxSelfProgress);
    // Sentinel = 'aMaxSelfProgress'
    ((&(writer__)))->WriteSentinel(882706023);
    IPC::WriteParam((&(writer__)), aCurTotalProgress);
    // Sentinel = 'aCurTotalProgress'
    ((&(writer__)))->WriteSentinel(1012795109);
    IPC::WriteParam((&(writer__)), aMaxTotalProgress);
    // Sentinel = 'aMaxTotalProgress'
    ((&(writer__)))->WriteSentinel(1009125089);


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

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

auto PRemotePrintJobChild::SendStatusChange(const nsresult& aStatus) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemotePrintJob::Msg_StatusChange(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

auto PRemotePrintJobChild::OnMessageReceived(const Message& msg__) -> PRemotePrintJobChild::Result
{
    if (!CanSend()) {
        if (mozilla::ipc::LoggingEnabledFor("PRemotePrintJob", mozilla::ipc::ChildSide)) {
            mozilla::ipc::LogMessageForProtocol(
                "PRemotePrintJobChild",
                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 PRemotePrintJob::Msg_AbortPrint__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemotePrintJob", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemotePrintJobChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemotePrintJob::Msg_AbortPrint", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aRv = *maybe__aRv;
            // Sentinel = 'aRv'
            if ((!(((&(reader__)))->ReadSentinel(37749034)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsresult'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvAbortPrint(std::move(aRv));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PRemotePrintJob::Msg_PrintInitializationResult__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemotePrintJob", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemotePrintJobChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemotePrintJob::Msg_PrintInitializationResult", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aRv = *maybe__aRv;
            // Sentinel = 'aRv'
            if ((!(((&(reader__)))->ReadSentinel(37749034)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsresult'");
                return MsgValueError;
            }
            auto maybe__aFd = IPC::ReadParam<FileDescriptor>((&(reader__)));
            if (!maybe__aFd) {
                FatalError("Error deserializing 'FileDescriptor'");
                return MsgValueError;

            }
            auto& aFd = *maybe__aFd;
            // Sentinel = 'aFd'
            if ((!(((&(reader__)))->ReadSentinel(34996492)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'FileDescriptor'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvPrintInitializationResult(std::move(aRv), std::move(aFd));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PRemotePrintJob::Msg_PageProcessed__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemotePrintJob", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemotePrintJobChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemotePrintJob::Msg_PageProcessed", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aFd = *maybe__aFd;
            // Sentinel = 'aFd'
            if ((!(((&(reader__)))->ReadSentinel(34996492)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'FileDescriptor'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvPageProcessed(std::move(aFd));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

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

            DoomSubtree();
            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 PRemotePrintJobChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PRemotePrintJobChild::Result
{
    if (!CanSend()) {
        return MsgDropped;

    }
    return MsgNotKnown;
}



} // namespace layout
} // namespace mozilla
