| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/metrics/sparse_histogram.h" | 13 #include "base/metrics/sparse_histogram.h" |
| 14 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
| 15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "net/base/host_port_pair.h" | 17 #include "net/base/host_port_pair.h" |
| 18 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
| 19 #include "net/base/trace_constants.h" |
| 19 #include "net/http/http_proxy_client_socket.h" | 20 #include "net/http/http_proxy_client_socket.h" |
| 20 #include "net/http/http_proxy_client_socket_pool.h" | 21 #include "net/http/http_proxy_client_socket_pool.h" |
| 21 #include "net/log/net_log_source_type.h" | 22 #include "net/log/net_log_source_type.h" |
| 22 #include "net/log/net_log_with_source.h" | 23 #include "net/log/net_log_with_source.h" |
| 23 #include "net/socket/client_socket_factory.h" | 24 #include "net/socket/client_socket_factory.h" |
| 24 #include "net/socket/client_socket_handle.h" | 25 #include "net/socket/client_socket_handle.h" |
| 25 #include "net/socket/socks_client_socket_pool.h" | 26 #include "net/socket/socks_client_socket_pool.h" |
| 26 #include "net/socket/ssl_client_socket.h" | 27 #include "net/socket/ssl_client_socket.h" |
| 27 #include "net/socket/transport_client_socket_pool.h" | 28 #include "net/socket/transport_client_socket_pool.h" |
| 28 #include "net/ssl/ssl_cert_request_info.h" | 29 #include "net/ssl/ssl_cert_request_info.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 handle->set_connection_attempts(connection_attempts_); | 170 handle->set_connection_attempts(connection_attempts_); |
| 170 } | 171 } |
| 171 | 172 |
| 172 void SSLConnectJob::OnIOComplete(int result) { | 173 void SSLConnectJob::OnIOComplete(int result) { |
| 173 int rv = DoLoop(result); | 174 int rv = DoLoop(result); |
| 174 if (rv != ERR_IO_PENDING) | 175 if (rv != ERR_IO_PENDING) |
| 175 NotifyDelegateOfCompletion(rv); // Deletes |this|. | 176 NotifyDelegateOfCompletion(rv); // Deletes |this|. |
| 176 } | 177 } |
| 177 | 178 |
| 178 int SSLConnectJob::DoLoop(int result) { | 179 int SSLConnectJob::DoLoop(int result) { |
| 179 TRACE_EVENT0("net", "SSLConnectJob::DoLoop"); | 180 TRACE_EVENT0(kNetTracingCategory, "SSLConnectJob::DoLoop"); |
| 180 DCHECK_NE(next_state_, STATE_NONE); | 181 DCHECK_NE(next_state_, STATE_NONE); |
| 181 | 182 |
| 182 int rv = result; | 183 int rv = result; |
| 183 do { | 184 do { |
| 184 State state = next_state_; | 185 State state = next_state_; |
| 185 next_state_ = STATE_NONE; | 186 next_state_ = STATE_NONE; |
| 186 switch (state) { | 187 switch (state) { |
| 187 case STATE_TRANSPORT_CONNECT: | 188 case STATE_TRANSPORT_CONNECT: |
| 188 DCHECK_EQ(OK, rv); | 189 DCHECK_EQ(OK, rv); |
| 189 rv = DoTransportConnect(); | 190 rv = DoTransportConnect(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 error_response_info_ = *tunnel_socket->GetConnectResponseInfo(); | 288 error_response_info_ = *tunnel_socket->GetConnectResponseInfo(); |
| 288 } | 289 } |
| 289 if (result < 0) | 290 if (result < 0) |
| 290 return result; | 291 return result; |
| 291 | 292 |
| 292 next_state_ = STATE_SSL_CONNECT; | 293 next_state_ = STATE_SSL_CONNECT; |
| 293 return result; | 294 return result; |
| 294 } | 295 } |
| 295 | 296 |
| 296 int SSLConnectJob::DoSSLConnect() { | 297 int SSLConnectJob::DoSSLConnect() { |
| 297 TRACE_EVENT0("net", "SSLConnectJob::DoSSLConnect"); | 298 TRACE_EVENT0(kNetTracingCategory, "SSLConnectJob::DoSSLConnect"); |
| 298 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462815 is fixed. | 299 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462815 is fixed. |
| 299 tracked_objects::ScopedTracker tracking_profile( | 300 tracked_objects::ScopedTracker tracking_profile( |
| 300 FROM_HERE_WITH_EXPLICIT_FUNCTION("462815 SSLConnectJob::DoSSLConnect")); | 301 FROM_HERE_WITH_EXPLICIT_FUNCTION("462815 SSLConnectJob::DoSSLConnect")); |
| 301 | 302 |
| 302 next_state_ = STATE_SSL_CONNECT_COMPLETE; | 303 next_state_ = STATE_SSL_CONNECT_COMPLETE; |
| 303 | 304 |
| 304 // Reset the timeout to just the time allowed for the SSL handshake. | 305 // Reset the timeout to just the time allowed for the SSL handshake. |
| 305 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds)); | 306 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds)); |
| 306 | 307 |
| 307 // If the handle has a fresh socket, get its connect start and DNS times. | 308 // If the handle has a fresh socket, get its connect start and DNS times. |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 if (base_.CloseOneIdleSocket()) | 686 if (base_.CloseOneIdleSocket()) |
| 686 return true; | 687 return true; |
| 687 return base_.CloseOneIdleConnectionInHigherLayeredPool(); | 688 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
| 688 } | 689 } |
| 689 | 690 |
| 690 void SSLClientSocketPool::OnSSLConfigChanged() { | 691 void SSLClientSocketPool::OnSSLConfigChanged() { |
| 691 FlushWithError(ERR_NETWORK_CHANGED); | 692 FlushWithError(ERR_NETWORK_CHANGED); |
| 692 } | 693 } |
| 693 | 694 |
| 694 } // namespace net | 695 } // namespace net |
| OLD | NEW |