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


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

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

MOZ_IMPLICIT PProxyAutoConfigChild::PProxyAutoConfigChild() :
    mozilla::ipc::IToplevelProtocol("PProxyAutoConfigChild", kProtocolId, mozilla::ipc::ChildSide)
{
    MOZ_COUNT_CTOR(PProxyAutoConfigChild);
}

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

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

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

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

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

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

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

auto PProxyAutoConfigChild::OnMessageReceived(const Message& msg__) -> PProxyAutoConfigChild::Result
{
    switch (msg__.type()) {
    case PProxyAutoConfig::Msg_ConfigurePAC__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProxyAutoConfig", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProxyAutoConfigChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PProxyAutoConfig::Msg_ConfigurePAC", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

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

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

            }
            auto& aIncludePath = *maybe__aIncludePath;
            // Sentinel = 'aIncludePath'
            if ((!(((&(reader__)))->ReadSentinel(504956083)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'bool'");
                return MsgValueError;
            }
            auto maybe__aExtraHeapSize = IPC::ReadParam<uint32_t>((&(reader__)));
            if (!maybe__aExtraHeapSize) {
                FatalError("Error deserializing 'uint32_t'");
                return MsgValueError;

            }
            auto& aExtraHeapSize = *maybe__aExtraHeapSize;
            // Sentinel = 'aExtraHeapSize'
            if ((!(((&(reader__)))->ReadSentinel(682558847)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'uint32_t'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::IPCResult __ok = (static_cast<ProxyAutoConfigChild*>(this))->RecvConfigurePAC(std::move(aPACURI), std::move(aPACScriptData), std::move(aIncludePath), std::move(aExtraHeapSize));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    case PProxyAutoConfig::Msg_GetProxyForURI__ID:
        {
            if (mozilla::ipc::LoggingEnabledFor("PProxyAutoConfig", mozilla::ipc::ChildSide)) {
                mozilla::ipc::LogMessageForProtocol(
                    "PProxyAutoConfigChild",
                    this->ToplevelProtocol()->OtherPidMaybeInvalid(),
                    "Received ",
                    (&(msg__))->type(),
                    mozilla::ipc::MessageDirection::eReceiving);
            }
            AUTO_PROFILER_LABEL("PProxyAutoConfig::Msg_GetProxyForURI", OTHER);

            IPC::MessageReader reader__{
                    msg__,
                    this};

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

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

            }
            auto& aTestHost = *maybe__aTestHost;
            // Sentinel = 'aTestHost'
            if ((!(((&(reader__)))->ReadSentinel(294781856)))) {
                mozilla::ipc::SentinelReadError("Error deserializing 'nsCString'");
                return MsgValueError;
            }
            reader__.EndRead();
            mozilla::ipc::ActorId id__ = MSG_ROUTING_CONTROL;
            UniquePtr<IPC::Message> reply__(PProxyAutoConfig::Reply_GetProxyForURI(id__));
            reply__->set_seqno(msg__.seqno());

            RefPtr<mozilla::ipc::IPDLResolverInner> resolver__ =
                new mozilla::ipc::IPDLResolverInner(std::move(reply__), this);

            GetProxyForURIResolver resolver = [resolver__ = std::move(resolver__)](std::tuple<const nsresult&, const nsACString&> aParam) {
                resolver__->Resolve([&] (IPC::Message* reply__, IProtocol* self__) {
                    IPC::MessageWriter writer__(*reply__, self__);
                    IPC::WriteParam((&(writer__)), std::get<0>(aParam));
                    // Sentinel = 'aStatus'
                    ((&(writer__)))->WriteSentinel(186712806);
                    IPC::WriteParam((&(writer__)), std::get<1>(aParam));
                    // Sentinel = 'aResult'
                    ((&(writer__)))->WriteSentinel(185205473);

                    if (mozilla::ipc::LoggingEnabledFor("PProxyAutoConfig", mozilla::ipc::ChildSide)) {
                        mozilla::ipc::LogMessageForProtocol(
                            "PProxyAutoConfigChild",
                            self__->ToplevelProtocol()->OtherPidMaybeInvalid(),
                            "Sending reply ",
                            reply__->type(),
                            mozilla::ipc::MessageDirection::eSending);
                    }

                });
            };
            mozilla::ipc::IPCResult __ok = (static_cast<ProxyAutoConfigChild*>(this))->RecvGetProxyForURI(std::move(aTestURI), std::move(aTestHost), std::move(resolver));
            if ((!(__ok))) {
                mozilla::ipc::ProtocolErrorBreakpoint("Handler returned error code!");
                // Error handled in mozilla::ipc::IPCResult
                return MsgProcessingError;
            }

            return MsgProcessed;
        }
    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 PProxyAutoConfigChild::OnMessageReceived(
        const Message& msg__,
        UniquePtr<Message>& reply__) -> PProxyAutoConfigChild::Result
{
    return MsgNotKnown;
}



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

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

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

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

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

} // namespace IPC
