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


#include "mozilla/layers/PUiCompositorControllerChild.h"
#include "mozilla/GfxMessageUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/layers/LayersMessageUtils.h"
#include "mozilla/layers/UiCompositorControllerChild.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 PUiCompositorControllerChild::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

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

MOZ_IMPLICIT PUiCompositorControllerChild::PUiCompositorControllerChild() :
    mozilla::ipc::IToplevelProtocol("PUiCompositorControllerChild", kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PUiCompositorControllerChild);
}

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

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

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

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

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

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

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

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

auto PUiCompositorControllerChild::SendPause() -> bool
{
    UniquePtr<IPC::Message> msg__ = PUiCompositorController::Msg_Pause(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};


    UniquePtr<Message> reply__;

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

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

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

    return true;
}

auto PUiCompositorControllerChild::SendResume(bool* aOutResumed) -> bool
{
    UniquePtr<IPC::Message> msg__ = PUiCompositorController::Msg_Resume(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};


    UniquePtr<Message> reply__;

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

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

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

    IPC::MessageReader reader__{
            (*(reply__)),
            this};

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

    }
    auto& aOutResumed__reply = *maybe__aOutResumed__reply;
    // Sentinel = 'aOutResumed'
    if ((!(((&(reader__)))->ReadSentinel(439157871)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
        return false;
    }
    (*(aOutResumed)) = std::move(aOutResumed__reply);
    reader__.EndRead();

    return true;
}

auto PUiCompositorControllerChild::SendResumeAndResize(
        const int32_t& aX,
        const int32_t& aY,
        const int32_t& aWidth,
        const int32_t& aHeight,
        bool* aOutResumed) -> bool
{
    UniquePtr<IPC::Message> msg__ = PUiCompositorController::Msg_ResumeAndResize(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aX);
    // Sentinel = 'aX'
    ((&(writer__)))->WriteSentinel(18612410);
    IPC::WriteParam((&(writer__)), aY);
    // Sentinel = 'aY'
    ((&(writer__)))->WriteSentinel(18677947);
    IPC::WriteParam((&(writer__)), aWidth);
    // Sentinel = 'aWidth'
    ((&(writer__)))->WriteSentinel(136249954);
    IPC::WriteParam((&(writer__)), aHeight);
    // Sentinel = 'aHeight'
    ((&(writer__)))->WriteSentinel(175375035);

    UniquePtr<Message> reply__;

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

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

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

    IPC::MessageReader reader__{
            (*(reply__)),
            this};

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

    }
    auto& aOutResumed__reply = *maybe__aOutResumed__reply;
    // Sentinel = 'aOutResumed'
    if ((!(((&(reader__)))->ReadSentinel(439157871)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
        return false;
    }
    (*(aOutResumed)) = std::move(aOutResumed__reply);
    reader__.EndRead();

    return true;
}

auto PUiCompositorControllerChild::SendInvalidateAndRender() -> bool
{
    UniquePtr<IPC::Message> msg__ = PUiCompositorController::Msg_InvalidateAndRender(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PUiCompositorControllerChild::SendMaxToolbarHeight(const int32_t& aHeight) -> bool
{
    UniquePtr<IPC::Message> msg__ = PUiCompositorController::Msg_MaxToolbarHeight(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PUiCompositorControllerChild::SendFixedBottomOffset(const int32_t& aOffset) -> bool
{
    UniquePtr<IPC::Message> msg__ = PUiCompositorController::Msg_FixedBottomOffset(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PUiCompositorControllerChild::SendDefaultClearColor(const uint32_t& aColor) -> bool
{
    UniquePtr<IPC::Message> msg__ = PUiCompositorController::Msg_DefaultClearColor(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PUiCompositorControllerChild::SendRequestScreenPixels() -> bool
{
    UniquePtr<IPC::Message> msg__ = PUiCompositorController::Msg_RequestScreenPixels(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PUiCompositorControllerChild::SendEnableLayerUpdateNotifications(const bool& aEnable) -> bool
{
    UniquePtr<IPC::Message> msg__ = PUiCompositorController::Msg_EnableLayerUpdateNotifications(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

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

            return MsgProcessed;
        }
    case PUiCompositorController::Msg_NotifyCompositorScrollUpdate__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PUiCompositorController::Msg_NotifyCompositorScrollUpdate", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aUpdate = *maybe__aUpdate;
            // Sentinel = 'aUpdate'
            if ((!(((&(reader__)))->ReadSentinel(182190789)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'CompositorScrollUpdate'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<UiCompositorControllerChild*>(this))->RecvNotifyCompositorScrollUpdate(std::move(aUpdate));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PUiCompositorController::Msg_ScreenPixels__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PUiCompositorController", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUiCompositorControllerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PUiCompositorController::Msg_ScreenPixels", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aMem = *maybe__aMem;
            // Sentinel = 'aMem'
            if ((!(((&(reader__)))->ReadSentinel(61211009)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'Shmem'");
                return MsgValueError;
            }
            auto maybe__aSize = IPC::ReadParam<ScreenIntSize>((&(reader__)));
            if (!maybe__aSize) {
                FatalError("Error deserializing 'ScreenIntSize'");
                return MsgValueError;

            }
            auto& aSize = *maybe__aSize;
            // Sentinel = 'aSize'
            if ((!(((&(reader__)))->ReadSentinel(97124861)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ScreenIntSize'");
                return MsgValueError;
            }
            auto maybe__aNeedsYFlip = IPC::ReadParam<bool>((&(reader__)));
            if (!maybe__aNeedsYFlip) {
                FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& aNeedsYFlip = *maybe__aNeedsYFlip;
            // Sentinel = 'aNeedsYFlip'
            if ((!(((&(reader__)))->ReadSentinel(415237173)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<UiCompositorControllerChild*>(this))->RecvScreenPixels(std::move(aMem), std::move(aSize), std::move(aNeedsYFlip));
            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 PUiCompositorControllerChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PUiCompositorControllerChild::Result
{
    return MsgNotKnown;
}



} // namespace layers
} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::layers::PUiCompositorControllerChild*>::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::PUiCompositorControllerChild*>::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::PUiCompositorControllerChild*>(actor);
}

} // namespace IPC
