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_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 URLRequestContext; | 21 class URLRequestContext; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace chromecast { | 24 namespace chromecast { |
| 25 | 25 |
| 26 // Simple class to check network connectivity by sending a HEAD http request | 26 // Simple class to check network connectivity by sending a HEAD http request |
| 27 // to given url. | 27 // to given url. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 38 | 38 |
| 39 protected: | 39 protected: |
| 40 ConnectivityObserver() {} | 40 ConnectivityObserver() {} |
| 41 virtual ~ConnectivityObserver() {} | 41 virtual ~ConnectivityObserver() {} |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 DISALLOW_COPY_AND_ASSIGN(ConnectivityObserver); | 44 DISALLOW_COPY_AND_ASSIGN(ConnectivityObserver); |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 explicit ConnectivityChecker( | 47 explicit ConnectivityChecker( |
| 48 const scoped_refptr<base::MessageLoopProxy>& loop_proxy); | 48 const scoped_refptr<base::SingleThreadTaskRunner>& loop_proxy); |
|
lcwu1
2015/05/19 01:45:38
s/loop_proxy/task_runner
gunsch
2015/05/19 03:01:58
Done.
gunsch
2015/05/19 03:01:58
Done.
| |
| 49 | 49 |
| 50 void AddConnectivityObserver(ConnectivityObserver* observer); | 50 void AddConnectivityObserver(ConnectivityObserver* observer); |
| 51 void RemoveConnectivityObserver(ConnectivityObserver* observer); | 51 void RemoveConnectivityObserver(ConnectivityObserver* observer); |
| 52 | 52 |
| 53 // Returns if there is internet connectivity | 53 // Returns if there is internet connectivity |
| 54 bool Connected() const; | 54 bool Connected() const; |
| 55 | 55 |
| 56 // Checks for connectivity | 56 // Checks for connectivity |
| 57 void Check(); | 57 void Check(); |
| 58 | 58 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 80 void Cancel(); | 80 void Cancel(); |
| 81 | 81 |
| 82 // Sets connectivity and alerts observers if it has changed | 82 // Sets connectivity and alerts observers if it has changed |
| 83 void SetConnectivity(bool connected); | 83 void SetConnectivity(bool connected); |
| 84 | 84 |
| 85 scoped_ptr<GURL> connectivity_check_url_; | 85 scoped_ptr<GURL> connectivity_check_url_; |
| 86 scoped_ptr<net::URLRequestContext> url_request_context_; | 86 scoped_ptr<net::URLRequestContext> url_request_context_; |
| 87 scoped_ptr<net::URLRequest> url_request_; | 87 scoped_ptr<net::URLRequest> url_request_; |
| 88 const scoped_refptr<ObserverListThreadSafe<ConnectivityObserver> > | 88 const scoped_refptr<ObserverListThreadSafe<ConnectivityObserver> > |
| 89 connectivity_observer_list_; | 89 connectivity_observer_list_; |
| 90 const scoped_refptr<base::MessageLoopProxy> loop_proxy_; | 90 const scoped_refptr<base::SingleThreadTaskRunner> loop_proxy_; |
|
lcwu1
2015/05/19 01:45:38
Ditto.
gunsch
2015/05/19 03:01:58
Done.
gunsch
2015/05/19 03:01:58
Done.
| |
| 91 bool connected_; | 91 bool connected_; |
| 92 unsigned int bad_responses_; | 92 unsigned int bad_responses_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(ConnectivityChecker); | 94 DISALLOW_COPY_AND_ASSIGN(ConnectivityChecker); |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace chromecast | 97 } // namespace chromecast |
| 98 | 98 |
| 99 #endif // CHROMECAST_NET_CONNECTIVITY_CHECKER_H_ | 99 #endif // CHROMECAST_NET_CONNECTIVITY_CHECKER_H_ |
| OLD | NEW |