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" | |
25 #include "base/metrics/field_trial.h" | 24 #include "base/metrics/field_trial.h" |
26 #include "base/metrics/histogram.h" | 25 #include "base/metrics/histogram.h" |
27 #include "base/profiler/scoped_tracker.h" | 26 #include "base/profiler/scoped_tracker.h" |
27 #include "base/single_thread_task_runner.h" | |
28 #include "base/stl_util.h" | 28 #include "base/stl_util.h" |
29 #include "base/strings/string_util.h" | 29 #include "base/strings/string_util.h" |
30 #include "base/strings/utf_string_conversions.h" | 30 #include "base/strings/utf_string_conversions.h" |
31 #include "base/thread_task_runner_handle.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" |
37 #include "net/base/dns_util.h" | 38 #include "net/base/dns_util.h" |
38 #include "net/base/host_port_pair.h" | 39 #include "net/base/host_port_pair.h" |
39 #include "net/base/ip_endpoint.h" | 40 #include "net/base/ip_endpoint.h" |
40 #include "net/base/net_errors.h" | 41 #include "net/base/net_errors.h" |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 typedef base::Callback<void(int net_error, | 567 typedef base::Callback<void(int net_error, |
567 const AddressList& addr_list)> Callback; | 568 const AddressList& addr_list)> Callback; |
568 | 569 |
569 ProcTask(const Key& key, | 570 ProcTask(const Key& key, |
570 const ProcTaskParams& params, | 571 const ProcTaskParams& params, |
571 const Callback& callback, | 572 const Callback& callback, |
572 const BoundNetLog& job_net_log) | 573 const BoundNetLog& job_net_log) |
573 : key_(key), | 574 : key_(key), |
574 params_(params), | 575 params_(params), |
575 callback_(callback), | 576 callback_(callback), |
576 origin_loop_(base::MessageLoopProxy::current()), | 577 origin_loop_(base::ThreadTaskRunnerHandle::Get()), |
577 attempt_number_(0), | 578 attempt_number_(0), |
578 completed_attempt_number_(0), | 579 completed_attempt_number_(0), |
579 completed_attempt_error_(ERR_UNEXPECTED), | 580 completed_attempt_error_(ERR_UNEXPECTED), |
580 had_non_speculative_request_(false), | 581 had_non_speculative_request_(false), |
581 net_log_(job_net_log) { | 582 net_log_(job_net_log) { |
582 if (!params_.resolver_proc.get()) | 583 if (!params_.resolver_proc.get()) |
583 params_.resolver_proc = HostResolverProc::GetDefault(); | 584 params_.resolver_proc = HostResolverProc::GetDefault(); |
584 // If default is unset, use the system proc. | 585 // If default is unset, use the system proc. |
585 if (!params_.resolver_proc.get()) | 586 if (!params_.resolver_proc.get()) |
586 params_.resolver_proc = new SystemHostResolverProc(); | 587 params_.resolver_proc = new SystemHostResolverProc(); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
897 // Holds an owning reference to the HostResolverProc that we are going to use. | 898 // Holds an owning reference to the HostResolverProc that we are going to use. |
898 // This may not be the current resolver procedure by the time we call | 899 // This may not be the current resolver procedure by the time we call |
899 // ResolveAddrInfo, but that's OK... we'll use it anyways, and the owning | 900 // ResolveAddrInfo, but that's OK... we'll use it anyways, and the owning |
900 // reference ensures that it remains valid until we are done. | 901 // reference ensures that it remains valid until we are done. |
901 ProcTaskParams params_; | 902 ProcTaskParams params_; |
902 | 903 |
903 // The listener to the results of this ProcTask. | 904 // The listener to the results of this ProcTask. |
904 Callback callback_; | 905 Callback callback_; |
905 | 906 |
906 // Used to post ourselves onto the origin thread. | 907 // Used to post ourselves onto the origin thread. |
907 scoped_refptr<base::MessageLoopProxy> origin_loop_; | 908 scoped_refptr<base::SingleThreadTaskRunner> origin_loop_; |
asanka
2015/05/14 04:06:36
Could you rename this to task_runner_ and document
anujsharma
2015/05/14 04:39:40
Done.
| |
908 | 909 |
909 // Keeps track of the number of attempts we have made so far to resolve the | 910 // Keeps track of the number of attempts we have made so far to resolve the |
910 // host. Whenever we start an attempt to resolve the host, we increase this | 911 // host. Whenever we start an attempt to resolve the host, we increase this |
911 // number. | 912 // number. |
912 uint32 attempt_number_; | 913 uint32 attempt_number_; |
913 | 914 |
914 // The index of the attempt which finished first (or 0 if the job is still in | 915 // The index of the attempt which finished first (or 0 if the job is still in |
915 // progress). | 916 // progress). |
916 uint32 completed_attempt_number_; | 917 uint32 completed_attempt_number_; |
917 | 918 |
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2392 dns_client_->SetConfig(dns_config); | 2393 dns_client_->SetConfig(dns_config); |
2393 num_dns_failures_ = 0; | 2394 num_dns_failures_ = 0; |
2394 if (dns_client_->GetConfig()) | 2395 if (dns_client_->GetConfig()) |
2395 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); | 2396 UMA_HISTOGRAM_BOOLEAN("AsyncDNS.DnsClientEnabled", true); |
2396 } | 2397 } |
2397 | 2398 |
2398 AbortDnsTasks(); | 2399 AbortDnsTasks(); |
2399 } | 2400 } |
2400 | 2401 |
2401 } // namespace net | 2402 } // namespace net |
OLD | NEW |