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


#include "mozilla/ipc/PUtilityMediaServiceChild.h"
#include "mozilla/D3DMessageUtils.h"
#include "mozilla/GfxMessageUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ipc/IPCCore.h"
#include "mozilla/ipc/UtilityMediaServiceChild.h"

#include "mozilla/PRemoteMediaManagerChild.h"
#include "mozilla/layers/PVideoBridgeChild.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 ipc {


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

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

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

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

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

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

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

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

auto PUtilityMediaServiceChild::SendNewContentRemoteMediaManager(
        Endpoint<::mozilla::PRemoteMediaManagerParent>&& endpoint,
        const ContentParentId& parentId) -> bool
{
    UniquePtr<IPC::Message> msg__ = PUtilityMediaService::Msg_NewContentRemoteMediaManager(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), std::move(endpoint));
    // Sentinel = 'endpoint'
    ((&(writer__)))->WriteSentinel(251724642);
    IPC::WriteParam((&(writer__)), parentId);
    // Sentinel = 'parentId'
    ((&(writer__)))->WriteSentinel(249430840);


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

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

auto PUtilityMediaServiceChild::SendUpdateVar(mozilla::Span<GfxVarUpdate const> var) -> bool
{
    UniquePtr<IPC::Message> msg__ = PUtilityMediaService::Msg_UpdateVar(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aLocation = *maybe__aLocation;
            // Sentinel = 'aLocation'
            if ((!(((&(reader__)))->ReadSentinel(292094875)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'RemoteMediaIn'");
                return MsgValueError;
            }
            auto maybe__aSupported = IPC::ReadParam<MediaCodecsSupported>((&(reader__)));
            if (!maybe__aSupported) {
                FatalError("Error deserializing 'MediaCodecsSupported'");
                return MsgValueError;

            }
            auto& aSupported = *maybe__aSupported;
            // Sentinel = 'aSupported'
            if ((!(((&(reader__)))->ReadSentinel(378799144)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'MediaCodecsSupported'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<UtilityMediaServiceChild*>(this))->RecvUpdateMediaCodecsSupported(std::move(aLocation), std::move(aSupported));
            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 PUtilityMediaServiceChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PUtilityMediaServiceChild::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}



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

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

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

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

        return {};
    }
    return static_cast<::mozilla::ipc::PUtilityMediaServiceChild*>(actor);
}

} // namespace IPC
