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


#include "mozilla/layers/PUiCompositorControllerParent.h"
#include "mozilla/GfxMessageUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/layers/LayersMessageUtils.h"
#include "mozilla/layers/UiCompositorControllerParent.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 layers {


auto PUiCompositorControllerParent::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

auto PUiCompositorControllerParent::ShouldContinueFromReplyTimeout() -> bool
{
    return true;
}

MOZ_IMPLICIT PUiCompositorControllerParent::PUiCompositorControllerParent() :
    mozilla::ipc::IToplevelProtocol("PUiCompositorControllerParent", kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PUiCompositorControllerParent);
}

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

auto PUiCompositorControllerParent::ActorAlloc() -> void
{
    MOZ_RELEASE_ASSERT(XRE_IsParentProcess() || XRE_IsGPUProcess(), "Invalid process for `PUiCompositorControllerParent'");
    AddRef();
}

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

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

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

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

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

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

auto PUiCompositorControllerParent::SendToolbarAnimatorMessageFromCompositor(const int32_t& aMessage) -> bool
{
    UniquePtr<IPC::Message> msg__ = PUiCompositorController::Msg_ToolbarAnimatorMessageFromCompositor(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PUiCompositorControllerParent::SendNotifyCompositorScrollUpdate(const CompositorScrollUpdate& aUpdate) -> bool
{
    UniquePtr<IPC::Message> msg__ = PUiCompositorController::Msg_NotifyCompositorScrollUpdate(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PUiCompositorControllerParent::SendScreenPixels(
        Shmem&& aMem,
        const ScreenIntSize& aSize,
        const bool& aNeedsYFlip) -> bool
{
    UniquePtr<IPC::Message> msg__ = PUiCompositorController::Msg_ScreenPixels(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), std::move(aMem));
    // Sentinel = 'aMem'
    ((&(writer__)))->WriteSentinel(61211009);
    IPC::WriteParam((&(writer__)), aSize);
    // Sentinel = 'aSize'
    ((&(writer__)))->WriteSentinel(97124861);
    IPC::WriteParam((&(writer__)), aNeedsYFlip);
    // Sentinel = 'aNeedsYFlip'
    ((&(writer__)))->WriteSentinel(415237173);


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

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

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

auto PUiCompositorControllerParent::OnMessageReceived(const Message& msg__) -> PUiCompositorControllerParent::Result
{
    switch (msg__.type()) {
    case PUiCompositorController::Msg_InvalidateAndRender__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PUiCompositorController::Msg_InvalidateAndRender", OTHER);

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

            return MsgProcessed;
        }
    case PUiCompositorController::Msg_MaxToolbarHeight__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PUiCompositorController::Msg_MaxToolbarHeight", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aHeight = *maybe__aHeight;
            // Sentinel = 'aHeight'
            if ((!(((&(reader__)))->ReadSentinel(175375035)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<UiCompositorControllerParent*>(this))->RecvMaxToolbarHeight(std::move(aHeight));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PUiCompositorController::Msg_FixedBottomOffset__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PUiCompositorController::Msg_FixedBottomOffset", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aOffset = *maybe__aOffset;
            // Sentinel = 'aOffset'
            if ((!(((&(reader__)))->ReadSentinel(179634889)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<UiCompositorControllerParent*>(this))->RecvFixedBottomOffset(std::move(aOffset));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PUiCompositorController::Msg_DefaultClearColor__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PUiCompositorController::Msg_DefaultClearColor", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aColor = *maybe__aColor;
            // Sentinel = 'aColor'
            if ((!(((&(reader__)))->ReadSentinel(132842081)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<UiCompositorControllerParent*>(this))->RecvDefaultClearColor(std::move(aColor));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PUiCompositorController::Msg_RequestScreenPixels__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PUiCompositorController::Msg_RequestScreenPixels", OTHER);

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

            return MsgProcessed;
        }
    case PUiCompositorController::Msg_EnableLayerUpdateNotifications__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PUiCompositorController::Msg_EnableLayerUpdateNotifications", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aEnable = *maybe__aEnable;
            // Sentinel = 'aEnable'
            if ((!(((&(reader__)))->ReadSentinel(173605545)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<UiCompositorControllerParent*>(this))->RecvEnableLayerUpdateNotifications(std::move(aEnable));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    case SHMEM_CREATED_MESSAGE_TYPE:
        {
            if (!ShmemCreated(msg__)) {
                return MsgPayloadError;
            }
            return MsgProcessed;
        }
    case SHMEM_DESTROYED_MESSAGE_TYPE:
        {
            if (!ShmemDestroyed(msg__)) {
                return MsgPayloadError;
            }
            return MsgProcessed;
        }
    }
}

auto PUiCompositorControllerParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PUiCompositorControllerParent::Result
{
    switch (msg__.type()) {
    case PUiCompositorController::Msg_Pause__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PUiCompositorController::Msg_Pause", OTHER);

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

            reply__ = PUiCompositorController::Reply_Pause(id__);
            IPC::MessageWriter writer__{
                    (*(reply__)),
                    this};

            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Sending reply ",
                    reply__->type(),
                    mozilla::ipc::MessageDirection::eSending);
            }
            return MsgProcessed;
        }
    case PUiCompositorController::Msg_Resume__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PUiCompositorController::Msg_Resume", OTHER);

            mozilla::ipc::ActorId id__ = MSG_ROUTING_CONTROL;
            bool aOutResumed{};
            mozilla::ipc::IPCResult __ok = (static_cast<UiCompositorControllerParent*>(this))->RecvResume((&(aOutResumed)));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            reply__ = PUiCompositorController::Reply_Resume(id__);
            IPC::MessageWriter writer__{
                    (*(reply__)),
                    this};

            IPC::WriteParam((&(writer__)), aOutResumed);
            // Sentinel = 'aOutResumed'
            ((&(writer__)))->WriteSentinel(439157871);
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Sending reply ",
                    reply__->type(),
                    mozilla::ipc::MessageDirection::eSending);
            }
            return MsgProcessed;
        }
    case PUiCompositorController::Msg_ResumeAndResize__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PUiCompositorController::Msg_ResumeAndResize", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

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

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

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

            }
            auto& aHeight = *maybe__aHeight;
            // Sentinel = 'aHeight'
            if ((!(((&(reader__)))->ReadSentinel(175375035)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = MSG_ROUTING_CONTROL;
            bool aOutResumed{};
            mozilla::ipc::IPCResult __ok = (static_cast<UiCompositorControllerParent*>(this))->RecvResumeAndResize(std::move(aX), std::move(aY), std::move(aWidth), std::move(aHeight), (&(aOutResumed)));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            reply__ = PUiCompositorController::Reply_ResumeAndResize(id__);
            IPC::MessageWriter writer__{
                    (*(reply__)),
                    this};

            IPC::WriteParam((&(writer__)), aOutResumed);
            // Sentinel = 'aOutResumed'
            ((&(writer__)))->WriteSentinel(439157871);
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Sending reply ",
                    reply__->type(),
                    mozilla::ipc::MessageDirection::eSending);
            }
            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}



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

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

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

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

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

} // namespace IPC
