diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-26 17:59:51 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-26 17:59:51 +0000 |
commit | 0c7798459922d970a2eb43039a2a5733bb94ae2e (patch) | |
tree | 648b15f61e1d7135f12fb648195e0806b8193dd2 /net/base | |
parent | c248be0e84cda8fb1870db68a3127b2e9fae057c (diff) | |
download | chromium_src-0c7798459922d970a2eb43039a2a5733bb94ae2e.zip chromium_src-0c7798459922d970a2eb43039a2a5733bb94ae2e.tar.gz chromium_src-0c7798459922d970a2eb43039a2a5733bb94ae2e.tar.bz2 |
Refactor: Change the interface from HostResolver::DisableIPv6() to HostResolver::SetDefaultAddressFamily(), to make it more general.
This came up in a codereview comment, but was after I had checked in.
Review URL: http://codereview.chromium.org/303026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30063 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/host_resolver.h | 7 | ||||
-rw-r--r-- | net/base/host_resolver_impl.cc | 6 | ||||
-rw-r--r-- | net/base/host_resolver_impl.h | 10 |
3 files changed, 12 insertions, 11 deletions
diff --git a/net/base/host_resolver.h b/net/base/host_resolver.h index 4829c1c..998de32 100644 --- a/net/base/host_resolver.h +++ b/net/base/host_resolver.h @@ -148,8 +148,11 @@ class HostResolver : public base::RefCountedThreadSafe<HostResolver> { // TODO(eroman): temp hack for http://crbug.com/18373 virtual void Shutdown() = 0; - // Disables or enables support for IPv6 results. - virtual void DisableIPv6(bool disable_ipv6) {} + // 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) {} protected: HostResolver() { } diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc index 6b5a20f..47b2aa3 100644 --- a/net/base/host_resolver_impl.cc +++ b/net/base/host_resolver_impl.cc @@ -293,7 +293,7 @@ HostResolverImpl::HostResolverImpl(HostResolverProc* resolver_proc, : cache_(max_cache_entries, cache_duration_ms), next_request_id_(0), resolver_proc_(resolver_proc), - disable_ipv6_(false), + default_address_family_(ADDRESS_FAMILY_UNSPECIFIED), shutdown_(false) { #if defined(OS_WIN) EnsureWinsockInit(); @@ -330,8 +330,8 @@ int HostResolverImpl::Resolve(const RequestInfo& info, // Build a key that identifies the request in the cache and in the // outstanding jobs map. Key key(info.hostname(), info.address_family()); - if (disable_ipv6_) - key.address_family = ADDRESS_FAMILY_IPV4; + if (key.address_family == ADDRESS_FAMILY_UNSPECIFIED) + key.address_family = default_address_family_; // If we have an unexpired cache entry, use it. if (info.allow_cached_response()) { diff --git a/net/base/host_resolver_impl.h b/net/base/host_resolver_impl.h index b641b0b..5399e69 100644 --- a/net/base/host_resolver_impl.h +++ b/net/base/host_resolver_impl.h @@ -70,10 +70,8 @@ class HostResolverImpl : public HostResolver { // TODO(eroman): temp hack for http://crbug.com/15513 virtual void Shutdown(); - // Prevents returning IPv6 addresses from Resolve(). - // The default is to allow IPv6 results. - virtual void DisableIPv6(bool disable_ipv6) { - disable_ipv6_ = disable_ipv6; + virtual void SetDefaultAddressFamily(AddressFamily address_family) { + default_address_family_ = address_family; } private: @@ -139,8 +137,8 @@ class HostResolverImpl : public HostResolver { // in the case of unit-tests which inject custom host resolving behaviors. scoped_refptr<HostResolverProc> resolver_proc_; - // Set to true if only IPv4 address are to be returned by Resolve(). - bool disable_ipv6_; + // Address family to use when the request doesn't specify one. + AddressFamily default_address_family_; // TODO(eroman): temp hack for http://crbug.com/15513 bool shutdown_; |