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


#include "mozilla/gfx/PVRParent.h"
#include "VRChild.h"
#include "VRMessageUtils.h"
#include "VRParent.h"
#include "mozilla/D3DMessageUtils.h"
#include "mozilla/GfxMessageUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ipc/IPCCore.h"

#include "mozilla/gfx/PVRGPUParent.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 gfx {


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

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

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

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

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

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

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

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

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

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

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

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

auto PVRParent::SendInitComplete() -> bool
{
    UniquePtr<IPC::Message> msg__ = PVR::Msg_InitComplete(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PVRParent::SendOpenVRControllerActionPathToParent(const nsACString& aPath) -> bool
{
    UniquePtr<IPC::Message> msg__ = PVR::Msg_OpenVRControllerActionPathToParent(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PVRParent::SendOpenVRControllerManifestPathToParent(
        const VRControllerType& aType,
        const nsACString& aPath) -> bool
{
    UniquePtr<IPC::Message> msg__ = PVR::Msg_OpenVRControllerManifestPathToParent(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aType);
    // Sentinel = 'aType'
    ((&(writer__)))->WriteSentinel(99222020);
    IPC::WriteParam((&(writer__)), aPath);
    // Sentinel = 'aPath'
    ((&(writer__)))->WriteSentinel(94175727);


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

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

auto PVRParent::SendInitCrashReporter(CrashReporterInitArgs&& aInitArgs) -> bool
{
    UniquePtr<IPC::Message> msg__ = PVR::Msg_InitCrashReporter(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), std::move(aInitArgs));
    // Sentinel = 'aInitArgs'
    ((&(writer__)))->WriteSentinel(286327683);


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

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

auto PVRParent::SendAddMemoryReport(const MemoryReport& aReport) -> bool
{
    UniquePtr<IPC::Message> msg__ = PVR::Msg_AddMemoryReport(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

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

    }
    switch (msg__.type()) {
    case PVR::Msg_NewGPUVRManager__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PVR", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PVRParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PVR::Msg_NewGPUVRManager", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__endpoint = IPC::ReadParam<Endpoint<::mozilla::gfx::PVRGPUParent>>((&(reader__)));
            if (!maybe__endpoint) {
                FatalError("Error deserializing 'Endpoint<::mozilla::gfx::PVRGPUParent>'");
                return MsgValueError;

            }
            auto& endpoint = *maybe__endpoint;
            // Sentinel = 'endpoint'
            if ((!(((&(reader__)))->ReadSentinel(251724642)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'Endpoint<::mozilla::gfx::PVRGPUParent>'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::gfx::VRParent*>(this))->RecvNewGPUVRManager(std::move(endpoint));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PVR::Msg_Init__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PVR", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PVRParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PVR::Msg_Init", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__vars = IPC::ReadParam<nsTArray<GfxVarUpdate>>((&(reader__)));
            if (!maybe__vars) {
                FatalError("Error deserializing 'GfxVarUpdate[]'");
                return MsgValueError;

            }
            auto& vars = *maybe__vars;
            // Sentinel = 'vars'
            if ((!(((&(reader__)))->ReadSentinel(72745405)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'GfxVarUpdate[]'");
                return MsgValueError;
            }
            auto maybe__devicePrefs = IPC::ReadParam<DevicePrefs>((&(reader__)));
            if (!maybe__devicePrefs) {
                FatalError("Error deserializing 'DevicePrefs'");
                return MsgValueError;

            }
            auto& devicePrefs = *maybe__devicePrefs;
            // Sentinel = 'devicePrefs'
            if ((!(((&(reader__)))->ReadSentinel(445645937)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'DevicePrefs'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::gfx::VRParent*>(this))->RecvInit(std::move(vars), std::move(devicePrefs));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PVR::Msg_UpdateVar__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PVR", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PVRParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PVR::Msg_UpdateVar", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__var = IPC::ReadParam<nsTArray<GfxVarUpdate>>((&(reader__)));
            if (!maybe__var) {
                FatalError("Error deserializing 'GfxVarUpdate[]'");
                return MsgValueError;

            }
            auto& var = *maybe__var;
            // Sentinel = 'var'
            if ((!(((&(reader__)))->ReadSentinel(43581770)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'GfxVarUpdate[]'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::gfx::VRParent*>(this))->RecvUpdateVar(std::move(var));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PVR::Msg_PreferenceUpdate__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PVR", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PVRParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PVR::Msg_PreferenceUpdate", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& pref = *maybe__pref;
            // Sentinel = 'pref'
            if ((!(((&(reader__)))->ReadSentinel(71958958)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'Pref'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::gfx::VRParent*>(this))->RecvPreferenceUpdate(std::move(pref));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PVR::Msg_OpenVRControllerActionPathToVR__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PVR", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PVRParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PVR::Msg_OpenVRControllerActionPathToVR", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aPath = *maybe__aPath;
            // Sentinel = 'aPath'
            if ((!(((&(reader__)))->ReadSentinel(94175727)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::gfx::VRParent*>(this))->RecvOpenVRControllerActionPathToVR(std::move(aPath));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PVR::Msg_OpenVRControllerManifestPathToVR__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PVR", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PVRParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PVR::Msg_OpenVRControllerManifestPathToVR", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aType = *maybe__aType;
            // Sentinel = 'aType'
            if ((!(((&(reader__)))->ReadSentinel(99222020)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'VRControllerType'");
                return MsgValueError;
            }
            auto maybe__aPath = IPC::ReadParam<nsCString>((&(reader__)));
            if (!maybe__aPath) {
                FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& aPath = *maybe__aPath;
            // Sentinel = 'aPath'
            if ((!(((&(reader__)))->ReadSentinel(94175727)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::gfx::VRParent*>(this))->RecvOpenVRControllerManifestPathToVR(std::move(aType), std::move(aPath));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PVR::Msg_RequestMemoryReport__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PVR", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PVRParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PVR::Msg_RequestMemoryReport", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& generation = *maybe__generation;
            // Sentinel = 'generation'
            if ((!(((&(reader__)))->ReadSentinel(381158445)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            auto maybe__anonymize = IPC::ReadParam<bool>((&(reader__)));
            if (!maybe__anonymize) {
                FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& anonymize = *maybe__anonymize;
            // Sentinel = 'anonymize'
            if ((!(((&(reader__)))->ReadSentinel(321127387)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            auto maybe__minimizeMemoryUsage = IPC::ReadParam<bool>((&(reader__)));
            if (!maybe__minimizeMemoryUsage) {
                FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& minimizeMemoryUsage = *maybe__minimizeMemoryUsage;
            // Sentinel = 'minimizeMemoryUsage'
            if ((!(((&(reader__)))->ReadSentinel(1321600977)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            auto maybe__DMDFile = IPC::ReadParam<mozilla::Maybe<FileDescriptor>>((&(reader__)));
            if (!maybe__DMDFile) {
                FatalError("Error deserializing 'FileDescriptor?'");
                return MsgValueError;

            }
            auto& DMDFile = *maybe__DMDFile;
            // Sentinel = 'DMDFile'
            if ((!(((&(reader__)))->ReadSentinel(143983190)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'FileDescriptor?'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = MSG_ROUTING_CONTROL;
            UniquePtr<IPC::Message> reply__(PVR::Reply_RequestMemoryReport(id__));
            reply__->set_seqno(msg__.seqno());

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

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

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

                });
            };
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::gfx::VRParent*>(this))->RecvRequestMemoryReport(std::move(generation), std::move(anonymize), std::move(minimizeMemoryUsage), std::move(DMDFile), std::move(resolver));
            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 PVRParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PVRParent::Result
{
    if (!CanSend()) {
        return MsgDropped;

    }
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}



} // namespace gfx
} // namespace mozilla
