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


#include "mozilla/dom/PSpeechSynthesisParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/SpeechSynthesisParent.h"

#include "mozilla/dom/PContentParent.h"
#include "mozilla/dom/PSpeechSynthesisRequestParent.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 dom {


auto PSpeechSynthesisParent::Recv__delete__() -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

auto PSpeechSynthesisParent::RecvPSpeechSynthesisRequestConstructor(
        PSpeechSynthesisRequestParent* actor,
        const nsAString& aText,
        const nsAString& aUri,
        const nsAString& aLang,
        const float& aVolume,
        const float& aRate,
        const float& aPitch,
        const bool& aShouldResistFingerprinting) -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

MOZ_IMPLICIT PSpeechSynthesisParent::PSpeechSynthesisParent() :
    mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PSpeechSynthesisParent);
}

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

auto PSpeechSynthesisParent::ActorAlloc() -> void
{
    AddRef();
}

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

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

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

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

auto PSpeechSynthesisParent::Manager() const -> PContentParent*
{
    return static_cast<PContentParent*>(IProtocol::Manager());
}

auto PSpeechSynthesisParent::ManagedPSpeechSynthesisRequestParent(nsTArray<PSpeechSynthesisRequestParent*>& aArr) const -> void
{
    mManagedPSpeechSynthesisRequestParent.ToArray(aArr);
}

auto PSpeechSynthesisParent::ManagedPSpeechSynthesisRequestParent() const -> const ManagedContainer<PSpeechSynthesisRequestParent>&
{
    return mManagedPSpeechSynthesisRequestParent;
}

auto PSpeechSynthesisParent::ManagedProtocolIds() const -> mozilla::Span<mozilla::ipc::ProtocolId const>
{
    static constexpr ::mozilla::ipc::ProtocolId sIds[] = {
        PSpeechSynthesisRequestMsgStart
    };
    return sIds;
}

auto PSpeechSynthesisParent::GetManagedActors(mozilla::ipc::ProtocolId aProtocol) -> UntypedManagedContainer*
{
    switch (aProtocol) {
    case PSpeechSynthesisRequestMsgStart:
        return (&(mManagedPSpeechSynthesisRequestParent));
    default:
        return nullptr;
    }
}

auto PSpeechSynthesisParent::OpenPSpeechSynthesisRequestEndpoint(PSpeechSynthesisRequestParent* aActor) -> ManagedEndpoint<PSpeechSynthesisRequestChild>
{
    if (!aActor) {
        NS_WARNING("Cannot bind null PSpeechSynthesisRequestParent actor");
        return ManagedEndpoint<PSpeechSynthesisRequestChild>();
    }

    if (!aActor->SetManagerAndRegister(this)) {
        NS_WARNING("Failed to bind PSpeechSynthesisRequestParent actor");
        return ManagedEndpoint<PSpeechSynthesisRequestChild>();
    }

    // Mark our actor as awaiting the other side to be bound. This will
    // be cleared when a `MANAGED_ENDPOINT_{DROPPED,BOUND}` message is
    // received.
    aActor->mAwaitingManagedEndpointBind = true;
    return ManagedEndpoint<PSpeechSynthesisRequestChild>(mozilla::ipc::PrivateIPDLInterface(), aActor);
}

auto PSpeechSynthesisParent::BindPSpeechSynthesisRequestEndpoint(
        ManagedEndpoint<PSpeechSynthesisRequestParent> aEndpoint,
        PSpeechSynthesisRequestParent* aActor) -> bool
{
    return aEndpoint.Bind(mozilla::ipc::PrivateIPDLInterface(), aActor, this);
}

