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/values.h" | 16 #include "base/values.h" |
16 #include "net/base/host_port_pair.h" | 17 #include "net/base/host_port_pair.h" |
17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
18 #include "net/http/http_proxy_client_socket.h" | 19 #include "net/http/http_proxy_client_socket.h" |
19 #include "net/http/http_proxy_client_socket_pool.h" | 20 #include "net/http/http_proxy_client_socket_pool.h" |
20 #include "net/socket/client_socket_factory.h" | 21 #include "net/socket/client_socket_factory.h" |
21 #include "net/socket/client_socket_handle.h" | 22 #include "net/socket/client_socket_handle.h" |
22 #include "net/socket/socks_client_socket_pool.h" | 23 #include "net/socket/socks_client_socket_pool.h" |
23 #include "net/socket/ssl_client_socket.h" | 24 #include "net/socket/ssl_client_socket.h" |
24 #include "net/socket/transport_client_socket_pool.h" | 25 #include "net/socket/transport_client_socket_pool.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 handle->set_connection_attempts(connection_attempts_); | 166 handle->set_connection_attempts(connection_attempts_); |
166 } | 167 } |
167 | 168 |
168 void SSLConnectJob::OnIOComplete(int result) { | 169 void SSLConnectJob::OnIOComplete(int result) { |
169 int rv = DoLoop(result); | 170 int rv = DoLoop(result); |
170 if (rv != ERR_IO_PENDING) | 171 if (rv != ERR_IO_PENDING) |
171 NotifyDelegateOfCompletion(rv); // Deletes |this|. | 172 NotifyDelegateOfCompletion(rv); // Deletes |this|. |
172 } | 173 } |
173 | 174 |
174 int SSLConnectJob::DoLoop(int result) { | 175 int SSLConnectJob::DoLoop(int result) { |
| 176 TRACE_EVENT0("net", "SSLConnectJob::DoLoop"); |
175 DCHECK_NE(next_state_, STATE_NONE); | 177 DCHECK_NE(next_state_, STATE_NONE); |
176 | 178 |
177 int rv = result; | 179 int rv = result; |
178 do { | 180 do { |
179 State state = next_state_; | 181 State state = next_state_; |
180 next_state_ = STATE_NONE; | 182 next_state_ = STATE_NONE; |
181 switch (state) { | 183 switch (state) { |
182 case STATE_TRANSPORT_CONNECT: | 184 case STATE_TRANSPORT_CONNECT: |
183 DCHECK_EQ(OK, rv); | 185 DCHECK_EQ(OK, rv); |
184 rv = DoTransportConnect(); | 186 rv = DoTransportConnect(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 error_response_info_ = *tunnel_socket->GetConnectResponseInfo(); | 284 error_response_info_ = *tunnel_socket->GetConnectResponseInfo(); |
283 } | 285 } |
284 if (result < 0) | 286 if (result < 0) |
285 return result; | 287 return result; |
286 | 288 |
287 next_state_ = STATE_SSL_CONNECT; | 289 next_state_ = STATE_SSL_CONNECT; |
288 return result; | 290 return result; |
289 } | 291 } |
290 | 292 |
291 int SSLConnectJob::DoSSLConnect() { | 293 int SSLConnectJob::DoSSLConnect() { |
| 294 TRACE_EVENT0("net", "SSLConnectJob::DoSSLConnect"); |
292 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462815 is fixed. | 295 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462815 is fixed. |
293 tracked_objects::ScopedTracker tracking_profile( | 296 tracked_objects::ScopedTracker tracking_profile( |
294 FROM_HERE_WITH_EXPLICIT_FUNCTION("462815 SSLConnectJob::DoSSLConnect")); | 297 FROM_HERE_WITH_EXPLICIT_FUNCTION("462815 SSLConnectJob::DoSSLConnect")); |
295 | 298 |
296 next_state_ = STATE_SSL_CONNECT_COMPLETE; | 299 next_state_ = STATE_SSL_CONNECT_COMPLETE; |
297 | 300 |
298 // Reset the timeout to just the time allowed for the SSL handshake. | 301 // Reset the timeout to just the time allowed for the SSL handshake. |
299 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds)); | 302 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds)); |
300 | 303 |
301 // If the handle has a fresh socket, get its connect start and DNS times. | 304 // If the handle has a fresh socket, get its connect start and DNS times. |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 if (base_.CloseOneIdleSocket()) | 672 if (base_.CloseOneIdleSocket()) |
670 return true; | 673 return true; |
671 return base_.CloseOneIdleConnectionInHigherLayeredPool(); | 674 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
672 } | 675 } |
673 | 676 |
674 void SSLClientSocketPool::OnSSLConfigChanged() { | 677 void SSLClientSocketPool::OnSSLConfigChanged() { |
675 FlushWithError(ERR_NETWORK_CHANGED); | 678 FlushWithError(ERR_NETWORK_CHANGED); |
676 } | 679 } |
677 | 680 |
678 } // namespace net | 681 } // namespace net |
OLD | NEW |