| 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" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 net::NetworkChangeNotifier::ConnectionType type) override; | 58 net::NetworkChangeNotifier::ConnectionType type) override; |
| 59 | 59 |
| 60 void OnNetworkChangedInternal(); | 60 void OnNetworkChangedInternal(); |
| 61 | 61 |
| 62 // Cancels current connectivity checking in progress. | 62 // Cancels current connectivity checking in progress. |
| 63 void Cancel(); | 63 void Cancel(); |
| 64 | 64 |
| 65 // Sets connectivity and alerts observers if it has changed | 65 // Sets connectivity and alerts observers if it has changed |
| 66 void SetConnected(bool connected); | 66 void SetConnected(bool connected); |
| 67 | 67 |
| 68 enum class ErrorType { |
| 69 BAD_HTTP_STATUS = 1, |
| 70 SSL_CERTIFICATE_ERROR = 2, |
| 71 REQUEST_TIMEOUT = 3, |
| 72 }; |
| 73 |
| 68 // Called when URL request failed. | 74 // Called when URL request failed. |
| 69 void OnUrlRequestError(); | 75 void OnUrlRequestError(ErrorType type); |
| 70 | 76 |
| 71 // Called when URL request timed out. | 77 // Called when URL request timed out. |
| 72 void OnUrlRequestTimeout(); | 78 void OnUrlRequestTimeout(); |
| 73 | 79 |
| 80 void RecordNetworkConnectivityErrorType(ErrorType type); |
| 81 |
| 74 std::unique_ptr<GURL> connectivity_check_url_; | 82 std::unique_ptr<GURL> connectivity_check_url_; |
| 75 std::unique_ptr<net::URLRequestContext> url_request_context_; | 83 std::unique_ptr<net::URLRequestContext> url_request_context_; |
| 76 std::unique_ptr<net::URLRequest> url_request_; | 84 std::unique_ptr<net::URLRequest> url_request_; |
| 77 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 85 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 78 bool connected_; | 86 bool connected_; |
| 79 net::NetworkChangeNotifier::ConnectionType connection_type_; | 87 net::NetworkChangeNotifier::ConnectionType connection_type_; |
| 80 // Number of connectivity check errors. | 88 // Number of connectivity check errors. |
| 81 unsigned int check_errors_; | 89 unsigned int check_errors_; |
| 82 bool network_changed_pending_; | 90 bool network_changed_pending_; |
| 83 // Timeout handler for connectivity checks. | 91 // Timeout handler for connectivity checks. |
| 84 // Note: Cancelling this timeout can cause the destructor for this class to be | 92 // Note: Cancelling this timeout can cause the destructor for this class to be |
| 85 // to be called. | 93 // to be called. |
| 86 base::CancelableCallback<void()> timeout_; | 94 base::CancelableCallback<void()> timeout_; |
| 87 | 95 |
| 88 DISALLOW_COPY_AND_ASSIGN(ConnectivityCheckerImpl); | 96 DISALLOW_COPY_AND_ASSIGN(ConnectivityCheckerImpl); |
| 89 }; | 97 }; |
| 90 | 98 |
| 91 } // namespace chromecast | 99 } // namespace chromecast |
| 92 | 100 |
| 93 #endif // CHROMECAST_NET_CONNECTIVITY_CHECKER_IMPL_H_ | 101 #endif // CHROMECAST_NET_CONNECTIVITY_CHECKER_IMPL_H_ |
| OLD | NEW |