| 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 #include "chromecast/net/connectivity_checker_impl.h" | 5 #include "chromecast/net/connectivity_checker_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chromecast/base/metrics/cast_metrics_helper.h" | 14 #include "chromecast/base/metrics/cast_metrics_helper.h" |
| 15 #include "chromecast/chromecast_features.h" | 15 #include "chromecast/chromecast_features.h" |
| 16 #include "chromecast/net/net_switches.h" | 16 #include "chromecast/net/net_switches.h" |
| 17 #include "net/base/request_priority.h" | 17 #include "net/base/request_priority.h" |
| 18 #include "net/http/http_network_session.h" |
| 18 #include "net/http/http_response_headers.h" | 19 #include "net/http/http_response_headers.h" |
| 19 #include "net/http/http_response_info.h" | 20 #include "net/http/http_response_info.h" |
| 20 #include "net/http/http_status_code.h" | 21 #include "net/http/http_status_code.h" |
| 22 #include "net/http/http_transaction_factory.h" |
| 21 #include "net/socket/ssl_client_socket.h" | 23 #include "net/socket/ssl_client_socket.h" |
| 22 #include "net/url_request/url_request_context.h" | 24 #include "net/url_request/url_request_context.h" |
| 23 #include "net/url_request/url_request_context_builder.h" | 25 #include "net/url_request/url_request_context_builder.h" |
| 24 #include "net/url_request/url_request_context_getter.h" | 26 #include "net/url_request/url_request_context_getter.h" |
| 25 | 27 |
| 26 namespace chromecast { | 28 namespace chromecast { |
| 27 | 29 |
| 28 namespace { | 30 namespace { |
| 29 | 31 |
| 30 // How often connectivity checks are performed in seconds while not connected. | 32 // How often connectivity checks are performed in seconds while not connected. |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 | 207 |
| 206 void ConnectivityCheckerImpl::OnReadCompleted(net::URLRequest* request, | 208 void ConnectivityCheckerImpl::OnReadCompleted(net::URLRequest* request, |
| 207 int bytes_read) { | 209 int bytes_read) { |
| 208 NOTREACHED(); | 210 NOTREACHED(); |
| 209 } | 211 } |
| 210 | 212 |
| 211 void ConnectivityCheckerImpl::OnSSLCertificateError( | 213 void ConnectivityCheckerImpl::OnSSLCertificateError( |
| 212 net::URLRequest* request, | 214 net::URLRequest* request, |
| 213 const net::SSLInfo& ssl_info, | 215 const net::SSLInfo& ssl_info, |
| 214 bool fatal) { | 216 bool fatal) { |
| 217 if (url_request_context_->http_transaction_factory() |
| 218 ->GetSession() |
| 219 ->params() |
| 220 .ignore_certificate_errors) { |
| 221 LOG(WARNING) << "OnSSLCertificateError: ignore cert_status=" |
| 222 << ssl_info.cert_status; |
| 223 request->ContinueDespiteLastError(); |
| 224 return; |
| 225 } |
| 215 DCHECK(task_runner_->BelongsToCurrentThread()); | 226 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 216 LOG(ERROR) << "OnSSLCertificateError: cert_status=" << ssl_info.cert_status; | 227 LOG(ERROR) << "OnSSLCertificateError: cert_status=" << ssl_info.cert_status; |
| 217 net::SSLClientSocket::ClearSessionCache(); | 228 net::SSLClientSocket::ClearSessionCache(); |
| 218 OnUrlRequestError(ErrorType::SSL_CERTIFICATE_ERROR); | 229 OnUrlRequestError(ErrorType::SSL_CERTIFICATE_ERROR); |
| 219 timeout_.Cancel(); | 230 timeout_.Cancel(); |
| 220 } | 231 } |
| 221 | 232 |
| 222 void ConnectivityCheckerImpl::OnUrlRequestError(ErrorType type) { | 233 void ConnectivityCheckerImpl::OnUrlRequestError(ErrorType type) { |
| 223 DCHECK(task_runner_->BelongsToCurrentThread()); | 234 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 224 ++check_errors_; | 235 ++check_errors_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 248 void ConnectivityCheckerImpl::Cancel() { | 259 void ConnectivityCheckerImpl::Cancel() { |
| 249 DCHECK(task_runner_->BelongsToCurrentThread()); | 260 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 250 if (!url_request_.get()) | 261 if (!url_request_.get()) |
| 251 return; | 262 return; |
| 252 VLOG(2) << "Cancel connectivity check in progress"; | 263 VLOG(2) << "Cancel connectivity check in progress"; |
| 253 url_request_.reset(nullptr); // URLRequest::Cancel() is called in destructor. | 264 url_request_.reset(nullptr); // URLRequest::Cancel() is called in destructor. |
| 254 timeout_.Cancel(); | 265 timeout_.Cancel(); |
| 255 } | 266 } |
| 256 | 267 |
| 257 } // namespace chromecast | 268 } // namespace chromecast |
| OLD | NEW |