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


#include "mozilla/net/PAltServiceParent.h"
#include "mozilla/AntiTrackingIPCUtils.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/dom/DomSecurityIPCUtils.h"
#include "mozilla/dom/FeaturePolicyUtils.h"
#include "mozilla/dom/FetchIPCTypes.h"
#include "mozilla/dom/NavigationAPIIPCUtils.h"
#include "mozilla/dom/PropertyBagUtils.h"
#include "mozilla/dom/ReferrerInfoUtils.h"
#include "mozilla/dom/SessionHistoryEntry.h"
#include "mozilla/ipc/URIUtils.h"
#include "mozilla/net/AltServiceParent.h"
#include "mozilla/net/CacheInfoIPCTypes.h"
#include "mozilla/net/ClassOfService.h"
#include "nsDOMNavigationTiming.h"
#include "nsDocShellLoadState.h"
#include "nsHttp.h"
#include "nsHttpResponseHead.h"
#include "nsIPropertyBag2.h"

#include "mozilla/net/PSocketProcessParent.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 net {


MOZ_IMPLICIT PAltServiceParent::PAltServiceParent() :
    mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PAltServiceParent);
}

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

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

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

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

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

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

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

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

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

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


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

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

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

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

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

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& host = *maybe__host;
            // Sentinel = 'host'
            if ((!(((&(reader__)))->ReadSentinel(72024511)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__port = IPC::ReadParam<int32_t>((&(reader__)));
            if (!maybe__port) {
                FatalError("Error deserializing 'int32_t'");
                return MsgValueError;

            }
            auto& port = *maybe__port;
            // Sentinel = 'port'
            if ((!(((&(reader__)))->ReadSentinel(73990598)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int32_t'");
                return MsgValueError;
            }
            auto maybe__originAttributes = IPC::ReadParam<OriginAttributes>((&(reader__)));
            if (!maybe__originAttributes) {
                FatalError("Error deserializing 'OriginAttributes'");
                return MsgValueError;

            }
            auto& originAttributes = *maybe__originAttributes;
            // Sentinel = 'originAttributes'
            if ((!(((&(reader__)))->ReadSentinel(947259056)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'OriginAttributes'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<AltServiceParent*>(this))->RecvClearHostMapping(std::move(host), std::move(port), std::move(originAttributes));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PAltService::Msg_ProcessHeader__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PAltService", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PAltServiceParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PAltService::Msg_ProcessHeader", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& buf = *maybe__buf;
            // Sentinel = 'buf'
            if ((!(((&(reader__)))->ReadSentinel(41484606)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__originScheme = IPC::ReadParam<nsCString>((&(reader__)));
            if (!maybe__originScheme) {
                FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& originScheme = *maybe__originScheme;
            // Sentinel = 'originScheme'
            if ((!(((&(reader__)))->ReadSentinel(538445022)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__originHost = IPC::ReadParam<nsCString>((&(reader__)));
            if (!maybe__originHost) {
                FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& originHost = *maybe__originHost;
            // Sentinel = 'originHost'
            if ((!(((&(reader__)))->ReadSentinel(383648807)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__originPort = IPC::ReadParam<int32_t>((&(reader__)));
            if (!maybe__originPort) {
                FatalError("Error deserializing 'int32_t'");
                return MsgValueError;

            }
            auto& originPort = *maybe__originPort;
            // Sentinel = 'originPort'
            if ((!(((&(reader__)))->ReadSentinel(385614894)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'int32_t'");
                return MsgValueError;
            }
            auto maybe__username = IPC::ReadParam<nsCString>((&(reader__)));
            if (!maybe__username) {
                FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& username = *maybe__username;
            // Sentinel = 'username'
            if ((!(((&(reader__)))->ReadSentinel(260506465)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            auto maybe__privateBrowsing = IPC::ReadParam<bool>((&(reader__)));
            if (!maybe__privateBrowsing) {
                FatalError("Error deserializing 'bool'");
                return MsgValueError;

            }
            auto& privateBrowsing = *maybe__privateBrowsing;
            // Sentinel = 'privateBrowsing'
            if ((!(((&(reader__)))->ReadSentinel(844957255)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            auto maybe__proxyInfo = IPC::ReadParam<nsTArray<ProxyInfoCloneArgs>>((&(reader__)));
            if (!maybe__proxyInfo) {
                FatalError("Error deserializing 'ProxyInfoCloneArgs[]'");
                return MsgValueError;

            }
            auto& proxyInfo = *maybe__proxyInfo;
            // Sentinel = 'proxyInfo'
            if ((!(((&(reader__)))->ReadSentinel(325583823)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'ProxyInfoCloneArgs[]'");
                return MsgValueError;
            }
            auto maybe__caps = IPC::ReadParam<uint32_t>((&(reader__)));
            if (!maybe__caps) {
                FatalError("Error deserializing 'uint32_t'");
                return MsgValueError;

            }
            auto& caps = *maybe__caps;
            // Sentinel = 'caps'
            if ((!(((&(reader__)))->ReadSentinel(67502504)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            auto maybe__originAttributes = IPC::ReadParam<OriginAttributes>((&(reader__)));
            if (!maybe__originAttributes) {
                FatalError("Error deserializing 'OriginAttributes'");
                return MsgValueError;

            }
            auto& originAttributes = *maybe__originAttributes;
            // Sentinel = 'originAttributes'
            if ((!(((&(reader__)))->ReadSentinel(947259056)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'OriginAttributes'");
                return MsgValueError;
            }
            auto maybe__connInfoArgs = IPC::ReadParam<HttpConnectionInfoCloneArgs>((&(reader__)));
            if (!maybe__connInfoArgs) {
                FatalError("Error deserializing 'HttpConnectionInfoCloneArgs'");
                return MsgValueError;

            }
            auto& connInfoArgs = *maybe__connInfoArgs;
            // Sentinel = 'connInfoArgs'
            if ((!(((&(reader__)))->ReadSentinel(521340104)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'HttpConnectionInfoCloneArgs'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<AltServiceParent*>(this))->RecvProcessHeader(std::move(buf), std::move(originScheme), std::move(originHost), std::move(originPort), std::move(username), std::move(privateBrowsing), std::move(proxyInfo), std::move(caps), std::move(originAttributes), std::move(connInfoArgs));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

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

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



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

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

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

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

        return {};
    }
    return static_cast<::mozilla::net::PAltServiceParent*>(actor);
}

} // namespace IPC
