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


#include "mozilla/ipc/PUtilityMediaServiceParent.h"
#include "mozilla/D3DMessageUtils.h"
#include "mozilla/GfxMessageUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ipc/IPCCore.h"
#include "mozilla/ipc/UtilityMediaServiceParent.h"

#include "mozilla/PRemoteMediaManagerParent.h"
#include "mozilla/layers/PVideoBridgeParent.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 PUtilityMediaServiceParent::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

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

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

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

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

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

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

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

auto PUtilityMediaServiceParent::SendUpdateMediaCodecsSupported(
        const RemoteMediaIn& aLocation,
        const MediaCodecsSupported& aSupported) -> bool
{
    UniquePtr<IPC::Message> msg__ = PUtilityMediaService::Msg_UpdateMediaCodecsSupported(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aLocation);
    // Sentinel = 'aLocation'
    ((&(writer__)))->WriteSentinel(292094875);
    IPC::WriteParam((&(writer__)), aSupported);
    // Sentinel = 'aSupported'
    ((&(writer__)))->WriteSentinel(378799144);


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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& endpoint = *maybe__endpoint;
            // Sentinel = 'endpoint'
            if ((!(((&(reader__)))->ReadSentinel(251724642)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'Endpoint<::mozilla::PRemoteMediaManagerParent>'");
                return MsgValueError;
            }
            auto maybe__parentId = IPC::ReadParam<ContentParentId>((&(reader__)));
            if (!maybe__parentId) {
                FatalError("Error deserializing 'ContentParentId'");
                return MsgValueError;

            }
            auto& parentId = *maybe__parentId;
            // Sentinel = 'parentId'
            if ((!(((&(reader__)))->ReadSentinel(249430840)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ContentParentId'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<UtilityMediaServiceParent*>(this))->RecvNewContentRemoteMediaManager(std::move(endpoint), std::move(parentId));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PUtilityMediaService::Msg_UpdateVar__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PUtilityMediaService", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PUtilityMediaServiceParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PUtilityMediaService::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<UtilityMediaServiceParent*>(this))->RecvUpdateVar(std::move(var));
            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 PUtilityMediaServiceParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PUtilityMediaServiceParent::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}



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

} // namespace IPC
