OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CHROMECAST_NET_CONNECTIVITY_CHECKER_IMPL_H_ | 5 #ifndef CHROMECAST_NET_CONNECTIVITY_CHECKER_IMPL_H_ |
6 #define CHROMECAST_NET_CONNECTIVITY_CHECKER_IMPL_H_ | 6 #define CHROMECAST_NET_CONNECTIVITY_CHECKER_IMPL_H_ |
7 | 7 |
8 #include "base/cancelable_callback.h" | 8 #include "base/cancelable_callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "chromecast/net/connectivity_checker.h" | 10 #include "chromecast/net/connectivity_checker.h" |
| 11 #include "components/proxy_config/pref_proxy_config_tracker_impl.h" |
11 #include "net/base/network_change_notifier.h" | 12 #include "net/base/network_change_notifier.h" |
12 #include "net/url_request/url_request.h" | 13 #include "net/url_request/url_request.h" |
13 | 14 |
14 class GURL; | 15 class GURL; |
15 | 16 |
16 namespace base { | 17 namespace base { |
17 class SingleThreadTaskRunner; | 18 class SingleThreadTaskRunner; |
18 } | 19 } |
19 | 20 |
20 namespace net { | 21 namespace net { |
21 class SSLInfo; | 22 class SSLInfo; |
22 class URLRequest; | 23 class URLRequest; |
23 class URLRequestContext; | 24 class URLRequestContext; |
24 } | 25 } |
25 | 26 |
26 namespace chromecast { | 27 namespace chromecast { |
27 | 28 |
28 // Simple class to check network connectivity by sending a HEAD http request | 29 // Simple class to check network connectivity by sending a HEAD http request |
29 // to given url. | 30 // to given url. |
30 class ConnectivityCheckerImpl | 31 class ConnectivityCheckerImpl |
31 : public ConnectivityChecker, | 32 : public ConnectivityChecker, |
32 public net::URLRequest::Delegate, | 33 public net::URLRequest::Delegate, |
33 public net::NetworkChangeNotifier::NetworkChangeObserver { | 34 public net::NetworkChangeNotifier::NetworkChangeObserver { |
34 public: | 35 public: |
35 // Connectivity checking and initialization will run on task_runner. | 36 // Connectivity checking and initialization will run on task_runner. |
36 explicit ConnectivityCheckerImpl( | 37 explicit ConnectivityCheckerImpl( |
37 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 38 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 39 std::unique_ptr<net::ProxyConfigService> proxy_config_service); |
38 | 40 |
39 // ConnectivityChecker implementation: | 41 // ConnectivityChecker implementation: |
40 bool Connected() const override; | 42 bool Connected() const override; |
41 void Check() override; | 43 void Check() override; |
42 | 44 |
43 protected: | 45 protected: |
44 ~ConnectivityCheckerImpl() override; | 46 ~ConnectivityCheckerImpl() override; |
45 | 47 |
46 private: | 48 private: |
47 // UrlRequest::Delegate implementation: | 49 // UrlRequest::Delegate implementation: |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 94 |
93 net::NetworkChangeNotifier::ConnectionType connection_type_; | 95 net::NetworkChangeNotifier::ConnectionType connection_type_; |
94 // Number of connectivity check errors. | 96 // Number of connectivity check errors. |
95 unsigned int check_errors_; | 97 unsigned int check_errors_; |
96 bool network_changed_pending_; | 98 bool network_changed_pending_; |
97 // Timeout handler for connectivity checks. | 99 // Timeout handler for connectivity checks. |
98 // Note: Cancelling this timeout can cause the destructor for this class to be | 100 // Note: Cancelling this timeout can cause the destructor for this class to be |
99 // called. | 101 // called. |
100 base::CancelableCallback<void()> timeout_; | 102 base::CancelableCallback<void()> timeout_; |
101 | 103 |
| 104 std::unique_ptr<net::ProxyConfigService> proxy_config_service_; |
| 105 |
102 DISALLOW_COPY_AND_ASSIGN(ConnectivityCheckerImpl); | 106 DISALLOW_COPY_AND_ASSIGN(ConnectivityCheckerImpl); |
103 }; | 107 }; |
104 | 108 |
105 } // namespace chromecast | 109 } // namespace chromecast |
106 | 110 |
107 #endif // CHROMECAST_NET_CONNECTIVITY_CHECKER_IMPL_H_ | 111 #endif // CHROMECAST_NET_CONNECTIVITY_CHECKER_IMPL_H_ |
OLD | NEW |