Chromium Code Reviews| OLD | NEW |
|---|---|
| 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> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include <cmath> | 13 #include <cmath> |
| 14 #include <utility> | 14 #include <utility> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/basictypes.h" | 17 #include "base/basictypes.h" |
| 18 #include "base/bind.h" | 18 #include "base/bind.h" |
| 19 #include "base/bind_helpers.h" | 19 #include "base/bind_helpers.h" |
| 20 #include "base/callback.h" | 20 #include "base/callback.h" |
| 21 #include "base/compiler_specific.h" | 21 #include "base/compiler_specific.h" |
| 22 #include "base/debug/debugger.h" | 22 #include "base/debug/debugger.h" |
| 23 #include "base/debug/stack_trace.h" | 23 #include "base/debug/stack_trace.h" |
| 24 #include "base/message_loop/message_loop_proxy.h" | 24 #include "base/message_loop/message_loop_proxy.h" |
| 25 #include "base/metrics/field_trial.h" | 25 #include "base/metrics/field_trial.h" |
| 26 #include "base/metrics/histogram.h" | 26 #include "base/metrics/histogram.h" |
|
Alexei Svitkine (slow)
2015/05/15 20:38:28
Ditto.
davidben
2015/05/15 20:41:01
Done.
| |
| 27 #include "base/metrics/sparse_histogram.h" | |
| 27 #include "base/profiler/scoped_tracker.h" | 28 #include "base/profiler/scoped_tracker.h" |
| 28 #include "base/stl_util.h" | 29 #include "base/stl_util.h" |
| 29 #include "base/strings/string_util.h" | 30 #include "base/strings/string_util.h" |
| 30 #include "base/strings/utf_string_conversions.h" | 31 #include "base/strings/utf_string_conversions.h" |
| 31 #include "base/threading/worker_pool.h" | 32 #include "base/threading/worker_pool.h" |
| 32 #include "base/time/time.h" | 33 #include "base/time/time.h" |
| 33 #include "base/values.h" | 34 #include "base/values.h" |
| 34 #include "net/base/address_family.h" | 35 #include "net/base/address_family.h" |
| 35 #include "net/base/address_list.h" | 36 #include "net/base/address_list.h" |
| 36 #include "net/base/dns_reloader.h" | 37 #include "net/base/dns_reloader.h" |
| (...skipping 1491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1528 if (dns_task_error_ != OK) { | 1529 if (dns_task_error_ != OK) { |
| 1529 base::TimeDelta duration = base::TimeTicks::Now() - start_time; | 1530 base::TimeDelta duration = base::TimeTicks::Now() - start_time; |
| 1530 if (net_error == OK) { | 1531 if (net_error == OK) { |
| 1531 DNS_HISTOGRAM("AsyncDNS.FallbackSuccess", duration); | 1532 DNS_HISTOGRAM("AsyncDNS.FallbackSuccess", duration); |
| 1532 if ((dns_task_error_ == ERR_NAME_NOT_RESOLVED) && | 1533 if ((dns_task_error_ == ERR_NAME_NOT_RESOLVED) && |
| 1533 ResemblesNetBIOSName(key_.hostname)) { | 1534 ResemblesNetBIOSName(key_.hostname)) { |
| 1534 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_SUSPECT_NETBIOS); | 1535 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_SUSPECT_NETBIOS); |
| 1535 } else { | 1536 } else { |
| 1536 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_PROC_SUCCESS); | 1537 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_PROC_SUCCESS); |
| 1537 } | 1538 } |
| 1538 UMA_HISTOGRAM_CUSTOM_ENUMERATION("AsyncDNS.ResolveError", | 1539 UMA_HISTOGRAM_SPARSE_SLOWLY("AsyncDNS.ResolveError", |
| 1539 std::abs(dns_task_error_), | 1540 std::abs(dns_task_error_)); |
| 1540 GetAllErrorCodesForUma()); | |
| 1541 resolver_->OnDnsTaskResolve(dns_task_error_); | 1541 resolver_->OnDnsTaskResolve(dns_task_error_); |
| 1542 } else { | 1542 } else { |
| 1543 DNS_HISTOGRAM("AsyncDNS.FallbackFail", duration); | 1543 DNS_HISTOGRAM("AsyncDNS.FallbackFail", duration); |
| 1544 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_FAIL); | 1544 UmaAsyncDnsResolveStatus(RESOLVE_STATUS_FAIL); |
| 1545 } | 1545 } |
| 1546 } | 1546 } |
| 1547 | 1547 |
| 1548 base::TimeDelta ttl = | 1548 base::TimeDelta ttl = |
| 1549 base::TimeDelta::FromSeconds(kNegativeCacheEntryTTLSeconds); | 1549 base::TimeDelta::FromSeconds(kNegativeCacheEntryTTLSeconds); |
| 1550 if (net_error == OK) | 1550 if (net_error == OK) |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2369 return; | 2369 return; |
| 2370 | 2370 |
| 2371 // Disable DnsClient until the next DNS change. Must be done before aborting | 2371 // Disable DnsClient until the next DNS change. Must be done before aborting |
| 2372 // DnsTasks, since doing so may start new jobs. | 2372 // DnsTasks, since doing so may start new jobs. |
| 2373 dns_client_->SetConfig(DnsConfig()); | 2373 dns_client_->SetConfig(DnsConfig()); |
| 2374 | 2374 |
| 2375 // Switch jobs with active DnsTasks over to using ProcTasks. | 2375 // Switch jobs with active DnsTasks over to using ProcTasks. |
| 2376 AbortDnsTasks(); | 2376 AbortDnsTasks(); |
| 2377 | 2377 |
| 2378 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", false); | 2378 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", false); |
| 2379 UMA_HISTOGRAM_CUSTOM_ENUMERATION("AsyncDNS.DnsClientDisabledReason", | 2379 UMA_HISTOGRAM_SPARSE_SLOWLY("AsyncDNS.DnsClientDisabledReason", |
| 2380 std::abs(net_error), | 2380 std::abs(net_error)); |
| 2381 GetAllErrorCodesForUma()); | |
| 2382 } | 2381 } |
| 2383 | 2382 |
| 2384 void HostResolverImpl::SetDnsClient(scoped_ptr<DnsClient> dns_client) { | 2383 void HostResolverImpl::SetDnsClient(scoped_ptr<DnsClient> dns_client) { |
| 2385 // DnsClient and config must be updated before aborting DnsTasks, since doing | 2384 // DnsClient and config must be updated before aborting DnsTasks, since doing |
| 2386 // so may start new jobs. | 2385 // so may start new jobs. |
| 2387 dns_client_ = dns_client.Pass(); | 2386 dns_client_ = dns_client.Pass(); |
| 2388 if (dns_client_ && !dns_client_->GetConfig() && | 2387 if (dns_client_ && !dns_client_->GetConfig() && |
| 2389 num_dns_failures_ < kMaximumDnsFailures) { | 2388 num_dns_failures_ < kMaximumDnsFailures) { |
| 2390 DnsConfig dns_config; | 2389 DnsConfig dns_config; |
| 2391 NetworkChangeNotifier::GetDnsConfig(&dns_config); | 2390 NetworkChangeNotifier::GetDnsConfig(&dns_config); |
| 2392 dns_client_->SetConfig(dns_config); | 2391 dns_client_->SetConfig(dns_config); |
| 2393 num_dns_failures_ = 0; | 2392 num_dns_failures_ = 0; |
| 2394 if (dns_client_->GetConfig()) | 2393 if (dns_client_->GetConfig()) |
| 2395 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2394 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
| 2396 } | 2395 } |
| 2397 | 2396 |
| 2398 AbortDnsTasks(); | 2397 AbortDnsTasks(); |
| 2399 } | 2398 } |
| 2400 | 2399 |
| 2401 } // namespace net | 2400 } // namespace net |
| OLD | NEW |