Commit 1e501e3d authored by Paul Jensen's avatar Paul Jensen Committed by Commit Bot

Fix my DNS histograms to notice when internal resolver is enabled

Previously my DNS histograms incorrectly thought the internal
resolver was not used when it in fact was.

Bug: 908535
Change-Id: I1c3a8d41298b91d23236649de72299c47cf93926
Reviewed-on: https://chromium-review.googlesource.com/c/1351742
Commit-Queue: Paul Jensen <pauljensen@chromium.org>
Reviewed-by: default avatarMisha Efimov <mef@chromium.org>
Cr-Commit-Position: refs/heads/master@{#612343}
parent a0e783fe
...@@ -2146,8 +2146,7 @@ HostResolverImpl::HostResolverImpl(const Options& options, NetLog* net_log) ...@@ -2146,8 +2146,7 @@ HostResolverImpl::HostResolverImpl(const Options& options, NetLog* net_log)
OnConnectionTypeChanged(NetworkChangeNotifier::GetConnectionType()); OnConnectionTypeChanged(NetworkChangeNotifier::GetConnectionType());
{ {
DnsConfig dns_config = GetBaseDnsConfig(); DnsConfig dns_config = GetBaseDnsConfig(false);
received_dns_config_ = dns_config.IsValid();
// Conservatively assume local IPv6 is needed when DnsConfig is not valid. // Conservatively assume local IPv6 is needed when DnsConfig is not valid.
use_local_ipv6_ = !dns_config.IsValid() || dns_config.use_local_ipv6; use_local_ipv6_ = !dns_config.IsValid() || dns_config.use_local_ipv6;
UpdateModeForHistogram(dns_config); UpdateModeForHistogram(dns_config);
...@@ -2175,19 +2174,19 @@ void HostResolverImpl::SetDnsClient(std::unique_ptr<DnsClient> dns_client) { ...@@ -2175,19 +2174,19 @@ void HostResolverImpl::SetDnsClient(std::unique_ptr<DnsClient> dns_client) {
dns_client_ = std::move(dns_client); dns_client_ = std::move(dns_client);
if (dns_client_ && !dns_client_->GetConfig() && if (dns_client_ && !dns_client_->GetConfig() &&
num_dns_failures_ < kMaximumDnsFailures) { num_dns_failures_ < kMaximumDnsFailures) {
DnsConfig dns_config; dns_client_->SetConfig(GetBaseDnsConfig(false));
// Skip retrieving the base config if all values will be overridden.
if (!dns_config_overrides_.OverridesEverything())
dns_config = GetBaseDnsConfig();
DnsConfig overridden_config =
dns_config_overrides_.ApplyOverrides(dns_config);
dns_client_->SetConfig(overridden_config);
num_dns_failures_ = 0; num_dns_failures_ = 0;
if (dns_client_->GetConfig()) if (dns_client_->GetConfig())
UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true);
} }
AbortDnsTasks(ERR_NETWORK_CHANGED, false /* fallback_only */); AbortDnsTasks(ERR_NETWORK_CHANGED, false /* fallback_only */);
DnsConfig dns_config;
if (!HaveDnsConfig())
// UpdateModeForHistogram() needs to know the DnsConfig when
// !HaveDnsConfig()
dns_config = GetBaseDnsConfig(false);
UpdateModeForHistogram(dns_config);
} }
std::unique_ptr<HostResolver::ResolveHostRequest> std::unique_ptr<HostResolver::ResolveHostRequest>
...@@ -2934,23 +2933,18 @@ void HostResolverImpl::OnDNSChanged() { ...@@ -2934,23 +2933,18 @@ void HostResolverImpl::OnDNSChanged() {
UpdateDNSConfig(true); UpdateDNSConfig(true);
} }
DnsConfig HostResolverImpl::GetBaseDnsConfig() const { DnsConfig HostResolverImpl::GetBaseDnsConfig(bool log_to_net_log) {
DnsConfig dns_config;
if (test_base_config_)
dns_config = test_base_config_.value();
else
NetworkChangeNotifier::GetDnsConfig(&dns_config);
return dns_config;
}
void HostResolverImpl::UpdateDNSConfig(bool config_changed) {
DnsConfig dns_config; DnsConfig dns_config;
// Skip retrieving the base config if all values will be overridden. // Skip retrieving the base config if all values will be overridden.
if (!dns_config_overrides_.OverridesEverything()) { if (!dns_config_overrides_.OverridesEverything()) {
dns_config = GetBaseDnsConfig(); if (test_base_config_) {
dns_config = test_base_config_.value();
} else {
NetworkChangeNotifier::GetDnsConfig(&dns_config);
}
if (net_log_) { if (log_to_net_log && net_log_) {
net_log_->AddGlobalEntry( net_log_->AddGlobalEntry(
NetLogEventType::DNS_CONFIG_CHANGED, NetLogEventType::DNS_CONFIG_CHANGED,
base::BindRepeating(&NetLogDnsConfigCallback, &dns_config)); base::BindRepeating(&NetLogDnsConfigCallback, &dns_config));
...@@ -2960,7 +2954,11 @@ void HostResolverImpl::UpdateDNSConfig(bool config_changed) { ...@@ -2960,7 +2954,11 @@ void HostResolverImpl::UpdateDNSConfig(bool config_changed) {
received_dns_config_ = dns_config.IsValid(); received_dns_config_ = dns_config.IsValid();
} }
dns_config = dns_config_overrides_.ApplyOverrides(dns_config); return dns_config_overrides_.ApplyOverrides(dns_config);
}
void HostResolverImpl::UpdateDNSConfig(bool config_changed) {
DnsConfig dns_config = GetBaseDnsConfig(true);
// Conservatively assume local IPv6 is needed when DnsConfig is not valid. // Conservatively assume local IPv6 is needed when DnsConfig is not valid.
use_local_ipv6_ = !dns_config.IsValid() || dns_config.use_local_ipv6; use_local_ipv6_ = !dns_config.IsValid() || dns_config.use_local_ipv6;
......
...@@ -357,7 +357,9 @@ class NET_EXPORT HostResolverImpl ...@@ -357,7 +357,9 @@ class NET_EXPORT HostResolverImpl
void OnDNSChanged() override; void OnDNSChanged() override;
void OnInitialDNSConfigRead() override; void OnInitialDNSConfigRead() override;
DnsConfig GetBaseDnsConfig() const; // Returns DNS configuration including applying overrides. |log_to_net_log|
// indicates whether the config should be logged to the netlog.
DnsConfig GetBaseDnsConfig(bool log_to_net_log);
void UpdateDNSConfig(bool config_changed); void UpdateDNSConfig(bool config_changed);
// True if have a DnsClient with a valid DnsConfig. // True if have a DnsClient with a valid DnsConfig.
...@@ -378,7 +380,8 @@ class NET_EXPORT HostResolverImpl ...@@ -378,7 +380,8 @@ class NET_EXPORT HostResolverImpl
return dispatcher_->num_running_jobs(); return dispatcher_->num_running_jobs();
} }
// Update |mode_for_histogram_|. Called when DNS config changes. // Update |mode_for_histogram_|. Called when DNS config changes. |dns_config|
// is the current DNS config and is only used if !HaveDnsConfig().
void UpdateModeForHistogram(const DnsConfig& dns_config); void UpdateModeForHistogram(const DnsConfig& dns_config);
// Cache of host resolution results. // Cache of host resolution results.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment