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 |
74 std::unique_ptr<GURL> connectivity_check_url_; | 80 std::unique_ptr<GURL> connectivity_check_url_; |
75 std::unique_ptr<net::URLRequestContext> url_request_context_; | 81 std::unique_ptr<net::URLRequestContext> url_request_context_; |
76 std::unique_ptr<net::URLRequest> url_request_; | 82 std::unique_ptr<net::URLRequest> url_request_; |
77 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 83 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
78 bool connected_; | 84 bool connected_; |
79 net::NetworkChangeNotifier::ConnectionType connection_type_; | 85 net::NetworkChangeNotifier::ConnectionType connection_type_; |
80 // Number of connectivity check errors. | 86 // Number of connectivity check errors. |
81 unsigned int check_errors_; | 87 unsigned int check_errors_; |
82 bool network_changed_pending_; | 88 bool network_changed_pending_; |
83 // Timeout handler for connectivity checks. | 89 // Timeout handler for connectivity checks. |
84 // Note: Cancelling this timeout can cause the destructor for this class to be | 90 // Note: Cancelling this timeout can cause the destructor for this class to be |
85 // to be called. | 91 // to be called. |
86 base::CancelableCallback<void()> timeout_; | 92 base::CancelableCallback<void()> timeout_; |
87 | 93 |
88 DISALLOW_COPY_AND_ASSIGN(ConnectivityCheckerImpl); | 94 DISALLOW_COPY_AND_ASSIGN(ConnectivityCheckerImpl); |
89 }; | 95 }; |
90 | 96 |
91 } // namespace chromecast | 97 } // namespace chromecast |
92 | 98 |
93 #endif // CHROMECAST_NET_CONNECTIVITY_CHECKER_IMPL_H_ | 99 #endif // CHROMECAST_NET_CONNECTIVITY_CHECKER_IMPL_H_ |
OLD | NEW |