Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: net/socket/ssl_client_socket_pool.cc

Issue 1006643002: Plumb connection attempts from (non-proxy) ConnectJobs to HttpNetworkTransaction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't copy attempts after reset on proxy HTTPS tunnel response Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) { 157 void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) {
158 // Headers in |error_response_info_| indicate a proxy tunnel setup 158 // Headers in |error_response_info_| indicate a proxy tunnel setup
159 // problem. See DoTunnelConnectComplete. 159 // problem. See DoTunnelConnectComplete.
160 if (error_response_info_.headers.get()) { 160 if (error_response_info_.headers.get()) {
161 handle->set_pending_http_proxy_connection( 161 handle->set_pending_http_proxy_connection(
162 transport_socket_handle_.release()); 162 transport_socket_handle_.release());
163 } 163 }
164 handle->set_ssl_error_response_info(error_response_info_); 164 handle->set_ssl_error_response_info(error_response_info_);
165 if (!connect_timing_.ssl_start.is_null()) 165 if (!connect_timing_.ssl_start.is_null())
166 handle->set_is_ssl_error(true); 166 handle->set_is_ssl_error(true);
167
168 handle->set_connection_attempts(connection_attempts_);
167 } 169 }
168 170
169 void SSLConnectJob::OnIOComplete(int result) { 171 void SSLConnectJob::OnIOComplete(int result) {
170 int rv = DoLoop(result); 172 int rv = DoLoop(result);
171 if (rv != ERR_IO_PENDING) 173 if (rv != ERR_IO_PENDING)
172 NotifyDelegateOfCompletion(rv); // Deletes |this|. 174 NotifyDelegateOfCompletion(rv); // Deletes |this|.
173 } 175 }
174 176
175 int SSLConnectJob::DoLoop(int result) { 177 int SSLConnectJob::DoLoop(int result) {
176 DCHECK_NE(next_state_, STATE_NONE); 178 DCHECK_NE(next_state_, STATE_NONE);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 225
224 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE; 226 next_state_ = STATE_TRANSPORT_CONNECT_COMPLETE;
225 transport_socket_handle_.reset(new ClientSocketHandle()); 227 transport_socket_handle_.reset(new ClientSocketHandle());
226 scoped_refptr<TransportSocketParams> direct_params = 228 scoped_refptr<TransportSocketParams> direct_params =
227 params_->GetDirectConnectionParams(); 229 params_->GetDirectConnectionParams();
228 return transport_socket_handle_->Init(group_name(), direct_params, priority(), 230 return transport_socket_handle_->Init(group_name(), direct_params, priority(),
229 callback_, transport_pool_, net_log()); 231 callback_, transport_pool_, net_log());
230 } 232 }
231 233
232 int SSLConnectJob::DoTransportConnectComplete(int result) { 234 int SSLConnectJob::DoTransportConnectComplete(int result) {
233 if (result == OK) 235 connection_attempts_ = transport_socket_handle_->connection_attempts();
236 if (result == OK) {
234 next_state_ = STATE_SSL_CONNECT; 237 next_state_ = STATE_SSL_CONNECT;
238 transport_socket_handle_->socket()->GetPeerAddress(&direct_address_);
239 }
235 240
236 return result; 241 return result;
237 } 242 }
238 243
239 int SSLConnectJob::DoSOCKSConnect() { 244 int SSLConnectJob::DoSOCKSConnect() {
240 DCHECK(socks_pool_); 245 DCHECK(socks_pool_);
241 next_state_ = STATE_SOCKS_CONNECT_COMPLETE; 246 next_state_ = STATE_SOCKS_CONNECT_COMPLETE;
242 transport_socket_handle_.reset(new ClientSocketHandle()); 247 transport_socket_handle_.reset(new ClientSocketHandle());
243 scoped_refptr<SOCKSSocketParams> socks_proxy_params = 248 scoped_refptr<SOCKSSocketParams> socks_proxy_params =
244 params_->GetSocksProxyConnectionParams(); 249 params_->GetSocksProxyConnectionParams();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 transport_socket_handle_.Pass(), 320 transport_socket_handle_.Pass(),
316 params_->host_and_port(), 321 params_->host_and_port(),
317 params_->ssl_config(), 322 params_->ssl_config(),
318 context_); 323 context_);
319 return ssl_socket_->Connect(callback_); 324 return ssl_socket_->Connect(callback_);
320 } 325 }
321 326
322 int SSLConnectJob::DoSSLConnectComplete(int result) { 327 int SSLConnectJob::DoSSLConnectComplete(int result) {
323 connect_timing_.ssl_end = base::TimeTicks::Now(); 328 connect_timing_.ssl_end = base::TimeTicks::Now();
324 329
330 if (result != OK && !direct_address_.address().empty()) {
331 connection_attempts_.push_back(
332 ClientSocketHandle::ConnectionAttempt(direct_address_, result));
333 direct_address_ = IPEndPoint();
334 }
335
325 SSLClientSocket::NextProtoStatus status = 336 SSLClientSocket::NextProtoStatus status =
326 SSLClientSocket::kNextProtoUnsupported; 337 SSLClientSocket::kNextProtoUnsupported;
327 std::string proto; 338 std::string proto;
328 // GetNextProto will fail and and trigger a NOTREACHED if we pass in a socket 339 // GetNextProto will fail and and trigger a NOTREACHED if we pass in a socket
329 // that hasn't had SSL_ImportFD called on it. If we get a certificate error 340 // that hasn't had SSL_ImportFD called on it. If we get a certificate error
330 // here, then we know that we called SSL_ImportFD. 341 // here, then we know that we called SSL_ImportFD.
331 if (result == OK || IsCertificateError(result)) { 342 if (result == OK || IsCertificateError(result)) {
332 status = ssl_socket_->GetNextProto(&proto); 343 status = ssl_socket_->GetNextProto(&proto);
333 ssl_socket_->RecordNegotiationExtension(); 344 ssl_socket_->RecordNegotiationExtension();
334 } 345 }
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 if (base_.CloseOneIdleSocket()) 697 if (base_.CloseOneIdleSocket())
687 return true; 698 return true;
688 return base_.CloseOneIdleConnectionInHigherLayeredPool(); 699 return base_.CloseOneIdleConnectionInHigherLayeredPool();
689 } 700 }
690 701
691 void SSLClientSocketPool::OnSSLConfigChanged() { 702 void SSLClientSocketPool::OnSSLConfigChanged() {
692 FlushWithError(ERR_NETWORK_CHANGED); 703 FlushWithError(ERR_NETWORK_CHANGED);
693 } 704 }
694 705
695 } // namespace net 706 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698