OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/net/dns_probe_runner.h" | 5 #include "chrome/browser/net/dns_probe_runner.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
11 #include "net/base/address_list.h" | 11 #include "net/base/address_list.h" |
12 #include "net/base/ip_endpoint.h" | 12 #include "net/base/ip_endpoint.h" |
13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
14 #include "net/base/network_change_notifier.h" | 14 #include "net/base/network_change_notifier.h" |
15 #include "net/dns/dns_client.h" | 15 #include "net/dns/dns_client.h" |
16 #include "net/dns/dns_protocol.h" | 16 #include "net/dns/dns_protocol.h" |
17 #include "net/dns/dns_response.h" | 17 #include "net/dns/dns_response.h" |
18 #include "net/dns/dns_transaction.h" | 18 #include "net/dns/dns_transaction.h" |
19 #include "net/log/net_log.h" | 19 #include "net/log/net_log.h" |
20 | 20 |
21 using base::TimeDelta; | 21 using base::TimeDelta; |
22 using content::BrowserThread; | 22 using content::BrowserThread; |
23 using net::AddressList; | 23 using net::AddressList; |
24 using net::BoundNetLog; | |
25 using net::DnsClient; | 24 using net::DnsClient; |
26 using net::DnsResponse; | 25 using net::DnsResponse; |
27 using net::DnsTransaction; | 26 using net::DnsTransaction; |
28 using net::DnsTransactionFactory; | 27 using net::DnsTransactionFactory; |
29 using net::IPEndPoint; | 28 using net::IPEndPoint; |
30 using net::NetLog; | 29 using net::NetLog; |
| 30 using net::NetLogWithSource; |
31 using net::NetworkChangeNotifier; | 31 using net::NetworkChangeNotifier; |
32 | 32 |
33 namespace chrome_browser_net { | 33 namespace chrome_browser_net { |
34 | 34 |
35 const char DnsProbeRunner::kKnownGoodHostname[] = "google.com"; | 35 const char DnsProbeRunner::kKnownGoodHostname[] = "google.com"; |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
39 DnsProbeRunner::Result EvaluateResponse( | 39 DnsProbeRunner::Result EvaluateResponse( |
40 int net_error, | 40 int net_error, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 result_ = UNKNOWN; | 100 result_ = UNKNOWN; |
101 BrowserThread::PostTask( | 101 BrowserThread::PostTask( |
102 BrowserThread::IO, | 102 BrowserThread::IO, |
103 FROM_HERE, | 103 FROM_HERE, |
104 base::Bind(&DnsProbeRunner::CallCallback, | 104 base::Bind(&DnsProbeRunner::CallCallback, |
105 weak_factory_.GetWeakPtr())); | 105 weak_factory_.GetWeakPtr())); |
106 return; | 106 return; |
107 } | 107 } |
108 | 108 |
109 transaction_ = factory->CreateTransaction( | 109 transaction_ = factory->CreateTransaction( |
110 kKnownGoodHostname, | 110 kKnownGoodHostname, net::dns_protocol::kTypeA, |
111 net::dns_protocol::kTypeA, | |
112 base::Bind(&DnsProbeRunner::OnTransactionComplete, | 111 base::Bind(&DnsProbeRunner::OnTransactionComplete, |
113 weak_factory_.GetWeakPtr()), | 112 weak_factory_.GetWeakPtr()), |
114 BoundNetLog()); | 113 NetLogWithSource()); |
115 | 114 |
116 transaction_->Start(); | 115 transaction_->Start(); |
117 } | 116 } |
118 | 117 |
119 bool DnsProbeRunner::IsRunning() const { | 118 bool DnsProbeRunner::IsRunning() const { |
120 return !callback_.is_null(); | 119 return !callback_.is_null(); |
121 } | 120 } |
122 | 121 |
123 void DnsProbeRunner::OnTransactionComplete( | 122 void DnsProbeRunner::OnTransactionComplete( |
124 DnsTransaction* transaction, | 123 DnsTransaction* transaction, |
(...skipping 17 matching lines...) Expand all Loading... |
142 DCHECK(!callback_.is_null()); | 141 DCHECK(!callback_.is_null()); |
143 DCHECK(!transaction_.get()); | 142 DCHECK(!transaction_.get()); |
144 | 143 |
145 // Clear callback in case it starts a new probe immediately. | 144 // Clear callback in case it starts a new probe immediately. |
146 const base::Closure callback = callback_; | 145 const base::Closure callback = callback_; |
147 callback_.Reset(); | 146 callback_.Reset(); |
148 callback.Run(); | 147 callback.Run(); |
149 } | 148 } |
150 | 149 |
151 } // namespace chrome_browser_net | 150 } // namespace chrome_browser_net |
OLD | NEW |