Commit 1906f870 authored by cbentzel's avatar cbentzel Committed by Commit bot

Remove "Default Address Family" behavior from the HostResolver.

This behavior was used to either force IPv4 resolution on dual-stack devices (using the --disable-ipv6 command-line flag) or to force IPv6 resolution.

Now that the flags have gone away, this behavior is no longer needed in the HostResolver.

BUG=344685

Review URL: https://codereview.chromium.org/1163903002

Cr-Commit-Position: refs/heads/master@{#333062}
parent fd3d1531
...@@ -100,10 +100,6 @@ HostResolver::RequestInfo::RequestInfo(const HostPortPair& host_port_pair) ...@@ -100,10 +100,6 @@ HostResolver::RequestInfo::RequestInfo(const HostPortPair& host_port_pair)
HostResolver::~HostResolver() { HostResolver::~HostResolver() {
} }
AddressFamily HostResolver::GetDefaultAddressFamily() const {
return ADDRESS_FAMILY_UNSPECIFIED;
}
void HostResolver::SetDnsClientEnabled(bool enabled) { void HostResolver::SetDnsClientEnabled(bool enabled) {
} }
......
...@@ -167,13 +167,6 @@ class NET_EXPORT HostResolver { ...@@ -167,13 +167,6 @@ class NET_EXPORT HostResolver {
// has already run or the request was canceled. // has already run or the request was canceled.
virtual void CancelRequest(RequestHandle req) = 0; virtual void CancelRequest(RequestHandle req) = 0;
// Sets the default AddressFamily to use when requests have left it
// unspecified. For example, this could be used to restrict resolution
// results to AF_INET by passing in ADDRESS_FAMILY_IPV4, or to
// AF_INET6 by passing in ADDRESS_FAMILY_IPV6.
virtual void SetDefaultAddressFamily(AddressFamily address_family) {}
virtual AddressFamily GetDefaultAddressFamily() const;
// Enable or disable the built-in asynchronous DnsClient. // Enable or disable the built-in asynchronous DnsClient.
virtual void SetDnsClientEnabled(bool enabled); virtual void SetDnsClientEnabled(bool enabled);
......
...@@ -1844,10 +1844,8 @@ HostResolverImpl::HostResolverImpl(const Options& options, NetLog* net_log) ...@@ -1844,10 +1844,8 @@ HostResolverImpl::HostResolverImpl(const Options& options, NetLog* net_log)
: max_queued_jobs_(0), : max_queued_jobs_(0),
proc_params_(NULL, options.max_retry_attempts), proc_params_(NULL, options.max_retry_attempts),
net_log_(net_log), net_log_(net_log),
default_address_family_(ADDRESS_FAMILY_UNSPECIFIED),
received_dns_config_(false), received_dns_config_(false),
num_dns_failures_(0), num_dns_failures_(0),
probe_ipv6_support_(true),
use_local_ipv6_(false), use_local_ipv6_(false),
last_ipv6_probe_result_(true), last_ipv6_probe_result_(true),
resolved_known_ipv6_hostname_(false), resolved_known_ipv6_hostname_(false),
...@@ -2032,16 +2030,6 @@ void HostResolverImpl::CancelRequest(RequestHandle req_handle) { ...@@ -2032,16 +2030,6 @@ void HostResolverImpl::CancelRequest(RequestHandle req_handle) {
job->CancelRequest(req); job->CancelRequest(req);
} }
void HostResolverImpl::SetDefaultAddressFamily(AddressFamily address_family) {
DCHECK(CalledOnValidThread());
default_address_family_ = address_family;
probe_ipv6_support_ = false;
}
AddressFamily HostResolverImpl::GetDefaultAddressFamily() const {
return default_address_family_;
}
void HostResolverImpl::SetDnsClientEnabled(bool enabled) { void HostResolverImpl::SetDnsClientEnabled(bool enabled) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
#if defined(ENABLE_BUILT_IN_DNS) #if defined(ENABLE_BUILT_IN_DNS)
...@@ -2088,14 +2076,8 @@ bool HostResolverImpl::ResolveAsIP(const Key& key, ...@@ -2088,14 +2076,8 @@ bool HostResolverImpl::ResolveAsIP(const Key& key,
*net_error = OK; *net_error = OK;
AddressFamily family = GetAddressFamily(*ip_number); AddressFamily family = GetAddressFamily(*ip_number);
if (family == ADDRESS_FAMILY_IPV6 && if (key.address_family != ADDRESS_FAMILY_UNSPECIFIED &&
!probe_ipv6_support_ && key.address_family != family) {
default_address_family_ == ADDRESS_FAMILY_IPV4) {
// Don't return IPv6 addresses if default address family is set to IPv4,
// and probes are disabled.
*net_error = ERR_NAME_NOT_RESOLVED;
} else if (key.address_family != ADDRESS_FAMILY_UNSPECIFIED &&
key.address_family != family) {
// Don't return IPv6 addresses for IPv4 queries, and vice versa. // Don't return IPv6 addresses for IPv4 queries, and vice versa.
*net_error = ERR_NAME_NOT_RESOLVED; *net_error = ERR_NAME_NOT_RESOLVED;
} else { } else {
...@@ -2208,22 +2190,18 @@ HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( ...@@ -2208,22 +2190,18 @@ HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest(
AddressFamily effective_address_family = info.address_family(); AddressFamily effective_address_family = info.address_family();
if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) { if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED) {
if (probe_ipv6_support_ && !use_local_ipv6_ && if (!use_local_ipv6_ &&
// When resolving IPv4 literals, there's no need to probe for IPv6. // When resolving IPv4 literals, there's no need to probe for IPv6.
// When resolving IPv6 literals, there's no benefit to artificially // When resolving IPv6 literals, there's no benefit to artificially
// limiting our resolution based on a probe. Prior logic ensures // limiting our resolution based on a probe. Prior logic ensures
// that this query is UNSPECIFIED (see info.address_family() // that this query is UNSPECIFIED (see info.address_family()
// check above) and that |default_address_family_| is UNSPECIFIED // check above) so the code requesting the resolution should be amenable
// (|prove_ipv6_support_| is false if |default_address_family_| is // to receiving a IPv6 resolution.
// set) so the code requesting the resolution should be amenable to
// receiving a IPv6 resolution.
ip_number == nullptr) { ip_number == nullptr) {
if (!IsIPv6Reachable(net_log)) { if (!IsIPv6Reachable(net_log)) {
effective_address_family = ADDRESS_FAMILY_IPV4; effective_address_family = ADDRESS_FAMILY_IPV4;
effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6;
} }
} else {
effective_address_family = default_address_family_;
} }
} }
......
...@@ -135,8 +135,6 @@ class NET_EXPORT HostResolverImpl ...@@ -135,8 +135,6 @@ class NET_EXPORT HostResolverImpl
AddressList* addresses, AddressList* addresses,
const BoundNetLog& source_net_log) override; const BoundNetLog& source_net_log) override;
void CancelRequest(RequestHandle req) override; void CancelRequest(RequestHandle req) override;
void SetDefaultAddressFamily(AddressFamily address_family) override;
AddressFamily GetDefaultAddressFamily() const override;
void SetDnsClientEnabled(bool enabled) override; void SetDnsClientEnabled(bool enabled) override;
HostCache* GetHostCache() override; HostCache* GetHostCache() override;
base::Value* GetDnsConfigAsValue() const override; base::Value* GetDnsConfigAsValue() const override;
...@@ -205,7 +203,7 @@ class NET_EXPORT HostResolverImpl ...@@ -205,7 +203,7 @@ class NET_EXPORT HostResolverImpl
// Probes IPv6 support and returns true if IPv6 support is enabled. // Probes IPv6 support and returns true if IPv6 support is enabled.
// Results are cached, i.e. when called repeatedly this method returns result // Results are cached, i.e. when called repeatedly this method returns result
// from the first probe for some time before probing again. // from the first probe for some time before probing again.
bool IsIPv6Reachable(const BoundNetLog& net_log); virtual bool IsIPv6Reachable(const BoundNetLog& net_log);
// Records the result in cache if cache is present. // Records the result in cache if cache is present.
void CacheResult(const Key& key, void CacheResult(const Key& key,
...@@ -268,9 +266,6 @@ class NET_EXPORT HostResolverImpl ...@@ -268,9 +266,6 @@ class NET_EXPORT HostResolverImpl
NetLog* net_log_; NetLog* net_log_;
// Address family to use when the request doesn't specify one.
AddressFamily default_address_family_;
// If present, used by DnsTask and ServeFromHosts to resolve requests. // If present, used by DnsTask and ServeFromHosts to resolve requests.
scoped_ptr<DnsClient> dns_client_; scoped_ptr<DnsClient> dns_client_;
...@@ -281,10 +276,6 @@ class NET_EXPORT HostResolverImpl ...@@ -281,10 +276,6 @@ class NET_EXPORT HostResolverImpl
// Number of consecutive failures of DnsTask, counted when fallback succeeds. // Number of consecutive failures of DnsTask, counted when fallback succeeds.
unsigned num_dns_failures_; unsigned num_dns_failures_;
// True if probing is done for each Request to set address family. When false,
// explicit setting in |default_address_family_| is used.
bool probe_ipv6_support_;
// True if DnsConfigService detected that system configuration depends on // True if DnsConfigService detected that system configuration depends on
// local IPv6 connectivity. Disables probing. // local IPv6 connectivity. Disables probing.
bool use_local_ipv6_; bool use_local_ipv6_;
......
This diff is collapsed.
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