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


#include "mozilla/dom/PRemoteWorkerNonLifeCycleOpControllerChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/dom/ClientIPCUtils.h"
#include "mozilla/dom/ReferrerInfoUtils.h"
#include "mozilla/dom/RemoteWorkerNonLifeCycleOpControllerChild.h"
#include "mozilla/dom/ServiceWorkerIPCUtils.h"
#include "mozilla/dom/WorkerIPCUtils.h"
#include "mozilla/ipc/IPCCore.h"
#include "nsIPrincipal.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 PRemoteWorkerNonLifeCycleOpControllerChild::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

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

MOZ_IMPLICIT PRemoteWorkerNonLifeCycleOpControllerChild::PRemoteWorkerNonLifeCycleOpControllerChild() :
    mozilla::ipc::IToplevelProtocol("PRemoteWorkerNonLifeCycleOpControllerChild", kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PRemoteWorkerNonLifeCycleOpControllerChild);
}

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

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

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

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

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

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

auto PRemoteWorkerNonLifeCycleOpControllerChild::SendTerminated() -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemoteWorkerNonLifeCycleOpController::Msg_Terminated(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PRemoteWorkerNonLifeCycleOpControllerChild::SendError(const ErrorValue& aValue) -> bool
{
    UniquePtr<IPC::Message> msg__ = PRemoteWorkerNonLifeCycleOpController::Msg_Error(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

auto PRemoteWorkerNonLifeCycleOpControllerChild::OnMessageReceived(const Message& msg__) -> PRemoteWorkerNonLifeCycleOpControllerChild::Result
{
    switch (msg__.type()) {
    case PRemoteWorkerNonLifeCycleOpController::Msg_ExecOp__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerNonLifeCycleOpController", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteWorkerNonLifeCycleOpControllerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteWorkerNonLifeCycleOpController::Msg_ExecOp", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aOpArgs = *maybe__aOpArgs;
            // Sentinel = 'aOpArgs'
            if ((!(((&(reader__)))->ReadSentinel(173212334)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'SharedWorkerOpArgs'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<RemoteWorkerNonLifeCycleOpControllerChild*>(this))->RecvExecOp(std::move(aOpArgs));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PRemoteWorkerNonLifeCycleOpController::Msg_ExecServiceWorkerOp__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerNonLifeCycleOpController", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteWorkerNonLifeCycleOpControllerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteWorkerNonLifeCycleOpController::Msg_ExecServiceWorkerOp", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aOpArgs = *maybe__aOpArgs;
            // Sentinel = 'aOpArgs'
            if ((!(((&(reader__)))->ReadSentinel(173212334)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ServiceWorkerOpArgs'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = MSG_ROUTING_CONTROL;
            UniquePtr<IPC::Message> reply__(PRemoteWorkerNonLifeCycleOpController::Reply_ExecServiceWorkerOp(id__));
            reply__->set_seqno(msg__.seqno());

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

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

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

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

            return MsgProcessed;
        }
    case PRemoteWorkerNonLifeCycleOpController::Msg_Shutdown__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PRemoteWorkerNonLifeCycleOpController", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PRemoteWorkerNonLifeCycleOpControllerChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PRemoteWorkerNonLifeCycleOpController::Msg_Shutdown", OTHER);

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



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

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

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

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

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

} // namespace IPC
