Chromium Code Reviews| 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 "net/base/network_change_notifier.h" | 11 #include "net/base/network_change_notifier.h" |
| 12 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" |
| 13 | 13 |
| 14 class GURL; | 14 class GURL; |
| 15 class PrefProxyConfigTracker; | |
| 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<PrefProxyConfigTracker> pref_proxy_config_tracker); | |
| 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; |
| 44 void DetachFromPrefService() override; | |
|
wzhong
2017/02/07 15:56:03
Can you add a Getter pref_proxy_config_tracker() s
almasrymina
2017/02/08 00:48:04
Removed with new approach.
| |
| 42 | 45 |
| 43 protected: | 46 protected: |
| 44 ~ConnectivityCheckerImpl() override; | 47 ~ConnectivityCheckerImpl() override; |
| 45 | 48 |
| 46 private: | 49 private: |
| 47 // UrlRequest::Delegate implementation: | 50 // UrlRequest::Delegate implementation: |
| 48 void OnResponseStarted(net::URLRequest* request) override; | 51 void OnResponseStarted(net::URLRequest* request) override; |
| 49 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; | 52 void OnReadCompleted(net::URLRequest* request, int bytes_read) override; |
| 50 void OnSSLCertificateError(net::URLRequest* request, | 53 void OnSSLCertificateError(net::URLRequest* request, |
| 51 const net::SSLInfo& ssl_info, | 54 const net::SSLInfo& ssl_info, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 | 95 |
| 93 net::NetworkChangeNotifier::ConnectionType connection_type_; | 96 net::NetworkChangeNotifier::ConnectionType connection_type_; |
| 94 // Number of connectivity check errors. | 97 // Number of connectivity check errors. |
| 95 unsigned int check_errors_; | 98 unsigned int check_errors_; |
| 96 bool network_changed_pending_; | 99 bool network_changed_pending_; |
| 97 // Timeout handler for connectivity checks. | 100 // Timeout handler for connectivity checks. |
| 98 // Note: Cancelling this timeout can cause the destructor for this class to be | 101 // Note: Cancelling this timeout can cause the destructor for this class to be |
| 99 // called. | 102 // called. |
| 100 base::CancelableCallback<void()> timeout_; | 103 base::CancelableCallback<void()> timeout_; |
| 101 | 104 |
| 105 std::unique_ptr<net::ProxyConfigService> proxy_config_service_; | |
| 106 std::unique_ptr<PrefProxyConfigTracker> pref_proxy_config_tracker_; | |
| 107 | |
| 102 DISALLOW_COPY_AND_ASSIGN(ConnectivityCheckerImpl); | 108 DISALLOW_COPY_AND_ASSIGN(ConnectivityCheckerImpl); |
| 103 }; | 109 }; |
| 104 | 110 |
| 105 } // namespace chromecast | 111 } // namespace chromecast |
| 106 | 112 |
| 107 #endif // CHROMECAST_NET_CONNECTIVITY_CHECKER_IMPL_H_ | 113 #endif // CHROMECAST_NET_CONNECTIVITY_CHECKER_IMPL_H_ |
| OLD | NEW |