chromium/net/dns/host_resolver_manager_job.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/dns/host_resolver_manager_job.h"

#include <deque>
#include <memory>
#include <optional>
#include <vector>

#include "base/containers/linked_list.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/safe_ref.h"
#include "base/memory/weak_ptr.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "net/base/address_family.h"
#include "net/base/features.h"
#include "net/base/network_anonymization_key.h"
#include "net/base/network_handle.h"
#include "net/base/prioritized_dispatcher.h"
#include "net/base/url_util.h"
#include "net/dns/dns_client.h"
#include "net/dns/dns_task_results_manager.h"
#include "net/dns/host_cache.h"
#include "net/dns/host_resolver.h"
#include "net/dns/host_resolver_dns_task.h"
#include "net/dns/host_resolver_manager.h"
#include "net/dns/host_resolver_manager_request_impl.h"
#include "net/dns/host_resolver_manager_service_endpoint_request_impl.h"
#include "net/dns/host_resolver_mdns_task.h"
#include "net/dns/host_resolver_nat64_task.h"
#include "net/dns/host_resolver_system_task.h"
#include "net/dns/public/dns_query_type.h"
#include "net/dns/public/secure_dns_mode.h"
#include "net/log/net_log_with_source.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "url/url_constants.h"

namespace net {

namespace {

// Default TTL for successful resolutions with HostResolverSystemTask.
const unsigned kCacheEntryTTLSeconds =;

// Default TTL for unsuccessful resolutions with HostResolverSystemTask.
const unsigned kNegativeCacheEntryTTLSeconds =;

// Minimum TTL for successful resolutions with HostResolverDnsTask.
const unsigned kMinimumTTLSeconds =;

// ICANN uses this localhost address to indicate a name collision.
//
// The policy in Chromium is to fail host resolving if it resolves to
// this special address.
//
// Not however that IP literals are exempt from this policy, so it is still
// possible to navigate to http://127.0.53.53/ directly.
//
// For more details: https://www.icann.org/news/announcement-2-2014-08-01-en
const uint8_t kIcanNameCollisionIp[] =;

bool ContainsIcannNameCollisionIp(const std::vector<IPEndPoint>& endpoints) {}

// Creates NetLog parameters for HOST_RESOLVER_MANAGER_JOB_ATTACH/DETACH events.
base::Value::Dict NetLogJobAttachParams(const NetLogSource& source,
                                        RequestPriority priority) {}

bool IsSchemeHttpsOrWss(const HostResolver::Host& host) {}

}  // namespace

HostResolverManager::JobKey::JobKey(HostResolver::Host host,
                                    ResolveContext* resolve_context)
    :{}

HostResolverManager::JobKey::~JobKey() = default;

HostResolverManager::JobKey::JobKey(const JobKey& other) = default;
HostResolverManager::JobKey& HostResolverManager::JobKey::operator=(
    const JobKey& other) = default;

bool HostResolverManager::JobKey::operator<(const JobKey& other) const {}

bool HostResolverManager::JobKey::operator==(const JobKey& other) const {}

HostCache::Key HostResolverManager::JobKey::ToCacheKey(bool secure) const {}

handles::NetworkHandle HostResolverManager::JobKey::GetTargetNetwork() const {}

HostResolverManager::Job::Job(
    const base::WeakPtr<HostResolverManager>& resolver,
    JobKey key,
    ResolveHostParameters::CacheUsage cache_usage,
    HostCache* host_cache,
    std::deque<TaskType> tasks,
    RequestPriority priority,
    const NetLogWithSource& source_net_log,
    const base::TickClock* tick_clock,
    const HostResolver::HttpsSvcbOptions& https_svcb_options)
    :{}

HostResolverManager::Job::~Job() {}

void HostResolverManager::Job::Schedule(bool at_head) {}

void HostResolverManager::Job::AddRequest(RequestImpl* request) {}

void HostResolverManager::Job::ChangeRequestPriority(RequestImpl* req,
                                                     RequestPriority priority) {}

void HostResolverManager::Job::CancelRequest(RequestImpl* request) {}

void HostResolverManager::Job::AddServiceEndpointRequest(
    ServiceEndpointRequestImpl* request) {}

void HostResolverManager::Job::CancelServiceEndpointRequest(
    ServiceEndpointRequestImpl* request) {}

void HostResolverManager::Job::ChangeServiceEndpointRequestPriority(
    ServiceEndpointRequestImpl* request,
    RequestPriority priority) {}

void HostResolverManager::Job::Abort() {}

base::OnceClosure HostResolverManager::Job::GetAbortInsecureDnsTaskClosure(
    int error,
    bool fallback_only) {}

void HostResolverManager::Job::AbortInsecureDnsTask(int error,
                                                    bool fallback_only) {}

void HostResolverManager::Job::OnEvicted() {}

bool HostResolverManager::Job::ServeFromHosts() {}

void HostResolverManager::Job::OnAddedToJobMap(JobMap::iterator iterator) {}

void HostResolverManager::Job::OnRemovedFromJobMap() {}

void HostResolverManager::Job::RunNextTask() {}

base::Value::Dict HostResolverManager::Job::NetLogJobCreationParams(
    const NetLogSource& source) {}

void HostResolverManager::Job::Finish() {}

void HostResolverManager::Job::KillDnsTask() {}

void HostResolverManager::Job::ReduceByOneJobSlot() {}

void HostResolverManager::Job::AddRequestCommon(
    RequestPriority request_priority,
    const NetLogWithSource& request_net_log,
    bool is_speculative) {}

void HostResolverManager::Job::CancelRequestCommon(
    RequestPriority request_priority,
    const NetLogWithSource& request_net_log) {}

void HostResolverManager::Job::UpdatePriority() {}

void HostResolverManager::Job::Start() {}

void HostResolverManager::Job::StartSystemTask() {}

void HostResolverManager::Job::OnSystemTaskComplete(
    base::TimeTicks start_time,
    const AddressList& addr_list,
    int /*os_error*/,
    int net_error) {}

void HostResolverManager::Job::InsecureCacheLookup() {}

void HostResolverManager::Job::StartDnsTask(bool secure) {}

void HostResolverManager::Job::StartNextDnsTransaction() {}

void HostResolverManager::Job::OnDnsTaskFailure(
    const base::WeakPtr<HostResolverDnsTask>& dns_task,
    base::TimeDelta duration,
    bool allow_fallback,
    const HostCache::Entry& failure_results,
    bool secure) {}

void HostResolverManager::Job::OnDnsTaskComplete(base::TimeTicks start_time,
                                                 bool allow_fallback,
                                                 HostCache::Entry results,
                                                 bool secure) {}

void HostResolverManager::Job::OnIntermediateTransactionsComplete(
    std::optional<HostResolverDnsTask::SingleTransactionResults>
        single_transaction_results) {}

void HostResolverManager::Job::AddTransactionTimeQueued(
    base::TimeDelta time_queued) {}

void HostResolverManager::Job::OnServiceEndpointsUpdated() {}

void HostResolverManager::Job::StartMdnsTask() {}

void HostResolverManager::Job::OnMdnsTaskComplete() {}

void HostResolverManager::Job::OnMdnsImmediateFailure(int rv) {}

void HostResolverManager::Job::StartNat64Task() {}

void HostResolverManager::Job::OnNat64TaskComplete() {}

void HostResolverManager::Job::RecordJobHistograms(
    const HostCache::Entry& results,
    std::optional<TaskType> task_type) {}

void HostResolverManager::Job::MaybeCacheResult(const HostCache::Entry& results,
                                                base::TimeDelta ttl,
                                                bool secure) {}

void HostResolverManager::Job::CompleteRequests(
    const HostCache::Entry& results,
    base::TimeDelta ttl,
    bool allow_cache,
    bool secure,
    std::optional<TaskType> task_type) {}

void HostResolverManager::Job::CompleteRequestsWithoutCache(
    const HostCache::Entry& results,
    std::optional<HostCache::EntryStaleness> stale_info,
    TaskType task_type) {}

void HostResolverManager::Job::CompleteRequestsWithError(
    int net_error,
    std::optional<TaskType> task_type) {}

RequestPriority HostResolverManager::Job::priority() const {}

}  // namespace net