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


#include "mozilla/dom/PFetchEventOpProxyChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/RemoteLazyInputStream.h"
#include "mozilla/dom/FetchEventOpProxyChild.h"
#include "mozilla/dom/FetchIPCTypes.h"
#include "mozilla/dom/ServiceWorkerIPCUtils.h"
#include "mozilla/ipc/TransportSecurityInfoUtils.h"
#include "nsID.h"
#include "nsITransportSecurityInfo.h"

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


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

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

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

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

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

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

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

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

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

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

auto PFetchEventOpProxyChild::SendAsyncLog(
        const nsACString& aScriptSpec,
        const uint32_t& aLineNumber,
        const uint32_t& aColumnNumber,
        const nsACString& aMessageName,
        mozilla::Span<nsString const> aParams) -> bool
{
    UniquePtr<IPC::Message> msg__ = PFetchEventOpProxy::Msg_AsyncLog(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aScriptSpec);
    // Sentinel = 'aScriptSpec'
    ((&(writer__)))->WriteSentinel(436929634);
    IPC::WriteParam((&(writer__)), aLineNumber);
    // Sentinel = 'aLineNumber'
    ((&(writer__)))->WriteSentinel(423953491);
    IPC::WriteParam((&(writer__)), aColumnNumber);
    // Sentinel = 'aColumnNumber'
    ((&(writer__)))->WriteSentinel(601163065);
    IPC::WriteParam((&(writer__)), aMessageName);
    // Sentinel = 'aMessageName'
    ((&(writer__)))->WriteSentinel(505414824);
    IPC::WriteParam((&(writer__)), aParams);
    // Sentinel = 'aParams'
    ((&(writer__)))->WriteSentinel(178979526);


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

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

auto PFetchEventOpProxyChild::SendRespondWith(const ChildToParentFetchEventRespondWithResult& aResult) -> bool
{
    UniquePtr<IPC::Message> msg__ = PFetchEventOpProxy::Msg_RespondWith(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

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

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

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

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

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

auto PFetchEventOpProxyChild::OnMessageReceived(const Message& msg__) -> PFetchEventOpProxyChild::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 PFetchEventOpProxy::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    case PFetchEventOpProxy::Msg_PreloadResponse__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PFetchEventOpProxy", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PFetchEventOpProxyChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PFetchEventOpProxy::Msg_PreloadResponse", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aResponse = *maybe__aResponse;
            // Sentinel = 'aResponse'
            if ((!(((&(reader__)))->ReadSentinel(301466545)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ParentToChildInternalResponse'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<FetchEventOpProxyChild*>(this))->RecvPreloadResponse(std::move(aResponse));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PFetchEventOpProxy::Msg_PreloadResponseTiming__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PFetchEventOpProxy", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PFetchEventOpProxyChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PFetchEventOpProxy::Msg_PreloadResponseTiming", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aTiming = *maybe__aTiming;
            // Sentinel = 'aTiming'
            if ((!(((&(reader__)))->ReadSentinel(182780618)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ResponseTiming'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<FetchEventOpProxyChild*>(this))->RecvPreloadResponseTiming(std::move(aTiming));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PFetchEventOpProxy::Msg_PreloadResponseEnd__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PFetchEventOpProxy", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PFetchEventOpProxyChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PFetchEventOpProxy::Msg_PreloadResponseEnd", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aArgs = *maybe__aArgs;
            // Sentinel = 'aArgs'
            if ((!(((&(reader__)))->ReadSentinel(92602863)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ResponseEndArgs'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<FetchEventOpProxyChild*>(this))->RecvPreloadResponseEnd(std::move(aArgs));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

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



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

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

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

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

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

} // namespace IPC
