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


#include "mozilla/dom/PFetchEventOpChild.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/RemoteLazyInputStream.h"
#include "mozilla/dom/FetchEventOpChild.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/PRemoteWorkerControllerChild.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 PFetchEventOpChild::PFetchEventOpChild() :
    mozilla::ipc::IProtocol(kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PFetchEventOpChild);
}

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

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

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

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

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

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

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

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

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

auto PFetchEventOpChild::SendPreloadResponse(const ParentToParentInternalResponse& aResponse) -> bool
{
    UniquePtr<IPC::Message> msg__ = PFetchEventOp::Msg_PreloadResponse(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PFetchEventOpChild::SendPreloadResponseTiming(const ResponseTiming& aTiming) -> bool
{
    UniquePtr<IPC::Message> msg__ = PFetchEventOp::Msg_PreloadResponseTiming(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PFetchEventOpChild::SendPreloadResponseEnd(const ResponseEndArgs& aArgs) -> bool
{
    UniquePtr<IPC::Message> msg__ = PFetchEventOp::Msg_PreloadResponseEnd(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aScriptSpec = *maybe__aScriptSpec;
            // Sentinel = 'aScriptSpec'
            if ((!(((&(reader__)))->ReadSentinel(436929634)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__aLineNumber = IPC::ReadParam<uint32_t>((&(reader__)));
            if (!maybe__aLineNumber) {
                FatalError("Error deserializing 'uint32_t'");
                return MsgValueError;

            }
            auto& aLineNumber = *maybe__aLineNumber;
            // Sentinel = 'aLineNumber'
            if ((!(((&(reader__)))->ReadSentinel(423953491)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            auto maybe__aColumnNumber = IPC::ReadParam<uint32_t>((&(reader__)));
            if (!maybe__aColumnNumber) {
                FatalError("Error deserializing 'uint32_t'");
                return MsgValueError;

            }
            auto& aColumnNumber = *maybe__aColumnNumber;
            // Sentinel = 'aColumnNumber'
            if ((!(((&(reader__)))->ReadSentinel(601163065)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            auto maybe__aMessageName = IPC::ReadParam<nsCString>((&(reader__)));
            if (!maybe__aMessageName) {
                FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& aMessageName = *maybe__aMessageName;
            // Sentinel = 'aMessageName'
            if ((!(((&(reader__)))->ReadSentinel(505414824)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__aParams = IPC::ReadParam<nsTArray<nsString>>((&(reader__)));
            if (!maybe__aParams) {
                FatalError("Error deserializing 'nsString[]'");
                return MsgValueError;

            }
            auto& aParams = *maybe__aParams;
            // Sentinel = 'aParams'
            if ((!(((&(reader__)))->ReadSentinel(178979526)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsString[]'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<FetchEventOpChild*>(this))->RecvAsyncLog(std::move(aScriptSpec), std::move(aLineNumber), std::move(aColumnNumber), std::move(aMessageName), std::move(aParams));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PFetchEventOp::Msg_RespondWith__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PFetchEventOp", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PFetchEventOpChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PFetchEventOp::Msg_RespondWith", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aResult = *maybe__aResult;
            // Sentinel = 'aResult'
            if ((!(((&(reader__)))->ReadSentinel(185205473)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ParentToParentFetchEventRespondWithResult'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<FetchEventOpChild*>(this))->RecvRespondWith(std::move(aResult));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aResult = *maybe__aResult;
            // Sentinel = 'aResult'
            if ((!(((&(reader__)))->ReadSentinel(185205473)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ServiceWorkerFetchEventOpResult'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<FetchEventOpChild*>(this))->Recv__delete__(std::move(aResult));
            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 PFetchEventOpChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PFetchEventOpChild::Result
{
    return MsgNotKnown;
}



} // namespace dom
} // namespace mozilla
namespace IPC {
auto ParamTraits<::mozilla::dom::PFetchEventOpChild*>::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::PFetchEventOpChild*>::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::PFetchEventOpChild*>(actor);
}

} // namespace IPC
