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


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

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


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

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

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

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

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

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

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

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

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

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

auto PRemotePrintJobParent::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::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PRemotePrintJobParent",
            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 PRemotePrintJobParent::SendPrintInitializationResult(
        const nsresult& aRv,
        const FileDescriptor& aFd) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemotePrintJob::Msg_PrintInitializationResult(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PRemotePrintJobParent::SendPageProcessed(const FileDescriptor& aFd) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemotePrintJob::Msg_PageProcessed(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PRemotePrintJobParent::Send__delete__(PRemotePrintJobParent* actor) -> bool
{
    if (!actor || !actor->CanSend()) {
        NS_WARNING("Attempt to __delete__ missing or closed actor");
        return false;
    }
    UniquePtr<IPC::Message> msg__ = PRemotePrintJob::Msg___delete__((actor)->Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            actor};


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

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

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

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

auto PRemotePrintJobParent::OnMessageReceived(const Message& msg__) -> PRemotePrintJobParent::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 PRemotePrintJob::Msg_AbortPrint__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemotePrintJob", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemotePrintJobParent",
                    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_InitializePrint__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemotePrintJob", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemotePrintJobParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemotePrintJob::Msg_InitializePrint", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aDocumentTitle = *maybe__aDocumentTitle;
            // Sentinel = 'aDocumentTitle'
            if ((!(((&(reader__)))->ReadSentinel(695141795)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aStartPage = IPC::ReadParam<int32_t>((&(reader__)));
            if (!maybe__aStartPage) {
                FatalError("Error deserializing 'int32_t'");
                return MsgValueError;

            }
            auto& aStartPage = *maybe__aStartPage;
            // Sentinel = 'aStartPage'
            if ((!(((&(reader__)))->ReadSentinel(361497581)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int32_t'");
                return MsgValueError;
            }
            auto maybe__aEndPage = IPC::ReadParam<int32_t>((&(reader__)));
            if (!maybe__aEndPage) {
                FatalError("Error deserializing 'int32_t'");
                return MsgValueError;

            }
            auto& aEndPage = *maybe__aEndPage;
            // Sentinel = 'aEndPage'
            if ((!(((&(reader__)))->ReadSentinel(219218678)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvInitializePrint(std::move(aDocumentTitle), std::move(aStartPage), std::move(aEndPage));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PRemotePrintJob::Msg_ProcessPage__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemotePrintJob", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemotePrintJobParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemotePrintJob::Msg_ProcessPage", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aWidthInPoints = *maybe__aWidthInPoints;
            // Sentinel = 'aWidthInPoints'
            if ((!(((&(reader__)))->ReadSentinel(684524950)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int32_t'");
                return MsgValueError;
            }
            auto maybe__aHeightInPoints = IPC::ReadParam<int32_t>((&(reader__)));
            if (!maybe__aHeightInPoints) {
                FatalError("Error deserializing 'int32_t'");
                return MsgValueError;

            }
            auto& aHeightInPoints = *maybe__aHeightInPoints;
            // Sentinel = 'aHeightInPoints'
            if ((!(((&(reader__)))->ReadSentinel(770311663)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int32_t'");
                return MsgValueError;
            }
            auto maybe__aDeps = IPC::ReadParam<nsTArray<uint64_t>>((&(reader__)));
            if (!maybe__aDeps) {
                FatalError("Error deserializing 'uint64_t[]'");
                return MsgValueError;

            }
            auto& aDeps = *maybe__aDeps;
            // Sentinel = 'aDeps'
            if ((!(((&(reader__)))->ReadSentinel(92013038)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint64_t[]'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvProcessPage(std::move(aWidthInPoints), std::move(aHeightInPoints), std::move(aDeps));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PRemotePrintJob::Msg_FinalizePrint__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemotePrintJob", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemotePrintJobParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemotePrintJob::Msg_FinalizePrint", OTHER);

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

            return MsgProcessed;
        }
    case PRemotePrintJob::Msg_ProgressChange__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemotePrintJob", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemotePrintJobParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemotePrintJob::Msg_ProgressChange", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aCurSelfProgress = *maybe__aCurSelfProgress;
            // Sentinel = 'aCurSelfProgress'
            if ((!(((&(reader__)))->ReadSentinel(886113899)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'long'");
                return MsgValueError;
            }
            auto maybe__aMaxSelfProgress = IPC::ReadParam<long>((&(reader__)));
            if (!maybe__aMaxSelfProgress) {
                FatalError("Error deserializing 'long'");
                return MsgValueError;

            }
            auto& aMaxSelfProgress = *maybe__aMaxSelfProgress;
            // Sentinel = 'aMaxSelfProgress'
            if ((!(((&(reader__)))->ReadSentinel(882706023)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'long'");
                return MsgValueError;
            }
            auto maybe__aCurTotalProgress = IPC::ReadParam<long>((&(reader__)));
            if (!maybe__aCurTotalProgress) {
                FatalError("Error deserializing 'long'");
                return MsgValueError;

            }
            auto& aCurTotalProgress = *maybe__aCurTotalProgress;
            // Sentinel = 'aCurTotalProgress'
            if ((!(((&(reader__)))->ReadSentinel(1012795109)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'long'");
                return MsgValueError;
            }
            auto maybe__aMaxTotalProgress = IPC::ReadParam<long>((&(reader__)));
            if (!maybe__aMaxTotalProgress) {
                FatalError("Error deserializing 'long'");
                return MsgValueError;

            }
            auto& aMaxTotalProgress = *maybe__aMaxTotalProgress;
            // Sentinel = 'aMaxTotalProgress'
            if ((!(((&(reader__)))->ReadSentinel(1009125089)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'long'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvProgressChange(std::move(aCurSelfProgress), std::move(aMaxSelfProgress), std::move(aCurTotalProgress), std::move(aMaxTotalProgress));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PRemotePrintJob::Msg_StatusChange__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemotePrintJob", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemotePrintJobParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemotePrintJob::Msg_StatusChange", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

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

            return MsgProcessed;
        }
    case PRemotePrintJob::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

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



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

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

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

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

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

} // namespace IPC
