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


#include "mozilla/net/PNativeDNSResolverOverrideParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/net/NativeDNSResolverOverrideParent.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 PNativeDNSResolverOverrideParent::PNativeDNSResolverOverrideParent() :
    mozilla::ipc::IRefCountedProtocol(kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PNativeDNSResolverOverrideParent);
}

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

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

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

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

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

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

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

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

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

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


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

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

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

auto PNativeDNSResolverOverrideParent::SendAddIPOverride(
        const nsACString& aHost,
        const nsACString& aIPLiteral) -> bool
{
    UniquePtr<IPC::Message> msg__ = PNativeDNSResolverOverride::Msg_AddIPOverride(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aHost);
    // Sentinel = 'aHost'
    ((&(writer__)))->WriteSentinel(95486464);
    IPC::WriteParam((&(writer__)), aIPLiteral);
    // Sentinel = 'aIPLiteral'
    ((&(writer__)))->WriteSentinel(332071880);


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

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

auto PNativeDNSResolverOverrideParent::SendAddHTTPSRecordOverride(
        const nsACString& aHost,
        mozilla::Span<uint8_t const> aData) -> bool
{
    UniquePtr<IPC::Message> msg__ = PNativeDNSResolverOverride::Msg_AddHTTPSRecordOverride(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aHost);
    // Sentinel = 'aHost'
    ((&(writer__)))->WriteSentinel(95486464);
    IPC::WriteParam((&(writer__)), aData);
    // Sentinel = 'aData'
    ((&(writer__)))->WriteSentinel(90571228);


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

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

auto PNativeDNSResolverOverrideParent::SendSetCnameOverride(
        const nsACString& aHost,
        const nsACString& aCNAME) -> bool
{
    UniquePtr<IPC::Message> msg__ = PNativeDNSResolverOverride::Msg_SetCnameOverride(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aHost);
    // Sentinel = 'aHost'
    ((&(writer__)))->WriteSentinel(95486464);
    IPC::WriteParam((&(writer__)), aCNAME);
    // Sentinel = 'aCNAME'
    ((&(writer__)))->WriteSentinel(108331462);


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

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

auto PNativeDNSResolverOverrideParent::SendClearHostOverride(const nsACString& aHost) -> bool
{
    UniquePtr<IPC::Message> msg__ = PNativeDNSResolverOverride::Msg_ClearHostOverride(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

auto PNativeDNSResolverOverrideParent::SendClearOverrides() -> bool
{
    UniquePtr<IPC::Message> msg__ = PNativeDNSResolverOverride::Msg_ClearOverrides(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};



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

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

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

auto PNativeDNSResolverOverrideParent::OnMessageReceived(const Message& msg__) -> PNativeDNSResolverOverrideParent::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 PNativeDNSResolverOverride::Reply___delete____ID:
        {
            return MsgProcessed;
        }
    default:
        return MsgNotKnown;
    }
}

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



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

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

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

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

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

} // namespace IPC
