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


#include "mozilla/PRemoteSpellcheckEngineChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/RemoteSpellCheckEngineChild.h"
#include "mozilla/RemoteSpellCheckEngineParent.h"

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


MOZ_IMPLICIT PRemoteSpellcheckEngineChild::PRemoteSpellcheckEngineChild() :
    mozilla::ipc::IProtocol(kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PRemoteSpellcheckEngineChild);
}

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

auto PRemoteSpellcheckEngineChild::ActorAlloc() -> void
{
}

auto PRemoteSpellcheckEngineChild::ActorDealloc() -> void
{
    if (Manager()) {
        Manager()->DeallocManagee(kProtocolId, this);
    }
}

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

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

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

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

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

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

auto PRemoteSpellcheckEngineChild::RejectPendingResponses(ResponseRejectReason aReason) -> void
{
    mAsyncCallbacks.RejectPendingResponses(aReason);
}

auto PRemoteSpellcheckEngineChild::Send__delete__(PRemoteSpellcheckEngineChild* actor) -> bool
{
    if (!actor || !actor->CanSend()) {
        NS_WARNING("Attempt to __delete__ missing or closed actor");
        return false;
    }
    UniquePtr<IPC::Message> msg__ = PRemoteSpellcheckEngine::Msg___delete__((actor)->Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            actor};


    if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PRemoteSpellcheckEngineChild",
            actor->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PRemoteSpellcheckEngine::Msg___delete__", OTHER);

    bool sendok__ = (actor)->ChannelSend(std::move(msg__));

    actor->ActorDisconnected(Deletion);
    return sendok__;
}

