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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
237 void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) { | 237 void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) { |
238 // Headers in |error_response_info_| indicate a proxy tunnel setup | 238 // Headers in |error_response_info_| indicate a proxy tunnel setup |
239 // problem. See DoTunnelConnectComplete. | 239 // problem. See DoTunnelConnectComplete. |
240 if (error_response_info_.headers.get()) { | 240 if (error_response_info_.headers.get()) { |
241 handle->set_pending_http_proxy_connection( | 241 handle->set_pending_http_proxy_connection( |
242 transport_socket_handle_.release()); | 242 transport_socket_handle_.release()); |
243 } | 243 } |
244 handle->set_ssl_error_response_info(error_response_info_); | 244 handle->set_ssl_error_response_info(error_response_info_); |
245 if (!connect_timing_.ssl_start.is_null()) | 245 if (!connect_timing_.ssl_start.is_null()) |
246 handle->set_is_ssl_error(true); | 246 handle->set_is_ssl_error(true); |
247 | |
248 handle->set_connection_attempts(connection_attempts_); | |
247 } | 249 } |
248 | 250 |
249 void SSLConnectJob::OnIOComplete(int result) { | 251 void SSLConnectJob::OnIOComplete(int result) { |
250 int rv = DoLoop(result); | 252 int rv = DoLoop(result); |
251 if (rv != ERR_IO_PENDING) | 253 if (rv != ERR_IO_PENDING) |
252 NotifyDelegateOfCompletion(rv); // Deletes |this|. | 254 NotifyDelegateOfCompletion(rv); // Deletes |this|. |
253 } | 255 } |
254 | 256 |
255 int SSLConnectJob::DoLoop(int result) { | 257 int SSLConnectJob::DoLoop(int result) { |
256 DCHECK_NE(next_state_, STATE_NONE); | 258 DCHECK_NE(next_state_, STATE_NONE); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 params_->GetDirectConnectionParams(); | 315 params_->GetDirectConnectionParams(); |
314 return transport_socket_handle_->Init(group_name(), | 316 return transport_socket_handle_->Init(group_name(), |
315 direct_params, | 317 direct_params, |
316 priority(), | 318 priority(), |
317 io_callback_, | 319 io_callback_, |
318 transport_pool_, | 320 transport_pool_, |
319 net_log()); | 321 net_log()); |
320 } | 322 } |
321 | 323 |
322 int SSLConnectJob::DoTransportConnectComplete(int result) { | 324 int SSLConnectJob::DoTransportConnectComplete(int result) { |
323 if (result == OK) | 325 connection_attempts_ = transport_socket_handle_->connection_attempts(); |
326 if (result == OK) { | |
324 next_state_ = STATE_CREATE_SSL_SOCKET; | 327 next_state_ = STATE_CREATE_SSL_SOCKET; |
328 transport_socket_handle_->socket()->GetPeerAddress(&direct_address_); | |
329 } | |
325 | 330 |
326 return result; | 331 return result; |
327 } | 332 } |
328 | 333 |
329 int SSLConnectJob::DoSOCKSConnect() { | 334 int SSLConnectJob::DoSOCKSConnect() { |
330 DCHECK(socks_pool_); | 335 DCHECK(socks_pool_); |
331 next_state_ = STATE_SOCKS_CONNECT_COMPLETE; | 336 next_state_ = STATE_SOCKS_CONNECT_COMPLETE; |
332 transport_socket_handle_.reset(new ClientSocketHandle()); | 337 transport_socket_handle_.reset(new ClientSocketHandle()); |
333 scoped_refptr<SOCKSSocketParams> socks_proxy_params = | 338 scoped_refptr<SOCKSSocketParams> socks_proxy_params = |
334 params_->GetSocksProxyConnectionParams(); | 339 params_->GetSocksProxyConnectionParams(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
444 next_state_ = STATE_SSL_CONNECT_COMPLETE; | 449 next_state_ = STATE_SSL_CONNECT_COMPLETE; |
445 | 450 |
446 connect_timing_.ssl_start = base::TimeTicks::Now(); | 451 connect_timing_.ssl_start = base::TimeTicks::Now(); |
447 | 452 |
448 return ssl_socket_->Connect(io_callback_); | 453 return ssl_socket_->Connect(io_callback_); |
449 } | 454 } |
450 | 455 |
451 int SSLConnectJob::DoSSLConnectComplete(int result) { | 456 int SSLConnectJob::DoSSLConnectComplete(int result) { |
452 connect_timing_.ssl_end = base::TimeTicks::Now(); | 457 connect_timing_.ssl_end = base::TimeTicks::Now(); |
453 | 458 |
459 if (result != OK && !direct_address_.address().empty()) { | |
460 connection_attempts_.push_back( | |
461 ClientSocketHandle::ConnectionAttempt(direct_address_, result)); | |
462 direct_address_ = IPEndPoint(); | |
Ryan Hamilton
2015/03/17 03:22:28
If this is the only place this member is used, it
Deprecated (see juliatuttle)
2015/03/23 17:45:35
I'm resetting it just to be careful, and yeah, I t
| |
463 } | |
464 | |
454 SSLClientSocket::NextProtoStatus status = | 465 SSLClientSocket::NextProtoStatus status = |
455 SSLClientSocket::kNextProtoUnsupported; | 466 SSLClientSocket::kNextProtoUnsupported; |
456 std::string proto; | 467 std::string proto; |
457 // GetNextProto will fail and and trigger a NOTREACHED if we pass in a socket | 468 // GetNextProto will fail and and trigger a NOTREACHED if we pass in a socket |
458 // that hasn't had SSL_ImportFD called on it. If we get a certificate error | 469 // that hasn't had SSL_ImportFD called on it. If we get a certificate error |
459 // here, then we know that we called SSL_ImportFD. | 470 // here, then we know that we called SSL_ImportFD. |
460 if (result == OK || IsCertificateError(result)) { | 471 if (result == OK || IsCertificateError(result)) { |
461 status = ssl_socket_->GetNextProto(&proto); | 472 status = ssl_socket_->GetNextProto(&proto); |
462 ssl_socket_->RecordNegotiationExtension(); | 473 ssl_socket_->RecordNegotiationExtension(); |
463 } | 474 } |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
857 CHECK(it != messenger_map_.end()); | 868 CHECK(it != messenger_map_.end()); |
858 delete it->second; | 869 delete it->second; |
859 messenger_map_.erase(it); | 870 messenger_map_.erase(it); |
860 } | 871 } |
861 | 872 |
862 void SSLClientSocketPool::OnSSLConfigChanged() { | 873 void SSLClientSocketPool::OnSSLConfigChanged() { |
863 FlushWithError(ERR_NETWORK_CHANGED); | 874 FlushWithError(ERR_NETWORK_CHANGED); |
864 } | 875 } |
865 | 876 |
866 } // namespace net | 877 } // namespace net |
OLD | NEW |