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

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

Issue 3066031: Merge 54714 - Recommit 54405 - Fix late binding induced mismatch of Socket an... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/472/src/
Patch Set: Fix merge problems Created 10 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/ssl_client_socket_pool.h ('k') | net/socket/ssl_client_socket_pool_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "net/base/net_errors.h" 7 #include "net/base/net_errors.h"
8 #include "net/socket/client_socket_factory.h" 8 #include "net/socket/client_socket_factory.h"
9 #include "net/socket/client_socket_handle.h" 9 #include "net/socket/client_socket_handle.h"
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 case STATE_SSL_CONNECT: 94 case STATE_SSL_CONNECT:
95 case STATE_SSL_CONNECT_COMPLETE: 95 case STATE_SSL_CONNECT_COMPLETE:
96 return LOAD_STATE_SSL_HANDSHAKE; 96 return LOAD_STATE_SSL_HANDSHAKE;
97 default: 97 default:
98 NOTREACHED(); 98 NOTREACHED();
99 return LOAD_STATE_IDLE; 99 return LOAD_STATE_IDLE;
100 } 100 }
101 } 101 }
102 102
103 int SSLConnectJob::ConnectInternal() { 103 int SSLConnectJob::ConnectInternal() {
104 DetermineFirstState();
105 return DoLoop(OK);
106 }
107
108 void SSLConnectJob::DetermineFirstState() {
109 switch (params_->proxy()) { 104 switch (params_->proxy()) {
110 case ProxyServer::SCHEME_DIRECT: 105 case ProxyServer::SCHEME_DIRECT:
111 next_state_ = STATE_TCP_CONNECT; 106 next_state_ = STATE_TCP_CONNECT;
112 break; 107 break;
113 case ProxyServer::SCHEME_HTTP: 108 case ProxyServer::SCHEME_HTTP:
114 next_state_ = STATE_TUNNEL_CONNECT; 109 next_state_ = STATE_TUNNEL_CONNECT;
115 break; 110 break;
116 case ProxyServer::SCHEME_SOCKS4: 111 case ProxyServer::SCHEME_SOCKS4:
117 case ProxyServer::SCHEME_SOCKS5: 112 case ProxyServer::SCHEME_SOCKS5:
118 next_state_ = STATE_SOCKS_CONNECT; 113 next_state_ = STATE_SOCKS_CONNECT;
119 break; 114 break;
120 default: 115 default:
121 NOTREACHED() << "unknown proxy type"; 116 NOTREACHED() << "unknown proxy type";
122 break; 117 break;
123 } 118 }
119 return DoLoop(OK);
124 } 120 }
125 121
126 void SSLConnectJob::OnIOComplete(int result) { 122 void SSLConnectJob::OnIOComplete(int result) {
127 int rv = DoLoop(result); 123 int rv = DoLoop(result);
128 if (rv != ERR_IO_PENDING) 124 if (rv != ERR_IO_PENDING)
129 NotifyDelegateOfCompletion(rv); // Deletes |this|. 125 NotifyDelegateOfCompletion(rv); // Deletes |this|.
130 } 126 }
131 127
132 int SSLConnectJob::DoLoop(int result) { 128 int SSLConnectJob::DoLoop(int result) {
133 DCHECK_NE(next_state_, STATE_NONE); 129 DCHECK_NE(next_state_, STATE_NONE);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 int SSLConnectJob::DoSOCKSConnectComplete(int result) { 201 int SSLConnectJob::DoSOCKSConnectComplete(int result) {
206 if (result == OK) 202 if (result == OK)
207 next_state_ = STATE_SSL_CONNECT; 203 next_state_ = STATE_SSL_CONNECT;
208 204
209 return result; 205 return result;
210 } 206 }
211 207
212 int SSLConnectJob::DoTunnelConnect() { 208 int SSLConnectJob::DoTunnelConnect() {
213 DCHECK(http_proxy_pool_.get()); 209 DCHECK(http_proxy_pool_.get());
214 next_state_ = STATE_TUNNEL_CONNECT_COMPLETE; 210 next_state_ = STATE_TUNNEL_CONNECT_COMPLETE;
211
215 transport_socket_handle_.reset(new ClientSocketHandle()); 212 transport_socket_handle_.reset(new ClientSocketHandle());
216 scoped_refptr<HttpProxySocketParams> http_proxy_params = 213 scoped_refptr<HttpProxySocketParams> http_proxy_params =
217 params_->http_proxy_params(); 214 params_->http_proxy_params();
218 return transport_socket_handle_->Init( 215 return transport_socket_handle_->Init(
219 group_name(), http_proxy_params, 216 group_name(), http_proxy_params,
220 http_proxy_params->tcp_params()->destination().priority(), &callback_, 217 http_proxy_params->tcp_params()->destination().priority(), &callback_,
221 http_proxy_pool_, net_log()); 218 http_proxy_pool_, net_log());
222 } 219 }
223 220
224 int SSLConnectJob::DoTunnelConnectComplete(int result) { 221 int SSLConnectJob::DoTunnelConnectComplete(int result) {
225 ClientSocket* socket = transport_socket_handle_->socket(); 222 ClientSocket* socket = transport_socket_handle_->socket();
226 HttpProxyClientSocket* tunnel_socket = 223 HttpProxyClientSocket* tunnel_socket =
227 static_cast<HttpProxyClientSocket*>(socket); 224 static_cast<HttpProxyClientSocket*>(socket);
228 225
229 if (result == ERR_RETRY_CONNECTION) {
230 DetermineFirstState();
231 transport_socket_handle_->socket()->Disconnect();
232 return OK;
233 }
234
235 // Extract the information needed to prompt for the proxy authentication. 226 // Extract the information needed to prompt for the proxy authentication.
236 // so that when ClientSocketPoolBaseHelper calls |GetAdditionalErrorState|, 227 // so that when ClientSocketPoolBaseHelper calls |GetAdditionalErrorState|,
237 // we can easily set the state. 228 // we can easily set the state.
238 if (result == ERR_PROXY_AUTH_REQUESTED) 229 if (result == ERR_PROXY_AUTH_REQUESTED)
239 error_response_info_ = *tunnel_socket->GetResponseInfo(); 230 error_response_info_ = *tunnel_socket->GetResponseInfo();
240 231
241 if (result < 0) 232 if (result < 0)
242 return result; 233 return result;
243 234
244 if (tunnel_socket->NeedsRestartWithAuth()) { 235 DCHECK(tunnel_socket->IsConnected());
245 // We must have gotten an 'idle' tunnel socket that is waiting for auth.
246 // The HttpAuthController should have new credentials, we just need
247 // to retry.
248 next_state_ = STATE_TUNNEL_CONNECT_COMPLETE;
249 return tunnel_socket->RestartWithAuth(&callback_);
250 }
251
252 next_state_ = STATE_SSL_CONNECT; 236 next_state_ = STATE_SSL_CONNECT;
253 return result; 237 return result;
254 } 238 }
255 239
256 void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle * handle) { 240 void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle * handle) {
257 handle->set_ssl_error_response_info(error_response_info_); 241 if (error_response_info_.headers) {
242 handle->set_ssl_error_response_info(error_response_info_);
243 handle->set_pending_http_proxy_connection(
244 transport_socket_handle_.release());
245 }
258 if (!ssl_connect_start_time_.is_null()) 246 if (!ssl_connect_start_time_.is_null())
259 handle->set_is_ssl_error(true); 247 handle->set_is_ssl_error(true);
260 } 248 }
261 249
262 int SSLConnectJob::DoSSLConnect() { 250 int SSLConnectJob::DoSSLConnect() {
263 next_state_ = STATE_SSL_CONNECT_COMPLETE; 251 next_state_ = STATE_SSL_CONNECT_COMPLETE;
264 // Reset the timeout to just the time allowed for the SSL handshake. 252 // Reset the timeout to just the time allowed for the SSL handshake.
265 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds)); 253 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds));
266 ssl_connect_start_time_ = base::TimeTicks::Now(); 254 ssl_connect_start_time_ = base::TimeTicks::Now();
267 255
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 const std::string& group_name) const { 405 const std::string& group_name) const {
418 return base_.IdleSocketCountInGroup(group_name); 406 return base_.IdleSocketCountInGroup(group_name);
419 } 407 }
420 408
421 LoadState SSLClientSocketPool::GetLoadState( 409 LoadState SSLClientSocketPool::GetLoadState(
422 const std::string& group_name, const ClientSocketHandle* handle) const { 410 const std::string& group_name, const ClientSocketHandle* handle) const {
423 return base_.GetLoadState(group_name, handle); 411 return base_.GetLoadState(group_name, handle);
424 } 412 }
425 413
426 } // namespace net 414 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket_pool.h ('k') | net/socket/ssl_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698