auto PRemoteSpellcheckEngineChild::SendCheckAsync(
        mozilla::Span<nsString const> aWord,
        mozilla::ipc::ResolveCallback<nsTArray<bool>>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PRemoteSpellcheckEngine::Msg_CheckAsync(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PRemoteSpellcheckEngine::Reply_CheckAsync__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__aIsMisspelled = IPC::ReadParam<nsTArray<bool>>(aReader);
            if (!maybe__aIsMisspelled) {
                (aReader)->FatalError("Error deserializing 'bool[]'");
                return MsgValueError;

            }
            auto& aIsMisspelled = *maybe__aIsMisspelled;
            // Sentinel = 'aIsMisspelled'
            if ((!((aReader)->ReadSentinel(595723568)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool[]'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(aIsMisspelled));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PRemoteSpellcheckEngineChild::SendCheckAsync(mozilla::Span<nsString const> aWord) -> RefPtr<CheckAsyncPromise>
{
    RefPtr<MozPromise<nsTArray<bool>, ResponseRejectReason, true>::Private> promise__ = new MozPromise<nsTArray<bool>, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendCheckAsync(std::forward<mozilla::Span<nsString const>>(aWord), [promise__](nsTArray<bool>&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PRemoteSpellcheckEngineChild::SendSetDictionary(
        const nsACString& aDictionary,
        bool* success) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemoteSpellcheckEngine::Msg_SetDictionary(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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

    UniquePtr<Message> reply__;

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

    bool sendok__ = false;
    {
        AUTO_PROFILER_MARKER("PRemoteSpellcheckEngine::Msg_SetDictionary", IPC);
        sendok__ = ChannelSend(std::move(msg__), (&(reply__)));
    }
    if ((!(sendok__))) {
        return false;
    }

    if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ChildSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PRemoteSpellcheckEngineChild",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Received reply ",
            reply__->type(),
            mozilla::ipc::MessageDirection::eReceiving);
    }

    IPC::MessageReader reader__{
            (*(reply__)),
            this};

    auto maybe__success__reply = IPC::ReadParam<bool>((&(reader__)));
    if (!maybe__success__reply) {
        FatalError("Error deserializing 'bool'");
        return false;

    }
    auto& success__reply = *maybe__success__reply;
    // Sentinel = 'success'
    if ((!(((&(reader__)))->ReadSentinel(200082170)))) {
        mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
        return false;
    }
    (*(success)) = std::move(success__reply);
    reader__.EndRead();

    return true;
}

auto PRemoteSpellcheckEngineChild::SendSetDictionaries(
        mozilla::Span<nsCString const> aDictionaries,
        mozilla::ipc::ResolveCallback<bool>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PRemoteSpellcheckEngine::Msg_SetDictionaries(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PRemoteSpellcheckEngine::Reply_SetDictionaries__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__success = IPC::ReadParam<bool>(aReader);
            if (!maybe__success) {
                (aReader)->FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& success = *maybe__success;
            // Sentinel = 'success'
            if ((!((aReader)->ReadSentinel(200082170)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(success));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PRemoteSpellcheckEngineChild::SendSetDictionaries(mozilla::Span<nsCString const> aDictionaries) -> RefPtr<SetDictionariesPromise>
{
    RefPtr<MozPromise<bool, ResponseRejectReason, true>::Private> promise__ = new MozPromise<bool, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendSetDictionaries(std::forward<mozilla::Span<nsCString const>>(aDictionaries), [promise__](bool&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PRemoteSpellcheckEngineChild::SendSuggest(
        const nsAString& aWord,
        const uint32_t& aCount,
        mozilla::ipc::ResolveCallback<nsTArray<nsString>>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PRemoteSpellcheckEngine::Msg_Suggest(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aWord);
    // Sentinel = 'aWord'
    ((&(writer__)))->WriteSentinel(98238974);
    IPC::WriteParam((&(writer__)), aCount);
    // Sentinel = 'aCount'
    ((&(writer__)))->WriteSentinel(134611563);


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

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PRemoteSpellcheckEngine::Reply_Suggest__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__aSuggestions = IPC::ReadParam<nsTArray<nsString>>(aReader);
            if (!maybe__aSuggestions) {
                (aReader)->FatalError("Error deserializing 'nsString[]'");
                return MsgValueError;

            }
            auto& aSuggestions = *maybe__aSuggestions;
            // Sentinel = 'aSuggestions'
            if ((!((aReader)->ReadSentinel(529204477)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString[]'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::move(aSuggestions));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PRemoteSpellcheckEngineChild::SendSuggest(
        const nsAString& aWord,
        const uint32_t& aCount) -> RefPtr<SuggestPromise>
{
    RefPtr<MozPromise<nsTArray<nsString>, ResponseRejectReason, true>::Private> promise__ = new MozPromise<nsTArray<nsString>, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendSuggest(std::forward<const nsAString&>(aWord), std::forward<const uint32_t&>(aCount), [promise__](nsTArray<nsString>&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

auto PRemoteSpellcheckEngineChild::SendSetDictionaryFromList(
        mozilla::Span<nsCString const> aList,
        mozilla::ipc::ResolveCallback<std::tuple<bool, nsCString>>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PRemoteSpellcheckEngine::Msg_SetDictionaryFromList(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PRemoteSpellcheckEngine::Reply_SetDictionaryFromList__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__aSuccess = IPC::ReadParam<bool>(aReader);
            if (!maybe__aSuccess) {
                (aReader)->FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& aSuccess = *maybe__aSuccess;
            // Sentinel = 'aSuccess'
            if ((!((aReader)->ReadSentinel(236323643)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            auto maybe__aDictionary = IPC::ReadParam<nsCString>(aReader);
            if (!maybe__aDictionary) {
                (aReader)->FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& aDictionary = *maybe__aDictionary;
            // Sentinel = 'aDictionary'
            if ((!((aReader)->ReadSentinel(430703736)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::make_tuple(std::move(aSuccess), std::move(aDictionary)));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PRemoteSpellcheckEngineChild::SendSetDictionaryFromList(mozilla::Span<nsCString const> aList) -> RefPtr<SetDictionaryFromListPromise>
{
    RefPtr<MozPromise<std::tuple<bool, nsCString>, ResponseRejectReason, true>::Private> promise__ = new MozPromise<std::tuple<bool, nsCString>, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendSetDictionaryFromList(std::forward<mozilla::Span<nsCString const>>(aList), [promise__](std::tuple<bool, nsCString>&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

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

auto PRemoteSpellcheckEngineChild::OnMessageReceived(const Message& msg__) -> PRemoteSpellcheckEngineChild::Result
{
    if (!CanSend()) {
        if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ChildSide)) {
            mozilla::ipc::LogMessageForProtocol(
                "PRemoteSpellcheckEngineChild",
                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 PRemoteSpellcheckEngine::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    case PRemoteSpellcheckEngine::Reply_CheckAsync__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteSpellcheckEngineChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PRemoteSpellcheckEngine::Msg_CheckAsync", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PRemoteSpellcheckEngine::Reply_SetDictionaries__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteSpellcheckEngineChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PRemoteSpellcheckEngine::Msg_SetDictionaries", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PRemoteSpellcheckEngine::Reply_Suggest__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteSpellcheckEngineChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PRemoteSpellcheckEngine::Msg_Suggest", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    case PRemoteSpellcheckEngine::Reply_SetDictionaryFromList__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteSpellcheckEngineChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PRemoteSpellcheckEngine::Msg_SetDictionaryFromList", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    default:
        return MsgNotKnown;
    }
}

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

    }
    return MsgNotKnown;
}



} // namespace mozilla
