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


#include "mozilla/net/PStunAddrsRequestParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/net/NrIceStunAddrMessageUtils.h"

#include "mozilla/net/PNeckoParent.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 PStunAddrsRequestParent::Recv__delete__() -> mozilla::ipc::IPCResult
{
    return IPC_OK();
}

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

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

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

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

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

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

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

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

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

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

auto PStunAddrsRequestParent::SendOnMDNSQueryComplete(
        const nsACString& hostname,
        const MaybeNsCString& address) -> bool
{
    UniquePtr<IPC::Message> msg__ = PStunAddrsRequest::Msg_OnMDNSQueryComplete(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), hostname);
    // Sentinel = 'hostname'
    ((&(writer__)))->WriteSentinel(258016096);
    IPC::WriteParam((&(writer__)), address);
    // Sentinel = 'address'
    ((&(writer__)))->WriteSentinel(189399783);


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

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

auto PStunAddrsRequestParent::SendOnStunAddrsAvailable(const NrIceStunAddrArray& iceStunAddrs) -> bool
{
    UniquePtr<IPC::Message> msg__ = PStunAddrsRequest::Msg_OnStunAddrsAvailable(Id());
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

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


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

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

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

auto PStunAddrsRequestParent::OnMessageReceived(const Message& msg__) -> PStunAddrsRequestParent::Result
{
    if (!CanSend()) {
        if (mozilla::ipc::LoggingEnabledFor("PStunAddrsRequest", mozilla::ipc::ParentSide)) {
            mozilla::ipc::LogMessageForProtocol(
                "PStunAddrsRequestParent",
                this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                "Ignored message for dead actor",
                (&(msg__))->type(),
                mozilla::ipc::MessageDirection::eSending);
        }
        return MsgProcessed;

    }
    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 PStunAddrsRequest::Msg_GetStunAddrs__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStunAddrsRequest", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStunAddrsRequestParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStunAddrsRequest::Msg_GetStunAddrs", OTHER);

            mozilla::ipc::IPCResult __ok = (this)->RecvGetStunAddrs();
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PStunAddrsRequest::Msg_RegisterMDNSHostname__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStunAddrsRequest", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStunAddrsRequestParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStunAddrsRequest::Msg_RegisterMDNSHostname", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

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

            }
            auto& address = *maybe__address;
            // Sentinel = 'address'
            if ((!(((&(reader__)))->ReadSentinel(189399783)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvRegisterMDNSHostname(std::move(hostname), std::move(address));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PStunAddrsRequest::Msg_QueryMDNSHostname__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStunAddrsRequest", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStunAddrsRequestParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStunAddrsRequest::Msg_QueryMDNSHostname", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& hostname = *maybe__hostname;
            // Sentinel = 'hostname'
            if ((!(((&(reader__)))->ReadSentinel(258016096)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvQueryMDNSHostname(std::move(hostname));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PStunAddrsRequest::Msg_UnregisterMDNSHostname__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PStunAddrsRequest", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PStunAddrsRequestParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PStunAddrsRequest::Msg_UnregisterMDNSHostname", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

            }
            auto& hostname = *maybe__hostname;
            // Sentinel = 'hostname'
            if ((!(((&(reader__)))->ReadSentinel(258016096)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (this)->RecvUnregisterMDNSHostname(std::move(hostname));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

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

            DoomSubtree();
            mozilla::ipc::IPCResult __ok = (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 PStunAddrsRequestParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PStunAddrsRequestParent::Result
{
    if (!CanSend()) {
        return MsgDropped;

    }
    return MsgNotKnown;
}



} // namespace net
} // namespace mozilla
