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


#include "mozilla/PRemoteSpellcheckEngineParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/RemoteSpellCheckEngineChild.h"
#include "mozilla/RemoteSpellCheckEngineParent.h"

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


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

MOZ_IMPLICIT PRemoteSpellcheckEngineParent::PRemoteSpellcheckEngineParent() :
    mozilla::ipc::IProtocol(kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PRemoteSpellcheckEngineParent);
}

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

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

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

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

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

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

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

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

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

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

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

auto PRemoteSpellcheckEngineParent::OnMessageReceived(const Message& msg__) -> PRemoteSpellcheckEngineParent::Result
{
    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::Msg___delete____ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteSpellcheckEngineParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteSpellcheckEngine::Msg___delete__", OTHER);

            mozilla::ipc::IPCResult __ok = (static_cast<RemoteSpellcheckEngineParent*>(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 PRemoteSpellcheckEngine::Msg_CheckAsync__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteSpellcheckEngineParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteSpellcheckEngine::Msg_CheckAsync", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__aWord = IPC::ReadParam<nsTArray<nsString>>((&(reader__)));
            if (!maybe__aWord) {
                FatalError("Error deserializing 'nsString[]'");
                return MsgValueError;

            }
            auto& aWord = *maybe__aWord;
            // Sentinel = 'aWord'
            if ((!(((&(reader__)))->ReadSentinel(98238974)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString[]'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = Id();
            UniquePtr<IPC::Message> reply__(PRemoteSpellcheckEngine::Reply_CheckAsync(id__));
            reply__->set_seqno(msg__.seqno());

            RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
                new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);

            CheckAsyncResolver resolver = [resolver__ = std::move(resolver__)](mozilla::Span<bool const> aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), aParam);
                    // Sentinel = 'aIsMisspelled'
                    ((&(writer__)))->WriteSentinel(595723568);

                    if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ParentSide)) {
                        mozilla::ipc::LogMessageForProtocol(
                            "PRemoteSpellcheckEngineParent",
                            self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
                            "Sending reply ",
                            reply__->type(),
                            mozilla::ipc::MessageDirection::eSending);
                    }

                });
            };
            mozilla::ipc::IPCResult __ok = (static_cast<RemoteSpellcheckEngineParent*>(this))->RecvCheckAsync(std::move(aWord), std::move(resolver));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PRemoteSpellcheckEngine::Msg_SetDictionaries__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteSpellcheckEngineParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteSpellcheckEngine::Msg_SetDictionaries", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__aDictionaries = IPC::ReadParam<nsTArray<nsCString>>((&(reader__)));
            if (!maybe__aDictionaries) {
                FatalError("Error deserializing 'nsCString[]'");
                return MsgValueError;

            }
            auto& aDictionaries = *maybe__aDictionaries;
            // Sentinel = 'aDictionaries'
            if ((!(((&(reader__)))->ReadSentinel(598279488)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString[]'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = Id();
            UniquePtr<IPC::Message> reply__(PRemoteSpellcheckEngine::Reply_SetDictionaries(id__));
            reply__->set_seqno(msg__.seqno());

            RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
                new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);

            SetDictionariesResolver resolver = [resolver__ = std::move(resolver__)](const bool& aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), aParam);
                    // Sentinel = 'success'
                    ((&(writer__)))->WriteSentinel(200082170);

                    if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ParentSide)) {
                        mozilla::ipc::LogMessageForProtocol(
                            "PRemoteSpellcheckEngineParent",
                            self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
                            "Sending reply ",
                            reply__->type(),
                            mozilla::ipc::MessageDirection::eSending);
                    }

                });
            };
            mozilla::ipc::IPCResult __ok = (static_cast<RemoteSpellcheckEngineParent*>(this))->RecvSetDictionaries(std::move(aDictionaries), std::move(resolver));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PRemoteSpellcheckEngine::Msg_Suggest__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteSpellcheckEngineParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteSpellcheckEngine::Msg_Suggest", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aWord = *maybe__aWord;
            // Sentinel = 'aWord'
            if ((!(((&(reader__)))->ReadSentinel(98238974)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            auto maybe__aCount = IPC::ReadParam<uint32_t>((&(reader__)));
            if (!maybe__aCount) {
                FatalError("Error deserializing 'uint32_t'");
                return MsgValueError;

            }
            auto& aCount = *maybe__aCount;
            // Sentinel = 'aCount'
            if ((!(((&(reader__)))->ReadSentinel(134611563)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = Id();
            UniquePtr<IPC::Message> reply__(PRemoteSpellcheckEngine::Reply_Suggest(id__));
            reply__->set_seqno(msg__.seqno());

            RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
                new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);

            SuggestResolver resolver = [resolver__ = std::move(resolver__)](mozilla::Span<nsString const> aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), aParam);
                    // Sentinel = 'aSuggestions'
                    ((&(writer__)))->WriteSentinel(529204477);

                    if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ParentSide)) {
                        mozilla::ipc::LogMessageForProtocol(
                            "PRemoteSpellcheckEngineParent",
                            self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
                            "Sending reply ",
                            reply__->type(),
                            mozilla::ipc::MessageDirection::eSending);
                    }

                });
            };
            mozilla::ipc::IPCResult __ok = (static_cast<RemoteSpellcheckEngineParent*>(this))->RecvSuggest(std::move(aWord), std::move(aCount), std::move(resolver));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PRemoteSpellcheckEngine::Msg_SetDictionaryFromList__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteSpellcheckEngineParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteSpellcheckEngine::Msg_SetDictionaryFromList", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

            auto maybe__aList = IPC::ReadParam<nsTArray<nsCString>>((&(reader__)));
            if (!maybe__aList) {
                FatalError("Error deserializing 'nsCString[]'");
                return MsgValueError;

            }
            auto& aList = *maybe__aList;
            // Sentinel = 'aList'
            if ((!(((&(reader__)))->ReadSentinel(95355390)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString[]'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = Id();
            UniquePtr<IPC::Message> reply__(PRemoteSpellcheckEngine::Reply_SetDictionaryFromList(id__));
            reply__->set_seqno(msg__.seqno());

            RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
                new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);

            SetDictionaryFromListResolver resolver = [resolver__ = std::move(resolver__)](std::tuple<const bool&, const nsACString&> aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), std::get<0>(aParam));
                    // Sentinel = 'aSuccess'
                    ((&(writer__)))->WriteSentinel(236323643);
                    IPC::WriteParam((&(writer__)), std::get<1>(aParam));
                    // Sentinel = 'aDictionary'
                    ((&(writer__)))->WriteSentinel(430703736);

                    if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ParentSide)) {
                        mozilla::ipc::LogMessageForProtocol(
                            "PRemoteSpellcheckEngineParent",
                            self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
                            "Sending reply ",
                            reply__->type(),
                            mozilla::ipc::MessageDirection::eSending);
                    }

                });
            };
            mozilla::ipc::IPCResult __ok = (static_cast<RemoteSpellcheckEngineParent*>(this))->RecvSetDictionaryFromList(std::move(aList), std::move(resolver));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

auto PRemoteSpellcheckEngineParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PRemoteSpellcheckEngineParent::Result
{
    switch (msg__.type()) {
    case PRemoteSpellcheckEngine::Msg_SetDictionary__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteSpellcheckEngineParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteSpellcheckEngine::Msg_SetDictionary", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aDictionary = *maybe__aDictionary;
            // Sentinel = 'aDictionary'
            if ((!(((&(reader__)))->ReadSentinel(430703736)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = Id();
            bool success{};
            mozilla::ipc::IPCResult __ok = (static_cast<RemoteSpellcheckEngineParent*>(this))->RecvSetDictionary(std::move(aDictionary), (&(success)));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            reply__ = PRemoteSpellcheckEngine::Reply_SetDictionary(id__);
            IPC::MessageWriter writer__{
                    (*(reply__)),
                    this};

            IPC::WriteParam((&(writer__)), success);
            // Sentinel = 'success'
            ((&(writer__)))->WriteSentinel(200082170);
            if (mozilla::ipc::LoggingEnabledFor("PRemoteSpellcheckEngine", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteSpellcheckEngineParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Sending reply ",
                    reply__->type(),
                    mozilla::ipc::MessageDirection::eSending);
            }
            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}



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

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

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

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

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

} // namespace IPC
