#include "net/dns/host_resolver_dns_task.h"
#include <string_view>
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/not_fatal_until.h"
#include "base/ranges/algorithm.h"
#include "base/time/tick_clock.h"
#include "net/base/features.h"
#include "net/dns/address_sorter.h"
#include "net/dns/dns_client.h"
#include "net/dns/dns_names_util.h"
#include "net/dns/dns_response.h"
#include "net/dns/dns_transaction.h"
#include "net/dns/dns_util.h"
#include "net/dns/host_resolver.h"
#include "net/dns/host_resolver_cache.h"
#include "net/dns/host_resolver_internal_result.h"
#include "net/dns/public/util.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
namespace net {
namespace {
DnsResponse CreateFakeEmptyResponse(std::string_view hostname,
DnsQueryType query_type) { … }
base::Value::Dict NetLogDnsTaskExtractionFailureParams(
DnsResponseResultExtractor::ExtractionError extraction_error,
DnsQueryType dns_query_type) { … }
base::Value::Dict NetLogDnsTaskFailedParams(
int net_error,
std::optional<DnsQueryType> failed_transaction_type,
std::optional<base::TimeDelta> ttl,
const HostCache::Entry* saved_results) { … }
base::Value::Dict NetLogResults(const HostCache::Entry& results) { … }
void RecordResolveTimeDiffForBucket(const char* histogram_variant,
const char* histogram_bucket,
base::TimeDelta diff) { … }
void RecordResolveTimeDiff(const char* histogram_variant,
base::TimeTicks start_time,
base::TimeTicks first_record_end_time,
base::TimeTicks second_record_end_time) { … }
}
HostResolverDnsTask::SingleTransactionResults::SingleTransactionResults(
DnsQueryType query_type,
Results results)
: … { … }
HostResolverDnsTask::SingleTransactionResults::~SingleTransactionResults() =
default;
HostResolverDnsTask::SingleTransactionResults::SingleTransactionResults(
SingleTransactionResults&&) = default;
HostResolverDnsTask::SingleTransactionResults&
HostResolverDnsTask::SingleTransactionResults::operator=(
SingleTransactionResults&&) = default;
HostResolverDnsTask::TransactionInfo::TransactionInfo(
DnsQueryType type,
TransactionErrorBehavior error_behavior)
: … { … }
HostResolverDnsTask::TransactionInfo::~TransactionInfo() = default;
HostResolverDnsTask::TransactionInfo::TransactionInfo(
HostResolverDnsTask::TransactionInfo&& other) = default;
HostResolverDnsTask::TransactionInfo&
HostResolverDnsTask::TransactionInfo::operator=(
HostResolverDnsTask::TransactionInfo&& other) = default;
bool HostResolverDnsTask::TransactionInfo::operator<(
const HostResolverDnsTask::TransactionInfo& other) const { … }
HostResolverDnsTask::HostResolverDnsTask(
DnsClient* client,
HostResolver::Host host,
NetworkAnonymizationKey anonymization_key,
DnsQueryTypeSet query_types,
ResolveContext* resolve_context,
bool secure,
SecureDnsMode secure_dns_mode,
Delegate* delegate,
const NetLogWithSource& job_net_log,
const base::TickClock* tick_clock,
bool fallback_available,
const HostResolver::HttpsSvcbOptions& https_svcb_options)
: … { … }
HostResolverDnsTask::~HostResolverDnsTask() = default;
void HostResolverDnsTask::StartNextTransaction() { … }
base::Value::Dict HostResolverDnsTask::NetLogDnsTaskCreationParams() { … }
base::Value::Dict HostResolverDnsTask::NetLogDnsTaskTimeoutParams() { … }
DnsQueryTypeSet HostResolverDnsTask::MaybeDisableAdditionalQueries(
DnsQueryTypeSet types) { … }
void HostResolverDnsTask::PushTransactionsNeeded(DnsQueryTypeSet query_types) { … }
void HostResolverDnsTask::CreateAndStartTransaction(
TransactionInfo transaction_info) { … }
void HostResolverDnsTask::OnTimeout() { … }
void HostResolverDnsTask::OnDnsTransactionComplete(
std::set<TransactionInfo>::iterator transaction_info_it,
uint16_t request_port,
int net_error,
const DnsResponse* response) { … }
bool HostResolverDnsTask::IsFatalTransactionFailure(
int transaction_error,
const TransactionInfo& transaction_info,
const DnsResponse* response) { … }
void HostResolverDnsTask::SortTransactionAndHandleResults(
TransactionInfo transaction_info,
Results transaction_results) { … }
void HostResolverDnsTask::OnTransactionSorted(
std::set<TransactionInfo>::iterator transaction_info_it,
Results transaction_results,
bool success,
std::vector<IPEndPoint> sorted) { … }
void HostResolverDnsTask::HandleTransactionResults(
TransactionInfo transaction_info,
Results transaction_results) { … }
void HostResolverDnsTask::OnTransactionsFinished(
std::optional<SingleTransactionResults> single_transaction_results) { … }
void HostResolverDnsTask::OnSortComplete(base::TimeTicks sort_start_time,
HostCache::Entry results,
bool secure,
bool success,
std::vector<IPEndPoint> sorted) { … }
bool HostResolverDnsTask::AnyPotentiallyFatalTransactionsRemain() { … }
void HostResolverDnsTask::CancelNonFatalTransactions() { … }
void HostResolverDnsTask::OnFailure(
int net_error,
bool allow_fallback,
std::optional<base::TimeDelta> ttl,
std::optional<DnsQueryType> failed_transaction_type) { … }
void HostResolverDnsTask::OnSuccess(HostCache::Entry results) { … }
bool HostResolverDnsTask::AnyOfTypeTransactionsRemain(
std::initializer_list<DnsQueryType> types) const { … }
void HostResolverDnsTask::MaybeStartTimeoutTimer() { … }
bool HostResolverDnsTask::ShouldTriggerHttpToHttpsUpgrade(
const Results& results) { … }
}