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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 handle->set_ssl_error_response_info(error_response_info_); | 160 handle->set_ssl_error_response_info(error_response_info_); |
160 if (!connect_timing_.ssl_start.is_null()) | 161 if (!connect_timing_.ssl_start.is_null()) |
161 handle->set_is_ssl_error(true); | 162 handle->set_is_ssl_error(true); |
162 if (ssl_socket_) | 163 if (ssl_socket_) |
163 handle->set_ssl_failure_state(ssl_socket_->GetSSLFailureState()); | 164 handle->set_ssl_failure_state(ssl_socket_->GetSSLFailureState()); |
164 | 165 |
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) { |
170 TRACE_EVENT0("net", "SSLConnectJob::OnIOComplete"); | |
mmenke
2016/04/04 16:45:49
Since we already have a separate event for DoLoop,
ssid
2016/04/05 00:50:13
Makes sense!
| |
169 int rv = DoLoop(result); | 171 int rv = DoLoop(result); |
170 if (rv != ERR_IO_PENDING) | 172 if (rv != ERR_IO_PENDING) |
171 NotifyDelegateOfCompletion(rv); // Deletes |this|. | 173 NotifyDelegateOfCompletion(rv); // Deletes |this|. |
172 } | 174 } |
173 | 175 |
174 int SSLConnectJob::DoLoop(int result) { | 176 int SSLConnectJob::DoLoop(int result) { |
177 TRACE_EVENT0("net", "SSLConnectJob::DoLoop"); | |
175 DCHECK_NE(next_state_, STATE_NONE); | 178 DCHECK_NE(next_state_, STATE_NONE); |
176 | 179 |
177 int rv = result; | 180 int rv = result; |
178 do { | 181 do { |
179 State state = next_state_; | 182 State state = next_state_; |
180 next_state_ = STATE_NONE; | 183 next_state_ = STATE_NONE; |
181 switch (state) { | 184 switch (state) { |
182 case STATE_TRANSPORT_CONNECT: | 185 case STATE_TRANSPORT_CONNECT: |
183 DCHECK_EQ(OK, rv); | 186 DCHECK_EQ(OK, rv); |
184 rv = DoTransportConnect(); | 187 rv = DoTransportConnect(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 error_response_info_ = *tunnel_socket->GetConnectResponseInfo(); | 285 error_response_info_ = *tunnel_socket->GetConnectResponseInfo(); |
283 } | 286 } |
284 if (result < 0) | 287 if (result < 0) |
285 return result; | 288 return result; |
286 | 289 |
287 next_state_ = STATE_SSL_CONNECT; | 290 next_state_ = STATE_SSL_CONNECT; |
288 return result; | 291 return result; |
289 } | 292 } |
290 | 293 |
291 int SSLConnectJob::DoSSLConnect() { | 294 int SSLConnectJob::DoSSLConnect() { |
295 TRACE_EVENT0("net", "SSLConnectJob::DoSSLConnect"); | |
292 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462815 is fixed. | 296 // TODO(pkasting): Remove ScopedTracker below once crbug.com/462815 is fixed. |
293 tracked_objects::ScopedTracker tracking_profile( | 297 tracked_objects::ScopedTracker tracking_profile( |
294 FROM_HERE_WITH_EXPLICIT_FUNCTION("462815 SSLConnectJob::DoSSLConnect")); | 298 FROM_HERE_WITH_EXPLICIT_FUNCTION("462815 SSLConnectJob::DoSSLConnect")); |
295 | 299 |
296 next_state_ = STATE_SSL_CONNECT_COMPLETE; | 300 next_state_ = STATE_SSL_CONNECT_COMPLETE; |
297 | 301 |
298 // Reset the timeout to just the time allowed for the SSL handshake. | 302 // Reset the timeout to just the time allowed for the SSL handshake. |
299 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds)); | 303 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds)); |
300 | 304 |
301 // If the handle has a fresh socket, get its connect start and DNS times. | 305 // 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()) | 673 if (base_.CloseOneIdleSocket()) |
670 return true; | 674 return true; |
671 return base_.CloseOneIdleConnectionInHigherLayeredPool(); | 675 return base_.CloseOneIdleConnectionInHigherLayeredPool(); |
672 } | 676 } |
673 | 677 |
674 void SSLClientSocketPool::OnSSLConfigChanged() { | 678 void SSLClientSocketPool::OnSSLConfigChanged() { |
675 FlushWithError(ERR_NETWORK_CHANGED); | 679 FlushWithError(ERR_NETWORK_CHANGED); |
676 } | 680 } |
677 | 681 |
678 } // namespace net | 682 } // namespace net |
OLD | NEW |