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