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


#include "mozilla/dom/PFetchEventOpParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/RemoteLazyInputStream.h"
#include "mozilla/dom/FetchEventOpParent.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/PRemoteWorkerControllerParent.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 PFetchEventOpParent::PFetchEventOpParent() :
    mozilla::ipc::IProtocol(kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PFetchEventOpParent);
}

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

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

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

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

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

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

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

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

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

auto PFetchEventOpParent::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__ = PFetchEventOp::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("PFetchEventOp", mozilla::ipc::ParentSide)) {
        mozilla::ipc::LogMessageForProtocol(
            "PFetchEventOpParent",
            this->ToplevelProtocol()->OtherPidMaybeInvalid(),
            "Sending ",
            msg__->type(),
            mozilla::ipc::MessageDirection::eSending);
    }
    AUTO_PROFILER_LABEL("PFetchEventOp::Msg_AsyncLog", OTHER);

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

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

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


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

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

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

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

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

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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aResponse = *maybe__aResponse;
            // Sentinel = 'aResponse'
            if ((!(((&(reader__)))->ReadSentinel(301466545)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ParentToParentInternalResponse'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<FetchEventOpParent*>(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 PFetchEventOp::Msg_PreloadResponseTiming__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PFetchEventOp", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PFetchEventOpParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PFetchEventOp::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<FetchEventOpParent*>(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 PFetchEventOp::Msg_PreloadResponseEnd__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PFetchEventOp", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PFetchEventOpParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PFetchEventOp::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<FetchEventOpParent*>(this))->RecvPreloadResponseEnd(std::move(aArgs));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PFetchEventOp::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

auto PFetchEventOpParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PFetchEventOpParent::Result
{
    return MsgNotKnown;
}



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

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

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

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

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

} // namespace IPC
