| 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 #ifndef CHROME_BROWSER_NET_DNS_PROBE_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_NET_DNS_PROBE_SERVICE_H_ |
| 6 #define CHROME_BROWSER_NET_DNS_PROBE_SERVICE_H_ | 6 #define CHROME_BROWSER_NET_DNS_PROBE_SERVICE_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/time.h" | 12 #include "base/time.h" |
| 13 #include "chrome/browser/net/dns_probe_job.h" | 13 #include "chrome/browser/net/dns_probe_job.h" |
| 14 #include "chrome/common/net/net_error_info.h" | 14 #include "chrome/common/net/net_error_info.h" |
| 15 #include "net/base/network_change_notifier.h" | 15 #include "net/base/network_change_notifier.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 struct DnsConfig; | 18 struct DnsConfig; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace chrome_browser_net { | 21 namespace chrome_browser_net { |
| 22 | 22 |
| 23 class DnsProbeService : public net::NetworkChangeNotifier::IPAddressObserver { | 23 class DnsProbeService |
| 24 : public net::NetworkChangeNotifier::NetworkChangeObserver { |
| 24 public: | 25 public: |
| 25 typedef base::Callback<void(chrome_common_net::DnsProbeResult result)> | 26 typedef base::Callback<void(chrome_common_net::DnsProbeResult result)> |
| 26 CallbackType; | 27 CallbackType; |
| 27 | 28 |
| 28 DnsProbeService(); | 29 DnsProbeService(); |
| 29 virtual ~DnsProbeService(); | 30 virtual ~DnsProbeService(); |
| 30 | 31 |
| 31 void ProbeDns(const CallbackType& callback); | 32 void ProbeDns(const CallbackType& callback); |
| 32 | 33 |
| 33 // NetworkChangeNotifier::IPAddressObserver implementation: | 34 // NetworkChangeNotifier::NetworkChangeObserver implementation: |
| 34 virtual void OnIPAddressChanged() OVERRIDE; | 35 virtual void OnNetworkChanged( |
| 36 net::NetworkChangeNotifier::ConnectionType type) OVERRIDE; |
| 35 | 37 |
| 36 protected: | 38 protected: |
| 37 // This can be called by tests to pretend the cached reuslt has expired. | 39 // This can be called by tests to pretend the cached reuslt has expired. |
| 38 void ExpireResults(); | 40 void ExpireResults(); |
| 39 | 41 |
| 40 private: | 42 private: |
| 41 enum State { | 43 enum State { |
| 42 STATE_NO_RESULTS, | 44 STATE_NO_RESULTS, |
| 43 STATE_PROBE_RUNNING, | 45 STATE_PROBE_RUNNING, |
| 44 STATE_RESULTS_CACHED, | 46 STATE_RESULTS_CACHED, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 int system_nameserver_count_; | 82 int system_nameserver_count_; |
| 81 // Whether the only system nameserver is 127.0.0.1. | 83 // Whether the only system nameserver is 127.0.0.1. |
| 82 bool system_is_localhost_; | 84 bool system_is_localhost_; |
| 83 | 85 |
| 84 DISALLOW_COPY_AND_ASSIGN(DnsProbeService); | 86 DISALLOW_COPY_AND_ASSIGN(DnsProbeService); |
| 85 }; | 87 }; |
| 86 | 88 |
| 87 } // namespace chrome_browser_net | 89 } // namespace chrome_browser_net |
| 88 | 90 |
| 89 #endif // CHROME_BROWSER_NET_DNS_PROBE_SERVICE_H_ | 91 #endif // CHROME_BROWSER_NET_DNS_PROBE_SERVICE_H_ |
| OLD | NEW |