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


#include "mozilla/net/PProxyAutoConfigParent.h"
#include "mozilla/ProfilerLabels.h"
#include "mozilla/net/ProxyAutoConfigParent.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 PProxyAutoConfigParent::ProcessingError(
        Result aCode,
        const char* aReason) -> void
{
}

auto PProxyAutoConfigParent::ShouldContinueFromReplyTimeout() -> bool
{
    return true;
}

MOZ_IMPLICIT PProxyAutoConfigParent::PProxyAutoConfigParent() :
    mozilla::ipc::IToplevelProtocol("PProxyAutoConfigParent", kProtocolId, mozilla::ipc::ParentSide)
{
    MOZ_COUNT_CTOR(PProxyAutoConfigParent);
}

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

auto PProxyAutoConfigParent::ActorAlloc() -> void
{
    MOZ_RELEASE_ASSERT(XRE_IsParentProcess(), "Invalid process for `PProxyAutoConfigParent'");
    AddRef();
}

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

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

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

auto PProxyAutoConfigParent::RejectPendingResponses(ResponseRejectReason aReason) -> void
{
    mAsyncCallbacks.RejectPendingResponses(aReason);
}

auto PProxyAutoConfigParent::SendConfigurePAC(
        const nsACString& aPACURI,
        const nsACString& aPACScriptData,
        const bool& aIncludePath,
        const uint32_t& aExtraHeapSize) -> bool
{
    UniquePtr<IPC::Message> msg__ = PProxyAutoConfig::Msg_ConfigurePAC(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aPACURI);
    // Sentinel = 'aPACURI'
    ((&(writer__)))->WriteSentinel(147522086);
    IPC::WriteParam((&(writer__)), aPACScriptData);
    // Sentinel = 'aPACScriptData'
    ((&(writer__)))->WriteSentinel(618726693);
    IPC::WriteParam((&(writer__)), aIncludePath);
    // Sentinel = 'aIncludePath'
    ((&(writer__)))->WriteSentinel(504956083);
    IPC::WriteParam((&(writer__)), aExtraHeapSize);
    // Sentinel = 'aExtraHeapSize'
    ((&(writer__)))->WriteSentinel(682558847);


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

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

auto PProxyAutoConfigParent::SendGetProxyForURI(
        const nsACString& aTestURI,
        const nsACString& aTestHost,
        mozilla::ipc::ResolveCallback<std::tuple<nsresult, nsCString>>&& aResolve,
        mozilla::ipc::RejectCallback&& aReject) -> void
{
    UniquePtr<IPC::Message> msg__ = PProxyAutoConfig::Msg_GetProxyForURI(MSG_ROUTING_CONTROL);
    IPC::MessageWriter writer__{
            (*(msg__)),
            this};

    IPC::WriteParam((&(writer__)), aTestURI);
    // Sentinel = 'aTestURI'
    ((&(writer__)))->WriteSentinel(229966578);
    IPC::WriteParam((&(writer__)), aTestHost);
    // Sentinel = 'aTestHost'
    ((&(writer__)))->WriteSentinel(294781856);


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

    IPC::Message::seqno_t seqno__ = 0;
    if (ChannelSend(std::move(msg__), (&(seqno__)))) {
        mAsyncCallbacks.AddCallback(seqno__, PProxyAutoConfig::Reply_GetProxyForURI__ID, [resolve=std::move(aResolve)](IPC::MessageReader* aReader) mutable {
            auto maybe__aStatus = IPC::ReadParam<nsresult>(aReader);
            if (!maybe__aStatus) {
                (aReader)->FatalError("Error deserializing 'nsresult'");
                return MsgValueError;

            }
            auto& aStatus = *maybe__aStatus;
            // Sentinel = 'aStatus'
            if ((!((aReader)->ReadSentinel(186712806)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsresult'");
                return MsgValueError;
            }
            auto maybe__aResult = IPC::ReadParam<nsCString>(aReader);
            if (!maybe__aResult) {
                (aReader)->FatalError("Error deserializing 'nsCString'");
                return MsgValueError;

            }
            auto& aResult = *maybe__aResult;
            // Sentinel = 'aResult'
            if ((!((aReader)->ReadSentinel(185205473)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }


            aReader->EndRead();

            resolve(std::make_tuple(std::move(aStatus), std::move(aResult)));
            return MsgProcessed;
        }, std::move(aReject));
    }
    else {
        aReject(::mozilla::ipc::ResponseRejectReason::SendError);
    }
    return;
}

auto PProxyAutoConfigParent::SendGetProxyForURI(
        const nsACString& aTestURI,
        const nsACString& aTestHost) -> RefPtr<GetProxyForURIPromise>
{
    RefPtr<MozPromise<std::tuple<nsresult, nsCString>, ResponseRejectReason, true>::Private> promise__ = new MozPromise<std::tuple<nsresult, nsCString>, ResponseRejectReason, true>::Private(__func__);
    promise__->UseDirectTaskDispatch(__func__);
    SendGetProxyForURI(std::forward<const nsACString&>(aTestURI), std::forward<const nsACString&>(aTestHost), [promise__](std::tuple<nsresult, nsCString>&& aValue) {
        promise__->Resolve(std::move(aValue), __func__);
    }, [promise__](ResponseRejectReason&& aReason) {
        promise__->Reject(std::move(aReason), __func__);
    });
    return promise__;
}

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

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

    }
    switch (msg__.type()) {
    case PProxyAutoConfig::Reply_GetProxyForURI__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProxyAutoConfig", mozilla::ipc::ParentSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProxyAutoConfigParent",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }

            AUTO_PROFILER_LABEL("PProxyAutoConfig::Msg_GetProxyForURI", OTHER);


            return mAsyncCallbacks.GotReply(this, msg__);
        }
    default:
        return MsgNotKnown;
    case SHMEM_CREATED_MESSAGE_TYPE:
        {
            if (!ShmemCreated(msg__)) {
                return MsgPayloadError;
            }
            return MsgProcessed;
        }
    case SHMEM_DESTROYED_MESSAGE_TYPE:
        {
            if (!ShmemDestroyed(msg__)) {
                return MsgPayloadError;
            }
            return MsgProcessed;
        }
    }
}

auto PProxyAutoConfigParent::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PProxyAutoConfigParent::Result
{
    if (!CanSend()) {
        return MsgDropped;

    }
    return MsgNotKnown;
}



} // namespace net
} // namespace mozilla
