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 // If we want SPDY over ALPN/NPN, make sure it succeeded. | 342 // If we want SPDY over ALPN/NPN, make sure it succeeded. |
333 if (params_->want_spdy_over_npn() && | 343 if (params_->want_spdy_over_npn() && |
334 !NextProtoIsSPDY(ssl_socket_->GetNegotiatedProtocol())) { | 344 !NextProtoIsSPDY(ssl_socket_->GetNegotiatedProtocol())) { |
335 return ERR_NPN_NEGOTIATION_FAILED; | 345 return ERR_NPN_NEGOTIATION_FAILED; |
336 } | 346 } |
337 | 347 |
338 if (result == OK || | 348 if (result == OK || |
339 ssl_socket_->IgnoreCertError(result, params_->load_flags())) { | 349 ssl_socket_->IgnoreCertError(result, params_->load_flags())) { |
340 DCHECK(!connect_timing_.ssl_start.is_null()); | 350 DCHECK(!connect_timing_.ssl_start.is_null()); |
341 base::TimeDelta connect_duration = | 351 base::TimeDelta connect_duration = |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 if (base_.CloseOneIdleSocket()) | 666 if (base_.CloseOneIdleSocket()) |
657 return true; | 667 return true; |
658 return base_.CloseOneIdleConnectionInHigherLayeredPool(); | 668 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
659 } | 669 } |
660 | 670 |
661 void SSLClientSocketPool::OnSSLConfigChanged() { | 671 void SSLClientSocketPool::OnSSLConfigChanged() { |
662 FlushWithError(ERR_NETWORK_CHANGED); | 672 FlushWithError(ERR_NETWORK_CHANGED); |
663 } | 673 } |
664 | 674 |
665 } // namespace net | 675 } // namespace net |
OLD | NEW |