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


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

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

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

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

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

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

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

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

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

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

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

auto PVsyncBridgeChild::SendNotifyVsync(
        const VsyncEvent& vsync,
        const LayersId& layersId) -> bool
{
    UniquePtr<IPC::Message> msg__ = PVsyncBridge::Msg_NotifyVsync(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), vsync);
    // Sentinel = 'vsync'
    ((&(writer__)))->WriteSentinel(113836596);
    IPC::WriteParam((&(writer__)), layersId);
    // Sentinel = 'layersId'
    ((&(writer__)))->WriteSentinel(250938174);


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

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

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

auto PVsyncBridgeChild::OnMessageReceived(const Message& msg__) -> PVsyncBridgeChild::Result
{
    switch (msg__.type()) {
    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 PVsyncBridgeChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PVsyncBridgeChild::Result
{
    return MsgNotKnown;
}



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

} // namespace IPC
