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


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

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

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

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

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

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

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

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

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

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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& vsync = *maybe__vsync;
            // Sentinel = 'vsync'
            if ((!(((&(reader__)))->ReadSentinel(113836596)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'VsyncEvent'");
                return MsgValueError;
            }
            auto maybe__layersId = IPC::ReadParam<LayersId>((&(reader__)));
            if (!maybe__layersId) {
                FatalError("Error deserializing 'LayersId'");
                return MsgValueError;

            }
            auto& layersId = *maybe__layersId;
            // Sentinel = 'layersId'
            if ((!(((&(reader__)))->ReadSentinel(250938174)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'LayersId'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<VsyncBridgeParent*>(this))->RecvNotifyVsync(std::move(vsync), std::move(layersId));
            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 PVsyncBridgeParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PVsyncBridgeParent::Result
{
    return MsgNotKnown;
}



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

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

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

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

        return {};
    }
    return static_cast<::mozilla::gfx::PVsyncBridgeParent*>(actor);
}

} // namespace IPC
