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

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

Issue 3056040: Revert 54405 - Fix late binding induced mismatch of Socket and AuthController... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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')
Property Changes:
Added: svn:mergeinfo
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 case STATE_SSL_CONNECT: 96 case STATE_SSL_CONNECT:
97 case STATE_SSL_CONNECT_COMPLETE: 97 case STATE_SSL_CONNECT_COMPLETE:
98 return LOAD_STATE_SSL_HANDSHAKE; 98 return LOAD_STATE_SSL_HANDSHAKE;
99 default: 99 default:
100 NOTREACHED(); 100 NOTREACHED();
101 return LOAD_STATE_IDLE; 101 return LOAD_STATE_IDLE;
102 } 102 }
103 } 103 }
104 104
105 int SSLConnectJob::ConnectInternal() { 105 int SSLConnectJob::ConnectInternal() {
106 DetermineFirstState();
107 return DoLoop(OK);
108 }
109
110 void SSLConnectJob::DetermineFirstState() {
106 switch (params_->proxy()) { 111 switch (params_->proxy()) {
107 case ProxyServer::SCHEME_DIRECT: 112 case ProxyServer::SCHEME_DIRECT:
108 next_state_ = STATE_TCP_CONNECT; 113 next_state_ = STATE_TCP_CONNECT;
109 break; 114 break;
110 case ProxyServer::SCHEME_HTTP: 115 case ProxyServer::SCHEME_HTTP:
111 next_state_ = STATE_TUNNEL_CONNECT; 116 next_state_ = STATE_TUNNEL_CONNECT;
112 break; 117 break;
113 case ProxyServer::SCHEME_SOCKS4: 118 case ProxyServer::SCHEME_SOCKS4:
114 case ProxyServer::SCHEME_SOCKS5: 119 case ProxyServer::SCHEME_SOCKS5:
115 next_state_ = STATE_SOCKS_CONNECT; 120 next_state_ = STATE_SOCKS_CONNECT;
116 break; 121 break;
117 default: 122 default:
118 NOTREACHED() << "unknown proxy type"; 123 NOTREACHED() << "unknown proxy type";
119 break; 124 break;
120 } 125 }
121 return DoLoop(OK);
122 } 126 }
123 127
124 void SSLConnectJob::OnIOComplete(int result) { 128 void SSLConnectJob::OnIOComplete(int result) {
125 int rv = DoLoop(result); 129 int rv = DoLoop(result);
126 if (rv != ERR_IO_PENDING) 130 if (rv != ERR_IO_PENDING)
127 NotifyDelegateOfCompletion(rv); // Deletes |this|. 131 NotifyDelegateOfCompletion(rv); // Deletes |this|.
128 } 132 }
129 133
130 int SSLConnectJob::DoLoop(int result) { 134 int SSLConnectJob::DoLoop(int result) {
131 DCHECK_NE(next_state_, STATE_NONE); 135 DCHECK_NE(next_state_, STATE_NONE);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 int SSLConnectJob::DoSOCKSConnectComplete(int result) { 207 int SSLConnectJob::DoSOCKSConnectComplete(int result) {
204 if (result == OK) 208 if (result == OK)
205 next_state_ = STATE_SSL_CONNECT; 209 next_state_ = STATE_SSL_CONNECT;
206 210
207 return result; 211 return result;
208 } 212 }
209 213
210 int SSLConnectJob::DoTunnelConnect() { 214 int SSLConnectJob::DoTunnelConnect() {
211 DCHECK(http_proxy_pool_.get()); 215 DCHECK(http_proxy_pool_.get());
212 next_state_ = STATE_TUNNEL_CONNECT_COMPLETE; 216 next_state_ = STATE_TUNNEL_CONNECT_COMPLETE;
213
214 transport_socket_handle_.reset(new ClientSocketHandle()); 217 transport_socket_handle_.reset(new ClientSocketHandle());
215 scoped_refptr<HttpProxySocketParams> http_proxy_params = 218 scoped_refptr<HttpProxySocketParams> http_proxy_params =
216 params_->http_proxy_params(); 219 params_->http_proxy_params();
217 return transport_socket_handle_->Init( 220 return transport_socket_handle_->Init(
218 group_name(), http_proxy_params, 221 group_name(), http_proxy_params,
219 http_proxy_params->tcp_params()->destination().priority(), &callback_, 222 http_proxy_params->tcp_params()->destination().priority(), &callback_,
220 http_proxy_pool_, net_log()); 223 http_proxy_pool_, net_log());
221 } 224 }
222 225
223 int SSLConnectJob::DoTunnelConnectComplete(int result) { 226 int SSLConnectJob::DoTunnelConnectComplete(int result) {
224 ClientSocket* socket = transport_socket_handle_->socket(); 227 ClientSocket* socket = transport_socket_handle_->socket();
225 HttpProxyClientSocket* tunnel_socket = 228 HttpProxyClientSocket* tunnel_socket =
226 static_cast<HttpProxyClientSocket*>(socket); 229 static_cast<HttpProxyClientSocket*>(socket);
227 230
231 if (result == ERR_RETRY_CONNECTION) {
232 DetermineFirstState();
233 transport_socket_handle_->socket()->Disconnect();
234 return OK;
235 }
236
228 // Extract the information needed to prompt for the proxy authentication. 237 // Extract the information needed to prompt for the proxy authentication.
229 // so that when ClientSocketPoolBaseHelper calls |GetAdditionalErrorState|, 238 // so that when ClientSocketPoolBaseHelper calls |GetAdditionalErrorState|,
230 // we can easily set the state. 239 // we can easily set the state.
231 if (result == ERR_PROXY_AUTH_REQUESTED) 240 if (result == ERR_PROXY_AUTH_REQUESTED)
232 error_response_info_ = *tunnel_socket->GetResponseInfo(); 241 error_response_info_ = *tunnel_socket->GetResponseInfo();
233 242
234 if (result < 0) 243 if (result < 0)
235 return result; 244 return result;
236 245
237 DCHECK(tunnel_socket->IsConnected()); 246 if (tunnel_socket->NeedsRestartWithAuth()) {
247 // We must have gotten an 'idle' tunnel socket that is waiting for auth.
248 // The HttpAuthController should have new credentials, we just need
249 // to retry.
250 next_state_ = STATE_TUNNEL_CONNECT_COMPLETE;
251 return tunnel_socket->RestartWithAuth(&callback_);
252 }
253
238 next_state_ = STATE_SSL_CONNECT; 254 next_state_ = STATE_SSL_CONNECT;
239 return result; 255 return result;
240 } 256 }
241 257
242 void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle * handle) { 258 void SSLConnectJob::GetAdditionalErrorState(ClientSocketHandle * handle) {
243 if (error_response_info_.headers) { 259 handle->set_ssl_error_response_info(error_response_info_);
244 handle->set_ssl_error_response_info(error_response_info_);
245 handle->set_pending_http_proxy_connection(
246 transport_socket_handle_.release());
247 }
248 if (!ssl_connect_start_time_.is_null()) 260 if (!ssl_connect_start_time_.is_null())
249 handle->set_is_ssl_error(true); 261 handle->set_is_ssl_error(true);
250 } 262 }
251 263
252 int SSLConnectJob::DoSSLConnect() { 264 int SSLConnectJob::DoSSLConnect() {
253 next_state_ = STATE_SSL_CONNECT_COMPLETE; 265 next_state_ = STATE_SSL_CONNECT_COMPLETE;
254 // Reset the timeout to just the time allowed for the SSL handshake. 266 // Reset the timeout to just the time allowed for the SSL handshake.
255 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds)); 267 ResetTimer(base::TimeDelta::FromSeconds(kSSLHandshakeTimeoutInSeconds));
256 ssl_connect_start_time_ = base::TimeTicks::Now(); 268 ssl_connect_start_time_ = base::TimeTicks::Now();
257 269
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 const std::string& group_name) const { 424 const std::string& group_name) const {
413 return base_.IdleSocketCountInGroup(group_name); 425 return base_.IdleSocketCountInGroup(group_name);
414 } 426 }
415 427
416 LoadState SSLClientSocketPool::GetLoadState( 428 LoadState SSLClientSocketPool::GetLoadState(
417 const std::string& group_name, const ClientSocketHandle* handle) const { 429 const std::string& group_name, const ClientSocketHandle* handle) const {
418 return base_.GetLoadState(group_name, handle); 430 return base_.GetLoadState(group_name, handle);
419 } 431 }
420 432
421 } // namespace net 433 } // 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