| 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_H_ | 5 #ifndef CHROMECAST_NET_CONNECTIVITY_CHECKER_H_ |
| 6 #define CHROMECAST_NET_CONNECTIVITY_CHECKER_H_ | 6 #define CHROMECAST_NET_CONNECTIVITY_CHECKER_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.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 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class MessageLoopProxy; | 17 class SingleThreadTaskRunner; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace net { | 20 namespace net { |
| 21 class SSLInfo; | 21 class SSLInfo; |
| 22 class URLRequestContext; | 22 class URLRequestContext; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace chromecast { | 25 namespace chromecast { |
| 26 | 26 |
| 27 // Simple class to check network connectivity by sending a HEAD http request | 27 // Simple class to check network connectivity by sending a HEAD http request |
| (...skipping 11 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 protected: | 40 protected: |
| 41 ConnectivityObserver() {} | 41 ConnectivityObserver() {} |
| 42 virtual ~ConnectivityObserver() {} | 42 virtual ~ConnectivityObserver() {} |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 DISALLOW_COPY_AND_ASSIGN(ConnectivityObserver); | 45 DISALLOW_COPY_AND_ASSIGN(ConnectivityObserver); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 explicit ConnectivityChecker( | 48 explicit ConnectivityChecker( |
| 49 const scoped_refptr<base::MessageLoopProxy>& loop_proxy); | 49 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 50 | 50 |
| 51 void AddConnectivityObserver(ConnectivityObserver* observer); | 51 void AddConnectivityObserver(ConnectivityObserver* observer); |
| 52 void RemoveConnectivityObserver(ConnectivityObserver* observer); | 52 void RemoveConnectivityObserver(ConnectivityObserver* observer); |
| 53 | 53 |
| 54 // Returns if there is internet connectivity | 54 // Returns if there is internet connectivity |
| 55 bool Connected() const; | 55 bool Connected() const; |
| 56 | 56 |
| 57 // Checks for connectivity | 57 // Checks for connectivity |
| 58 void Check(); | 58 void Check(); |
| 59 | 59 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 87 void SetConnectivity(bool connected); | 87 void SetConnectivity(bool connected); |
| 88 | 88 |
| 89 // Called when URL request failed. | 89 // Called when URL request failed. |
| 90 void OnUrlRequestError(); | 90 void OnUrlRequestError(); |
| 91 | 91 |
| 92 scoped_ptr<GURL> connectivity_check_url_; | 92 scoped_ptr<GURL> connectivity_check_url_; |
| 93 scoped_ptr<net::URLRequestContext> url_request_context_; | 93 scoped_ptr<net::URLRequestContext> url_request_context_; |
| 94 scoped_ptr<net::URLRequest> url_request_; | 94 scoped_ptr<net::URLRequest> url_request_; |
| 95 const scoped_refptr<ObserverListThreadSafe<ConnectivityObserver> > | 95 const scoped_refptr<ObserverListThreadSafe<ConnectivityObserver> > |
| 96 connectivity_observer_list_; | 96 connectivity_observer_list_; |
| 97 const scoped_refptr<base::MessageLoopProxy> loop_proxy_; | 97 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 98 bool connected_; | 98 bool connected_; |
| 99 // Number of connectivity check errors. | 99 // Number of connectivity check errors. |
| 100 unsigned int check_errors_; | 100 unsigned int check_errors_; |
| 101 | 101 |
| 102 DISALLOW_COPY_AND_ASSIGN(ConnectivityChecker); | 102 DISALLOW_COPY_AND_ASSIGN(ConnectivityChecker); |
| 103 }; | 103 }; |
| 104 | 104 |
| 105 } // namespace chromecast | 105 } // namespace chromecast |
| 106 | 106 |
| 107 #endif // CHROMECAST_NET_CONNECTIVITY_CHECKER_H_ | 107 #endif // CHROMECAST_NET_CONNECTIVITY_CHECKER_H_ |
| OLD | NEW |