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


#include "mozilla/dom/PFetchParent.h"
#include "ipc/ErrorIPCUtils.h"
#include "mozilla/AntiTrackingIPCUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/RemoteLazyInputStream.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/BindingIPCUtils.h"
#include "mozilla/dom/ClientIPCUtils.h"
#include "mozilla/dom/DomSecurityIPCUtils.h"
#include "mozilla/dom/FeaturePolicyUtils.h"
#include "mozilla/dom/FetchIPCTypes.h"
#include "mozilla/dom/FetchParent.h"
#include "mozilla/dom/NavigationAPIIPCUtils.h"
#include "mozilla/dom/PropertyBagUtils.h"
#include "mozilla/dom/ReferrerInfoUtils.h"
#include "mozilla/dom/ServiceWorkerIPCUtils.h"
#include "mozilla/dom/SessionHistoryEntry.h"
#include "mozilla/dom/WorkerIPCUtils.h"
#include "mozilla/ipc/IPCCore.h"
#include "mozilla/ipc/TransportSecurityInfoUtils.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/net/CacheInfoIPCTypes.h"
#include "mozilla/net/ClassOfService.h"
#include "nsDOMNavigationTiming.h"
#include "nsDocShellLoadState.h"
#include "nsHttp.h"
#include "nsHttpResponseHead.h"
#include "nsID.h"
#include "nsIPropertyBag2.h"
#include "nsITransportSecurityInfo.h"

#include "mozilla/ipc/PBackgroundParent.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 PFetchParent::PFetchParent() :
    mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PFetchParent);
}

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

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

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

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

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

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

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

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

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

auto PFetchParent::SendOnResponseAvailableInternal(const ParentToChildInternalResponse& aResponse) -> bool
{
    UniquePtr<IPC::Message> msg__ = PFetch::Msg_OnResponseAvailableInternal(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PFetchParent::SendOnResponseEnd(const ResponseEndArgs& aResponseEndArgs) -> bool
{
    UniquePtr<IPC::Message> msg__ = PFetch::Msg_OnResponseEnd(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PFetchParent::SendOnDataAvailable() -> bool
{
    UniquePtr<IPC::Message> msg__ = PFetch::Msg_OnDataAvailable(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

auto PFetchParent::SendOnFlushConsoleReport(mozilla::Span<ConsoleReportCollected const> aReports) -> bool
{
    UniquePtr<IPC::Message> msg__ = PFetch::Msg_OnFlushConsoleReport(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PFetchParent::SendOnCSPViolationEvent(const nsAString& aJSON) -> bool
{
    UniquePtr<IPC::Message> msg__ = PFetch::Msg_OnCSPViolationEvent(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PFetchParent::SendOnReportPerformanceTiming(const ResponseTiming& aTiming) -> bool
{
    UniquePtr<IPC::Message> msg__ = PFetch::Msg_OnReportPerformanceTiming(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PFetchParent::SendOnNotifyNetworkMonitorAlternateStack(const uint64_t& aChannelID) -> bool
{
    UniquePtr<IPC::Message> msg__ = PFetch::Msg_OnNotifyNetworkMonitorAlternateStack(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

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

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

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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

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

            return MsgProcessed;
        }
    case PFetch::Msg_AbortFetchOp__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PFetch", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PFetchParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PFetch::Msg_AbortFetchOp", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& aForceAbort = *maybe__aForceAbort;
            // Sentinel = 'aForceAbort'
            if ((!(((&(reader__)))->ReadSentinel(418251849)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<FetchParent*>(this))->RecvAbortFetchOp(std::move(aForceAbort));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

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

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



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

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

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

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

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

} // namespace IPC
