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


#include "mozilla/dom/PJSValidatorChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/JSValidatorChild.h"

#include "mozilla/dom/PJSOracleChild.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 PJSValidatorChild::Recv__delete__() -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

MOZ_IMPLICIT PJSValidatorChild::PJSValidatorChild() :
    mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PJSValidatorChild);
}

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

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

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

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

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

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

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

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

auto PJSValidatorChild::OnMessageReceived(const Message& msg__) -> PJSValidatorChild::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 PJSValidator::Msg_IsOpaqueResponseAllowed__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PJSValidator", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PJSValidatorChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PJSValidator::Msg_IsOpaqueResponseAllowed", OTHER);

            mozilla::ipc::ActorId id__ = Id();
            UniquePtr<IPC::Message> reply__(PJSValidator::Reply_IsOpaqueResponseAllowed(id__));
            reply__->set_seqno(msg__.seqno());

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

            IsOpaqueResponseAllowedResolver resolver = [resolver__ = std::move(resolver__)](std::tuple<mozilla::Maybe<Shmem>&&, const ValidatorResult&> aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), std::move(std::get<0>(aParam)));
                    // Sentinel = 'aMem'
                    ((&(writer__)))->WriteSentinel(61211009);
                    IPC::WriteParam((&(writer__)), std::get<1>(aParam));
                    // Sentinel = 'aResult'
                    ((&(writer__)))->WriteSentinel(185205473);

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

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

            return MsgProcessed;
        }
    case PJSValidator::Msg_OnDataAvailable__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PJSValidator", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PJSValidatorChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PJSValidator::Msg_OnDataAvailable", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aData = *maybe__aData;
            // Sentinel = 'aData'
            if ((!(((&(reader__)))->ReadSentinel(90571228)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'Shmem'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<JSValidatorChild*>(this))->RecvOnDataAvailable(std::move(aData));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PJSValidator::Msg_OnStopRequest__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PJSValidator", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PJSValidatorChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PJSValidator::Msg_OnStopRequest", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aReason = *maybe__aReason;
            // Sentinel = 'aReason'
            if ((!(((&(reader__)))->ReadSentinel(180093642)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsresult'");
                return MsgValueError;
            }
            auto maybe__aContentCharset = IPC::ReadParam<nsCString>((&(reader__)));
            if (!maybe__aContentCharset) {
                FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& aContentCharset = *maybe__aContentCharset;
            // Sentinel = 'aContentCharset'
            if ((!(((&(reader__)))->ReadSentinel(791152135)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__aHintCharset = IPC::ReadParam<nsString>((&(reader__)));
            if (!maybe__aHintCharset) {
                FatalError("Error deserializing 'nsString'");
                return MsgValueError;

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

            }
            auto& aDocumentCharset = *maybe__aDocumentCharset;
            // Sentinel = 'aDocumentCharset'
            if ((!(((&(reader__)))->ReadSentinel(895026795)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<JSValidatorChild*>(this))->RecvOnStopRequest(std::move(aReason), std::move(aContentCharset), std::move(aHintCharset), std::move(aDocumentCharset));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PJSValidator::Msg___delete____ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PJSValidator", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PJSValidatorChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PJSValidator::Msg___delete__", OTHER);

            mozilla::ipc::IPCResult __ok = (static_cast<JSValidatorChild*>(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;
        }
    default:
        return MsgNotKnown;
    }
}

auto PJSValidatorChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PJSValidatorChild::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}



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

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

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

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

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

} // namespace IPC
