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


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


auto PAltServiceChild::Recv__delete__() -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

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

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

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

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

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

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

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

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

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

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

auto PAltServiceChild::SendClearHostMapping(
        const nsACString& host,
        const int32_t& port,
        const OriginAttributes& originAttributes) -> bool
{
    UniquePtr<IPC::Message> msg__ = PAltService::Msg_ClearHostMapping(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), host);
    // Sentinel = 'host'
    ((&(writer__)))->WriteSentinel(72024511);
    IPC::WriteParam((&(writer__)), port);
    // Sentinel = 'port'
    ((&(writer__)))->WriteSentinel(73990598);
    IPC::WriteParam((&(writer__)), originAttributes);
    // Sentinel = 'originAttributes'
    ((&(writer__)))->WriteSentinel(947259056);


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

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

auto PAltServiceChild::SendProcessHeader(
        const nsACString& buf,
        const nsACString& originScheme,
        const nsACString& originHost,
        const int32_t& originPort,
        const nsACString& username,
        const bool& privateBrowsing,
        mozilla::Span<ProxyInfoCloneArgs const> proxyInfo,
        const uint32_t& caps,
        const OriginAttributes& originAttributes,
        const HttpConnectionInfoCloneArgs& connInfoArgs) -> bool
{
    UniquePtr<IPC::Message> msg__ = PAltService::Msg_ProcessHeader(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), buf);
    // Sentinel = 'buf'
    ((&(writer__)))->WriteSentinel(41484606);
    IPC::WriteParam((&(writer__)), originScheme);
    // Sentinel = 'originScheme'
    ((&(writer__)))->WriteSentinel(538445022);
    IPC::WriteParam((&(writer__)), originHost);
    // Sentinel = 'originHost'
    ((&(writer__)))->WriteSentinel(383648807);
    IPC::WriteParam((&(writer__)), originPort);
    // Sentinel = 'originPort'
    ((&(writer__)))->WriteSentinel(385614894);
    IPC::WriteParam((&(writer__)), username);
    // Sentinel = 'username'
    ((&(writer__)))->WriteSentinel(260506465);
    IPC::WriteParam((&(writer__)), privateBrowsing);
    // Sentinel = 'privateBrowsing'
    ((&(writer__)))->WriteSentinel(844957255);
    IPC::WriteParam((&(writer__)), proxyInfo);
    // Sentinel = 'proxyInfo'
    ((&(writer__)))->WriteSentinel(325583823);
    IPC::WriteParam((&(writer__)), caps);
    // Sentinel = 'caps'
    ((&(writer__)))->WriteSentinel(67502504);
    IPC::WriteParam((&(writer__)), originAttributes);
    // Sentinel = 'originAttributes'
    ((&(writer__)))->WriteSentinel(947259056);
    IPC::WriteParam((&(writer__)), connInfoArgs);
    // Sentinel = 'connInfoArgs'
    ((&(writer__)))->WriteSentinel(521340104);


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

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

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

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

            mozilla::ipc::IPCResult __ok = (static_cast<AltServiceChild*>(this))->Recv__delete__();
            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 PAltServiceChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PAltServiceChild::Result
{
    return MsgNotKnown;
}



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

} // namespace IPC
