Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: net/dns/host_resolver_impl.cc

Issue 2812983006: Revert "Add back "default address family" to HostResolver" (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/dns/host_resolver_impl.h ('k') | net/dns/host_resolver_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/dns/host_resolver_impl.h" 5 #include "net/dns/host_resolver_impl.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <Winsock2.h> 8 #include <Winsock2.h>
9 #elif defined(OS_POSIX) 9 #elif defined(OS_POSIX)
10 #include <netdb.h> 10 #include <netdb.h>
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after
2039 2039
2040 HostResolverImpl::HostResolverImpl( 2040 HostResolverImpl::HostResolverImpl(
2041 const Options& options, 2041 const Options& options,
2042 NetLog* net_log, 2042 NetLog* net_log,
2043 scoped_refptr<base::TaskRunner> worker_task_runner) 2043 scoped_refptr<base::TaskRunner> worker_task_runner)
2044 : max_queued_jobs_(0), 2044 : max_queued_jobs_(0),
2045 proc_params_(NULL, options.max_retry_attempts), 2045 proc_params_(NULL, options.max_retry_attempts),
2046 net_log_(net_log), 2046 net_log_(net_log),
2047 received_dns_config_(false), 2047 received_dns_config_(false),
2048 num_dns_failures_(0), 2048 num_dns_failures_(0),
2049 default_address_family_(ADDRESS_FAMILY_UNSPECIFIED),
2050 assume_ipv6_failure_on_wifi_(false), 2049 assume_ipv6_failure_on_wifi_(false),
2051 use_local_ipv6_(false), 2050 use_local_ipv6_(false),
2052 last_ipv6_probe_result_(true), 2051 last_ipv6_probe_result_(true),
2053 resolved_known_ipv6_hostname_(false), 2052 resolved_known_ipv6_hostname_(false),
2054 additional_resolver_flags_(0), 2053 additional_resolver_flags_(0),
2055 fallback_to_proctask_(true), 2054 fallback_to_proctask_(true),
2056 worker_task_runner_(std::move(worker_task_runner)), 2055 worker_task_runner_(std::move(worker_task_runner)),
2057 persist_initialized_(false), 2056 persist_initialized_(false),
2058 weak_ptr_factory_(this), 2057 weak_ptr_factory_(this),
2059 probe_weak_ptr_factory_(this) { 2058 probe_weak_ptr_factory_(this) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 ip_address_ptr = &ip_address; 2215 ip_address_ptr = &ip_address;
2217 2216
2218 Key key = GetEffectiveKeyForRequest(info, ip_address_ptr, source_net_log); 2217 Key key = GetEffectiveKeyForRequest(info, ip_address_ptr, source_net_log);
2219 2218
2220 int rv = ResolveHelper(key, info, ip_address_ptr, addresses, true, stale_info, 2219 int rv = ResolveHelper(key, info, ip_address_ptr, addresses, true, stale_info,
2221 source_net_log); 2220 source_net_log);
2222 LogFinishRequest(source_net_log, info, rv); 2221 LogFinishRequest(source_net_log, info, rv);
2223 return rv; 2222 return rv;
2224 } 2223 }
2225 2224
2226 void HostResolverImpl::SetDefaultAddressFamily(AddressFamily address_family) {
2227 DCHECK(CalledOnValidThread());
2228 default_address_family_ = address_family;
2229 }
2230
2231 AddressFamily HostResolverImpl::GetDefaultAddressFamily() const {
2232 return default_address_family_;
2233 }
2234
2235 void HostResolverImpl::SetNoIPv6OnWifi(bool no_ipv6_on_wifi) { 2225 void HostResolverImpl::SetNoIPv6OnWifi(bool no_ipv6_on_wifi) {
2236 DCHECK(CalledOnValidThread()); 2226 DCHECK(CalledOnValidThread());
2237 assume_ipv6_failure_on_wifi_ = no_ipv6_on_wifi; 2227 assume_ipv6_failure_on_wifi_ = no_ipv6_on_wifi;
2238 } 2228 }
2239 2229
2240 bool HostResolverImpl::GetNoIPv6OnWifi() { 2230 bool HostResolverImpl::GetNoIPv6OnWifi() {
2241 return assume_ipv6_failure_on_wifi_; 2231 return assume_ipv6_failure_on_wifi_;
2242 } 2232 }
2243 2233
2244 bool HostResolverImpl::ResolveAsIP(const Key& key, 2234 bool HostResolverImpl::ResolveAsIP(const Key& key,
2245 const RequestInfo& info, 2235 const RequestInfo& info,
2246 const IPAddress* ip_address, 2236 const IPAddress* ip_address,
2247 int* net_error, 2237 int* net_error,
2248 AddressList* addresses) { 2238 AddressList* addresses) {
2249 DCHECK(addresses); 2239 DCHECK(addresses);
2250 DCHECK(net_error); 2240 DCHECK(net_error);
2251 if (ip_address == nullptr) 2241 if (ip_address == nullptr)
2252 return false; 2242 return false;
2253 2243
2254 *net_error = OK; 2244 *net_error = OK;
2255 AddressFamily family = GetAddressFamily(*ip_address); 2245 AddressFamily family = GetAddressFamily(*ip_address);
2256 if (family == ADDRESS_FAMILY_IPV6 &&
2257 default_address_family_ == ADDRESS_FAMILY_IPV4) {
2258 // Don't return IPv6 addresses if default address family is set to IPv4.
2259 *net_error = ERR_NAME_NOT_RESOLVED;
2260 }
2261 if (key.address_family != ADDRESS_FAMILY_UNSPECIFIED && 2246 if (key.address_family != ADDRESS_FAMILY_UNSPECIFIED &&
2262 key.address_family != family) { 2247 key.address_family != family) {
2263 // Don't return IPv6 addresses for IPv4 queries, and vice versa. 2248 // Don't return IPv6 addresses for IPv4 queries, and vice versa.
2264 *net_error = ERR_NAME_NOT_RESOLVED; 2249 *net_error = ERR_NAME_NOT_RESOLVED;
2265 } else { 2250 } else {
2266 *addresses = AddressList::CreateFromIPAddress(*ip_address, info.port()); 2251 *addresses = AddressList::CreateFromIPAddress(*ip_address, info.port());
2267 if (key.host_resolver_flags & HOST_RESOLVER_CANONNAME) 2252 if (key.host_resolver_flags & HOST_RESOLVER_CANONNAME)
2268 addresses->SetDefaultCanonicalName(); 2253 addresses->SetDefaultCanonicalName();
2269 } 2254 }
2270 return true; 2255 return true;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 } 2378 }
2394 2379
2395 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest( 2380 HostResolverImpl::Key HostResolverImpl::GetEffectiveKeyForRequest(
2396 const RequestInfo& info, 2381 const RequestInfo& info,
2397 const IPAddress* ip_address, 2382 const IPAddress* ip_address,
2398 const NetLogWithSource& net_log) { 2383 const NetLogWithSource& net_log) {
2399 HostResolverFlags effective_flags = 2384 HostResolverFlags effective_flags =
2400 info.host_resolver_flags() | additional_resolver_flags_; 2385 info.host_resolver_flags() | additional_resolver_flags_;
2401 AddressFamily effective_address_family = info.address_family(); 2386 AddressFamily effective_address_family = info.address_family();
2402 2387
2403 if (info.address_family() == ADDRESS_FAMILY_UNSPECIFIED)
2404 effective_address_family = default_address_family_;
2405
2406 if (effective_address_family == ADDRESS_FAMILY_UNSPECIFIED && 2388 if (effective_address_family == ADDRESS_FAMILY_UNSPECIFIED &&
2407 // When resolving IPv4 literals, there's no need to probe for IPv6. 2389 // When resolving IPv4 literals, there's no need to probe for IPv6.
2408 // When resolving IPv6 literals, there's no benefit to artificially 2390 // When resolving IPv6 literals, there's no benefit to artificially
2409 // limiting our resolution based on a probe. Prior logic ensures 2391 // limiting our resolution based on a probe. Prior logic ensures
2410 // that this query is UNSPECIFIED (see effective_address_family 2392 // that this query is UNSPECIFIED (see effective_address_family
2411 // check above) so the code requesting the resolution should be amenable 2393 // check above) so the code requesting the resolution should be amenable
2412 // to receiving a IPv6 resolution. 2394 // to receiving a IPv6 resolution.
2413 !use_local_ipv6_ && ip_address == nullptr && !IsIPv6Reachable(net_log)) { 2395 !use_local_ipv6_ && ip_address == nullptr && !IsIPv6Reachable(net_log)) {
2414 effective_address_family = ADDRESS_FAMILY_IPV4; 2396 effective_address_family = ADDRESS_FAMILY_IPV4;
2415 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6; 2397 effective_flags |= HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6;
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
2735 if (job_) 2717 if (job_)
2736 job_->CancelRequest(this); 2718 job_->CancelRequest(this);
2737 } 2719 }
2738 2720
2739 void HostResolverImpl::RequestImpl::ChangeRequestPriority( 2721 void HostResolverImpl::RequestImpl::ChangeRequestPriority(
2740 RequestPriority priority) { 2722 RequestPriority priority) {
2741 job_->ChangeRequestPriority(this, priority); 2723 job_->ChangeRequestPriority(this, priority);
2742 } 2724 }
2743 2725
2744 } // namespace net 2726 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/host_resolver_impl.h ('k') | net/dns/host_resolver_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698