auto PSpeechSynthesisParent::SendVoiceAdded(const RemoteVoice& aVoice) -> bool
{
    UniquePtr<IPC::Message> msg__ = PSpeechSynthesis::Msg_VoiceAdded(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PSpeechSynthesisParent::SendVoiceRemoved(const nsAString& aUri) -> bool
{
    UniquePtr<IPC::Message> msg__ = PSpeechSynthesis::Msg_VoiceRemoved(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PSpeechSynthesisParent::SendSetDefaultVoice(
        const nsAString& aUri,
        const bool& aIsDefault) -> bool
{
    UniquePtr<IPC::Message> msg__ = PSpeechSynthesis::Msg_SetDefaultVoice(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aUri);
    // Sentinel = 'aUri'
    ((&(writer__)))->WriteSentinel(64225682);
    IPC::WriteParam((&(writer__)), aIsDefault);
    // Sentinel = 'aIsDefault'
    ((&(writer__)))->WriteSentinel(342098915);


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

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

auto PSpeechSynthesisParent::SendIsSpeakingChanged(const bool& aIsSpeaking) -> bool
{
    UniquePtr<IPC::Message> msg__ = PSpeechSynthesis::Msg_IsSpeakingChanged(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PSpeechSynthesisParent::SendNotifyVoicesChanged() -> bool
{
    UniquePtr<IPC::Message> msg__ = PSpeechSynthesis::Msg_NotifyVoicesChanged(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PSpeechSynthesisParent::SendNotifyVoicesError(const nsAString& aError) -> bool
{
    UniquePtr<IPC::Message> msg__ = PSpeechSynthesis::Msg_NotifyVoicesError(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PSpeechSynthesisParent::SendInitialVoicesAndState(
        mozilla::Span<RemoteVoice const> aVoices,
        mozilla::Span<nsString const> aDefaults,
        const bool& aIsSpeaking) -> bool
{
    UniquePtr<IPC::Message> msg__ = PSpeechSynthesis::Msg_InitialVoicesAndState(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aVoices);
    // Sentinel = 'aVoices'
    ((&(writer__)))->WriteSentinel(182911691);
    IPC::WriteParam((&(writer__)), aDefaults);
    // Sentinel = 'aDefaults'
    ((&(writer__)))->WriteSentinel(286327706);
    IPC::WriteParam((&(writer__)), aIsSpeaking);
    // Sentinel = 'aIsSpeaking'
    ((&(writer__)))->WriteSentinel(422577232);


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

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

auto PSpeechSynthesisParent::DeallocManagee(
        mozilla::ipc::ProtocolId aProtocolId,
        IProtocol* aListener) -> void
{
    switch (aProtocolId) {
    case PSpeechSynthesisRequestMsgStart:
        static_cast<::mozilla::dom::SpeechSynthesisParent*>(this)->DeallocPSpeechSynthesisRequestParent(static_cast<PSpeechSynthesisRequestParent*>(aListener));
        return;
    default:
        FatalError("unreached");
        return;
    }
}

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

    }
    switch (msg__.type()) {
    case MANAGED_ENDPOINT_BOUND_MESSAGE_TYPE:
        {
            if (!mAwaitingManagedEndpointBind) {
                NS_WARNING("Unexpected managed endpoint lifecycle message after actor bound!");
                return MsgNotAllowed;
            }
            mAwaitingManagedEndpointBind = false;
            return MsgProcessed;
        }
    case MANAGED_ENDPOINT_DROPPED_MESSAGE_TYPE:
        {
            if (!mAwaitingManagedEndpointBind) {
                NS_WARNING("Unexpected managed endpoint lifecycle message after actor bound!");
                return MsgNotAllowed;
            }
            mAwaitingManagedEndpointBind = false;
            this->ActorDisconnected(ManagedEndpointDropped);
            return MsgProcessed;
        }
    case PSpeechSynthesis::Msg___delete____ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PSpeechSynthesis", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PSpeechSynthesisParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PSpeechSynthesis::Msg___delete__", OTHER);

            DoomSubtree();
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::SpeechSynthesisParent*>(this))->Recv__delete__();
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }


            this->ActorDisconnected(Deletion);

            return MsgProcessed;
        }
    case PSpeechSynthesis::Msg_PSpeechSynthesisRequestConstructor__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PSpeechSynthesis", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PSpeechSynthesisParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PSpeechSynthesis::Msg_PSpeechSynthesisRequestConstructor", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__actorid__ = IPC::ReadParam<mozilla::ipc::ActorId>((&(reader__)));
            if (!maybe__actorid__) {
                FatalError("Error deserializing 'mozilla::ipc::ActorId'");
                return MsgValueError;

            }
            auto& actorid__ = *maybe__actorid__;
            // Sentinel = 'actorid'
            if ((!(((&(reader__)))->ReadSentinel(193725159)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'mozilla::ipc::ActorId'");
                return MsgValueError;
            }
            auto maybe__aText = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aText) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aText = *maybe__aText;
            // Sentinel = 'aText'
            if ((!(((&(reader__)))->ReadSentinel(97321479)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aUri = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aUri) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aUri = *maybe__aUri;
            // Sentinel = 'aUri'
            if ((!(((&(reader__)))->ReadSentinel(64225682)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aLang = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aLang) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

            }
            auto& aLang = *maybe__aLang;
            // Sentinel = 'aLang'
            if ((!(((&(reader__)))->ReadSentinel(92275172)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aVolume = IPC::ReadParam<float>((&(reader__)));
            if (!maybe__aVolume) {
                FatalError("Error deserializing 'float'");
                return MsgValueError;

            }
            auto& aVolume = *maybe__aVolume;
            // Sentinel = 'aVolume'
            if ((!(((&(reader__)))->ReadSentinel(187368154)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'float'");
                return MsgValueError;
            }
            auto maybe__aRate = IPC::ReadParam<float>((&(reader__)));
            if (!maybe__aRate) {
                FatalError("Error deserializing 'float'");
                return MsgValueError;

            }
            auto& aRate = *maybe__aRate;
            // Sentinel = 'aRate'
            if ((!(((&(reader__)))->ReadSentinel(94503406)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'float'");
                return MsgValueError;
            }
            auto maybe__aPitch = IPC::ReadParam<float>((&(reader__)));
            if (!maybe__aPitch) {
                FatalError("Error deserializing 'float'");
                return MsgValueError;

            }
            auto& aPitch = *maybe__aPitch;
            // Sentinel = 'aPitch'
            if ((!(((&(reader__)))->ReadSentinel(134873690)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'float'");
                return MsgValueError;
            }
            auto maybe__aShouldResistFingerprinting = IPC::ReadParam<bool>((&(reader__)));
            if (!maybe__aShouldResistFingerprinting) {
                FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& aShouldResistFingerprinting = *maybe__aShouldResistFingerprinting;
            // Sentinel = 'aShouldResistFingerprinting'
            if ((!(((&(reader__)))->ReadSentinel(2558462737)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            reader__.EndRead();
            // Ensure the ID which was sent to us is valid, and reserve a spot
            // in the table for the new actor before we bother to alloc it.
            if (!ToplevelProtocol()->TryReserve(actorid__)) {
                NS_WARNING("Failed to reserve ActorId for constructor");
                return MsgValueError;
            }

            PSpeechSynthesisRequestParent* actor = (static_cast<::mozilla::dom::SpeechSynthesisParent*>(this))->AllocPSpeechSynthesisRequestParent(aText, aUri, aLang, aVolume, aRate, aPitch, aShouldResistFingerprinting);

            if (!actor) {
                NS_WARNING("Alloc function returned null");
                // Clean up the reservation taken above if this fails, to avoid
                // leaving zombie entries in the map.
                ToplevelProtocol()->ClearReservation(actorid__);
                return MsgValueError;
            }

            // NOTE: SetManagerAndRegister unconditionally consumes the
            // reservation taken by TryReserve, so we don't need to clear it on
            // failure.
            if (!actor->SetManagerAndRegister(this, actorid__)) {
                NS_WARNING("Failed to set manager for constructor");
                return MsgValueError;
            }
            mozilla::ipc::IPCResult __ok = (static_cast<::mozilla::dom::SpeechSynthesisParent*>(this))->RecvPSpeechSynthesisRequestConstructor(std::move(actor), std::move(aText), std::move(aUri), std::move(aLang), std::move(aVolume), std::move(aRate), std::move(aPitch), std::move(aShouldResistFingerprinting));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

auto PSpeechSynthesisParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PSpeechSynthesisParent::Result
{
    if (!CanSend()) {
        return MsgDropped;

    }
    return MsgNotKnown;
}



} // namespace dom
} // namespace mozilla
