| OLD | NEW |
| 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/http/http_proxy_client_socket_pool.h" | 5 #include "net/http/http_proxy_client_socket_pool.h" |
| 6 | 6 |
| 7 #include "base/time.h" | 7 #include "base/time.h" |
| 8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 9 #include "net/base/net_errors.h" | 9 #include "net/base/net_errors.h" |
| 10 #include "net/http/http_network_session.h" | |
| 11 #include "net/http/http_proxy_client_socket.h" | 10 #include "net/http/http_proxy_client_socket.h" |
| 12 #include "net/socket/client_socket_factory.h" | 11 #include "net/socket/client_socket_factory.h" |
| 13 #include "net/socket/client_socket_handle.h" | 12 #include "net/socket/client_socket_handle.h" |
| 14 #include "net/socket/client_socket_pool_base.h" | 13 #include "net/socket/client_socket_pool_base.h" |
| 15 | 14 |
| 16 namespace net { | 15 namespace net { |
| 17 | 16 |
| 18 HttpProxySocketParams::HttpProxySocketParams( | 17 HttpProxySocketParams::HttpProxySocketParams( |
| 19 const scoped_refptr<TCPSocketParams>& proxy_server, | 18 const scoped_refptr<TCPSocketParams>& proxy_server, |
| 20 const GURL& request_url, | 19 const GURL& request_url, |
| 21 HostPortPair endpoint, | 20 HostPortPair endpoint, |
| 22 scoped_refptr<HttpNetworkSession> session, | 21 scoped_refptr<HttpAuthController> auth_controller, |
| 23 bool tunnel) | 22 bool tunnel) |
| 24 : tcp_params_(proxy_server), | 23 : tcp_params_(proxy_server), |
| 25 request_url_(request_url), | 24 request_url_(request_url), |
| 26 endpoint_(endpoint), | 25 endpoint_(endpoint), |
| 27 session_(session), | 26 auth_controller_(auth_controller), |
| 28 tunnel_(tunnel) { | 27 tunnel_(tunnel) { |
| 29 } | 28 } |
| 30 | 29 |
| 31 HttpProxySocketParams::~HttpProxySocketParams() {} | 30 HttpProxySocketParams::~HttpProxySocketParams() {} |
| 32 | 31 |
| 33 // HttpProxyConnectJobs will time out after this many seconds. Note this is on | 32 // HttpProxyConnectJobs will time out after this many seconds. Note this is on |
| 34 // top of the timeout for the transport socket. | 33 // top of the timeout for the transport socket. |
| 35 static const int kHttpProxyConnectJobTimeoutInSeconds = 30; | 34 static const int kHttpProxyConnectJobTimeoutInSeconds = 30; |
| 36 | 35 |
| 37 HttpProxyConnectJob::HttpProxyConnectJob( | 36 HttpProxyConnectJob::HttpProxyConnectJob( |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // so that a fast TCP connection plus a slow HttpProxy failure doesn't take | 126 // so that a fast TCP connection plus a slow HttpProxy failure doesn't take |
| 128 // longer to timeout than it should. | 127 // longer to timeout than it should. |
| 129 ResetTimer(base::TimeDelta::FromSeconds( | 128 ResetTimer(base::TimeDelta::FromSeconds( |
| 130 kHttpProxyConnectJobTimeoutInSeconds)); | 129 kHttpProxyConnectJobTimeoutInSeconds)); |
| 131 next_state_ = kStateHttpProxyConnect; | 130 next_state_ = kStateHttpProxyConnect; |
| 132 return result; | 131 return result; |
| 133 } | 132 } |
| 134 | 133 |
| 135 int HttpProxyConnectJob::DoHttpProxyConnect() { | 134 int HttpProxyConnectJob::DoHttpProxyConnect() { |
| 136 next_state_ = kStateHttpProxyConnectComplete; | 135 next_state_ = kStateHttpProxyConnectComplete; |
| 137 const HostResolver::RequestInfo& tcp_destination = | |
| 138 params_->tcp_params()->destination(); | |
| 139 HostPortPair proxy_server(tcp_destination.hostname(), | |
| 140 tcp_destination.port()); | |
| 141 | 136 |
| 142 // Add a HttpProxy connection on top of the tcp socket. | 137 // Add a HttpProxy connection on top of the tcp socket. |
| 143 socket_.reset(new HttpProxyClientSocket(tcp_socket_handle_.release(), | 138 socket_.reset(new HttpProxyClientSocket(tcp_socket_handle_.release(), |
| 144 params_->request_url(), | 139 params_->request_url(), |
| 145 params_->endpoint(), | 140 params_->endpoint(), |
| 146 proxy_server, | 141 params_->auth_controller(), |
| 147 params_->session(), | |
| 148 params_->tunnel())); | 142 params_->tunnel())); |
| 149 return socket_->Connect(&callback_); | 143 return socket_->Connect(&callback_); |
| 150 } | 144 } |
| 151 | 145 |
| 152 int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) { | 146 int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) { |
| 147 DCHECK_NE(result, ERR_RETRY_CONNECTION); |
| 148 |
| 153 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED) | 149 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED) |
| 154 set_socket(socket_.release()); | 150 set_socket(socket_.release()); |
| 155 | 151 |
| 156 return result; | 152 return result; |
| 157 } | 153 } |
| 158 | 154 |
| 159 ConnectJob* | 155 ConnectJob* |
| 160 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob( | 156 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob( |
| 161 const std::string& group_name, | 157 const std::string& group_name, |
| 162 const PoolBase::Request& request, | 158 const PoolBase::Request& request, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 const std::string& group_name) const { | 220 const std::string& group_name) const { |
| 225 return base_.IdleSocketCountInGroup(group_name); | 221 return base_.IdleSocketCountInGroup(group_name); |
| 226 } | 222 } |
| 227 | 223 |
| 228 LoadState HttpProxyClientSocketPool::GetLoadState( | 224 LoadState HttpProxyClientSocketPool::GetLoadState( |
| 229 const std::string& group_name, const ClientSocketHandle* handle) const { | 225 const std::string& group_name, const ClientSocketHandle* handle) const { |
| 230 return base_.GetLoadState(group_name, handle); | 226 return base_.GetLoadState(group_name, handle); |
| 231 } | 227 } |
| 232 | 228 |
| 233 } // namespace net | 229 } // namespace net |
| OLD | NEW |