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


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

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

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

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

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

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

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

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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aCloneEndpoint = *maybe__aCloneEndpoint;
            // Sentinel = 'aCloneEndpoint'
            if ((!(((&(reader__)))->ReadSentinel(678036884)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'Endpoint<::mozilla::PRemoteLazyInputStreamParent>'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<RemoteLazyInputStreamParent*>(this))->RecvClone(std::move(aCloneEndpoint));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PRemoteLazyInputStream::Msg_StreamNeeded__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteLazyInputStream", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteLazyInputStreamParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteLazyInputStream::Msg_StreamNeeded", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aStart = *maybe__aStart;
            // Sentinel = 'aStart'
            if ((!(((&(reader__)))->ReadSentinel(137757296)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint64_t'");
                return MsgValueError;
            }
            auto maybe__aLength = IPC::ReadParam<uint64_t>((&(reader__)));
            if (!maybe__aLength) {
                FatalError("Error deserializing 'uint64_t'");
                return MsgValueError;

            }
            auto& aLength = *maybe__aLength;
            // Sentinel = 'aLength'
            if ((!(((&(reader__)))->ReadSentinel(179045060)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint64_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = MSG_ROUTING_CONTROL;
            UniquePtr<IPC::Message> reply__(PRemoteLazyInputStream::Reply_StreamNeeded(id__));
            reply__->set_seqno(msg__.seqno());

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

            StreamNeededResolver resolver = [resolver__ = std::move(resolver__)](const mozilla::Maybe<IPCStream>& aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), aParam);
                    // Sentinel = 'stream'
                    ((&(writer__)))->WriteSentinel(153223821);

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

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

            return MsgProcessed;
        }
    case PRemoteLazyInputStream::Msg_LengthNeeded__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteLazyInputStream", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteLazyInputStreamParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteLazyInputStream::Msg_LengthNeeded", OTHER);

            mozilla::ipc::ActorId id__ = MSG_ROUTING_CONTROL;
            UniquePtr<IPC::Message> reply__(PRemoteLazyInputStream::Reply_LengthNeeded(id__));
            reply__->set_seqno(msg__.seqno());

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

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

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

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

            return MsgProcessed;
        }
    case PRemoteLazyInputStream::Msg_Goodbye__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteLazyInputStream", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteLazyInputStreamParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteLazyInputStream::Msg_Goodbye", OTHER);

            mozilla::ipc::IPCResult __ok = (static_cast<RemoteLazyInputStreamParent*>(this))->RecvGoodbye();
            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 PRemoteLazyInputStreamParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PRemoteLazyInputStreamParent::Result
{
    MOZ_ASSERT_UNREACHABLE("message protocol not supported");
    return MsgNotKnown;
}



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

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

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

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

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

} // namespace IPC
