| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/socket/ssl_client_socket_pool.h" | 5 #include "net/socket/ssl_client_socket_pool.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) { | 158 void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) { |
| 159 // Headers in |error_response_info_| indicate a proxy tunnel setup | 159 // Headers in |error_response_info_| indicate a proxy tunnel setup |
| 160 // problem. See DoTunnelConnectComplete. | 160 // problem. See DoTunnelConnectComplete. |
| 161 if (error_response_info_.headers.get()) { | 161 if (error_response_info_.headers.get()) { |
| 162 handle->set_pending_http_proxy_connection( | 162 handle->set_pending_http_proxy_connection( |
| 163 transport_socket_handle_.release()); | 163 transport_socket_handle_.release()); |
| 164 } | 164 } |
| 165 handle->set_ssl_error_response_info(error_response_info_); | 165 handle->set_ssl_error_response_info(error_response_info_); |
| 166 if (!connect_timing_.ssl_start.is_null()) | 166 if (!connect_timing_.ssl_start.is_null()) |
| 167 handle->set_is_ssl_error(true); | 167 handle->set_is_ssl_error(true); |
| 168 |
| 169 handle->set_connection_attempts(connection_attempts_); |
| 168 } | 170 } |
| 169 | 171 |
| 170 void SSLConnectJob::OnIOComplete(int result) { | 172 void SSLConnectJob::OnIOComplete(int result) { |
| 171 int rv = DoLoop(result); | 173 int rv = DoLoop(result); |
| 172 if (rv != ERR_IO_PENDING) | 174 if (rv != ERR_IO_PENDING) |
| 173 NotifyDelegateOfCompletion(rv); // Deletes |this|. | 175 NotifyDelegateOfCompletion(rv); // Deletes |this|. |
| 174 } | 176 } |
| 175 | 177 |
| 176 int SSLConnectJob::DoLoop(int result) { | 178 int SSLConnectJob::DoLoop(int result) { |
| 177 DCHECK_NE(next_state_, STATE_NONE); | 179 DCHECK_NE(next_state_, STATE_NONE); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 226 |
| 225 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; | 227 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; |
| 226 transport_socket_handle_.reset(new ClientSocketHandle()); | 228 transport_socket_handle_.reset(new ClientSocketHandle()); |
| 227 scoped_refptr<TransportSocketParams> direct_params = | 229 scoped_refptr<TransportSocketParams> direct_params = |
| 228 params_->GetDirectConnectionParams(); | 230 params_->GetDirectConnectionParams(); |
| 229 return transport_socket_handle_->Init(group_name(), direct_params, priority(), | 231 return transport_socket_handle_->Init(group_name(), direct_params, priority(), |
| 230 callback_, transport_pool_, net_log()); | 232 callback_, transport_pool_, net_log()); |
| 231 } | 233 } |
| 232 | 234 |
| 233 int SSLConnectJob::DoTransportConnectComplete(int result) { | 235 int SSLConnectJob::DoTransportConnectComplete(int result) { |
| 234 if (result == OK) | 236 connection_attempts_ = transport_socket_handle_->connection_attempts(); |
| 237 if (result == OK) { |
| 235 next_state_ = STATE_SSL_CONNECT; | 238 next_state_ = STATE_SSL_CONNECT; |
| 239 transport_socket_handle_->socket()->GetPeerAddress(&server_address_); |
| 240 } |
| 236 | 241 |
| 237 return result; | 242 return result; |
| 238 } | 243 } |
| 239 | 244 |
| 240 int SSLConnectJob::DoSOCKSConnect() { | 245 int SSLConnectJob::DoSOCKSConnect() { |
| 241 DCHECK(socks_pool_); | 246 DCHECK(socks_pool_); |
| 242 next_state_ = STATE_SOCKS_CONNECT_COMPLETE; | 247 next_state_ = STATE_SOCKS_CONNECT_COMPLETE; |
| 243 transport_socket_handle_.reset(new ClientSocketHandle()); | 248 transport_socket_handle_.reset(new ClientSocketHandle()); |
| 244 scoped_refptr<SOCKSSocketParams> socks_proxy_params = | 249 scoped_refptr<SOCKSSocketParams> socks_proxy_params = |
| 245 params_->GetSocksProxyConnectionParams(); | 250 params_->GetSocksProxyConnectionParams(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 } | 326 } |
| 322 | 327 |
| 323 int SSLConnectJob::DoSSLConnectComplete(int result) { | 328 int SSLConnectJob::DoSSLConnectComplete(int result) { |
| 324 // TODO(rvargas): Remove ScopedTracker below once crbug.com/462784 is fixed. | 329 // TODO(rvargas): Remove ScopedTracker below once crbug.com/462784 is fixed. |
| 325 tracked_objects::ScopedTracker tracking_profile( | 330 tracked_objects::ScopedTracker tracking_profile( |
| 326 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 331 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 327 "462784 SSLConnectJob::DoSSLConnectComplete")); | 332 "462784 SSLConnectJob::DoSSLConnectComplete")); |
| 328 | 333 |
| 329 connect_timing_.ssl_end = base::TimeTicks::Now(); | 334 connect_timing_.ssl_end = base::TimeTicks::Now(); |
| 330 | 335 |
| 336 if (result != OK && !server_address_.address().empty()) { |
| 337 connection_attempts_.push_back(ConnectionAttempt(server_address_, result)); |
| 338 server_address_ = IPEndPoint(); |
| 339 } |
| 340 |
| 331 SSLClientSocket::NextProtoStatus status = | 341 SSLClientSocket::NextProtoStatus status = |
| 332 SSLClientSocket::kNextProtoUnsupported; | 342 SSLClientSocket::kNextProtoUnsupported; |
| 333 std::string proto; | 343 std::string proto; |
| 334 // GetNextProto will fail and and trigger a NOTREACHED if we pass in a socket | 344 // GetNextProto will fail and and trigger a NOTREACHED if we pass in a socket |
| 335 // that hasn't had SSL_ImportFD called on it. If we get a certificate error | 345 // that hasn't had SSL_ImportFD called on it. If we get a certificate error |
| 336 // here, then we know that we called SSL_ImportFD. | 346 // here, then we know that we called SSL_ImportFD. |
| 337 if (result == OK || IsCertificateError(result)) { | 347 if (result == OK || IsCertificateError(result)) { |
| 338 status = ssl_socket_->GetNextProto(&proto); | 348 status = ssl_socket_->GetNextProto(&proto); |
| 339 ssl_socket_->RecordNegotiationExtension(); | 349 ssl_socket_->RecordNegotiationExtension(); |
| 340 } | 350 } |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 if (base_.CloseOneIdleSocket()) | 691 if (base_.CloseOneIdleSocket()) |
| 682 return true; | 692 return true; |
| 683 return base_.CloseOneIdleConnectionInHigherLayeredPool(); | 693 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
| 684 } | 694 } |
| 685 | 695 |
| 686 void SSLClientSocketPool::OnSSLConfigChanged() { | 696 void SSLClientSocketPool::OnSSLConfigChanged() { |
| 687 FlushWithError(ERR_NETWORK_CHANGED); | 697 FlushWithError(ERR_NETWORK_CHANGED); |
| 688 } | 698 } |
| 689 | 699 |
| 690 } // namespace net | 700 } // namespace net |
| OLD | NEW |