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

Side by Side Diff: net/http/http_proxy_client_socket_pool.cc

Issue 2899313006: Plumb NQP to context and to http_proxy_client_socket_pool (Closed)
Patch Set: ps Created 3 years, 6 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/http/http_proxy_client_socket_pool.h" 5 #include "net/http/http_proxy_client_socket_pool.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 14 matching lines...) Expand all
25 #include "net/socket/transport_client_socket_pool.h" 25 #include "net/socket/transport_client_socket_pool.h"
26 #include "net/spdy/chromium/spdy_proxy_client_socket.h" 26 #include "net/spdy/chromium/spdy_proxy_client_socket.h"
27 #include "net/spdy/chromium/spdy_session.h" 27 #include "net/spdy/chromium/spdy_session.h"
28 #include "net/spdy/chromium/spdy_session_pool.h" 28 #include "net/spdy/chromium/spdy_session_pool.h"
29 #include "net/spdy/chromium/spdy_stream.h" 29 #include "net/spdy/chromium/spdy_stream.h"
30 #include "net/ssl/ssl_cert_request_info.h" 30 #include "net/ssl/ssl_cert_request_info.h"
31 #include "url/gurl.h" 31 #include "url/gurl.h"
32 32
33 namespace net { 33 namespace net {
34 34
35 namespace {
36
37 // Configure using net session params.
38 base::TimeDelta GetConnectionTimeout(
39 NetworkQualityEstimator* network_quality_estimator,
40 base::TimeDelta default_connection_timeout) {
41 // TODO(tbansal): https://crbug.com/704339. Use NQE and field trial to
42 // determine the connection timeout.
43 return default_connection_timeout;
44 }
45
46 base::TimeDelta GetMaxPoolTimeout(TransportClientSocketPool* transport_pool,
47 SSLClientSocketPool* ssl_pool) {
48 base::TimeDelta max_pool_timeout = base::TimeDelta();
49
50 #if (defined(OS_ANDROID) || defined(OS_IOS))
51 return max_pool_timeout;
52 #endif
53
54 if (transport_pool)
55 max_pool_timeout = transport_pool->ConnectionTimeout();
56 if (ssl_pool) {
57 max_pool_timeout =
58 std::max(max_pool_timeout, ssl_pool->ConnectionTimeout());
59 }
60 return max_pool_timeout;
61 }
62
63 } // namespace
64
35 HttpProxySocketParams::HttpProxySocketParams( 65 HttpProxySocketParams::HttpProxySocketParams(
36 const scoped_refptr<TransportSocketParams>& transport_params, 66 const scoped_refptr<TransportSocketParams>& transport_params,
37 const scoped_refptr<SSLSocketParams>& ssl_params, 67 const scoped_refptr<SSLSocketParams>& ssl_params,
38 const std::string& user_agent, 68 const std::string& user_agent,
39 const HostPortPair& endpoint, 69 const HostPortPair& endpoint,
40 HttpAuthCache* http_auth_cache, 70 HttpAuthCache* http_auth_cache,
41 HttpAuthHandlerFactory* http_auth_handler_factory, 71 HttpAuthHandlerFactory* http_auth_handler_factory,
42 SpdySessionPool* spdy_session_pool, 72 SpdySessionPool* spdy_session_pool,
43 bool tunnel, 73 bool tunnel,
44 ProxyDelegate* proxy_delegate) 74 ProxyDelegate* proxy_delegate)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) 172 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED)
143 error_response_info_ = client_socket_->GetAdditionalErrorState(); 173 error_response_info_ = client_socket_->GetAdditionalErrorState();
144 174
145 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED || 175 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED ||
146 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { 176 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) {
147 SetSocket(std::move(client_socket_)); 177 SetSocket(std::move(client_socket_));
148 } 178 }
149 return result; 179 return result;
150 } 180 }
151 181
152 HttpProxyClientSocketPool:: 182 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::
153 HttpProxyConnectJobFactory::HttpProxyConnectJobFactory( 183 HttpProxyConnectJobFactory(
154 TransportClientSocketPool* transport_pool, 184 TransportClientSocketPool* transport_pool,
155 SSLClientSocketPool* ssl_pool, 185 SSLClientSocketPool* ssl_pool,
156 NetLog* net_log) 186 NetworkQualityEstimator* network_quality_estimator,
187 NetLog* net_log)
157 : transport_pool_(transport_pool), 188 : transport_pool_(transport_pool),
158 ssl_pool_(ssl_pool), 189 ssl_pool_(ssl_pool),
159 net_log_(net_log) { 190 network_quality_estimator_(network_quality_estimator),
160 base::TimeDelta max_pool_timeout = base::TimeDelta(); 191 default_connection_timeout_(
161 192 GetMaxPoolTimeout(transport_pool, ssl_pool) +
162 // TODO(kundaji): Proxy connect timeout should be independent of platform and be 193 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds)),
163 // based on proxy. Bug http://crbug.com/407446. 194 net_log_(net_log) {}
164 #if (defined(OS_ANDROID) || defined(OS_IOS))
165 #else
166 if (transport_pool_)
167 max_pool_timeout = transport_pool_->ConnectionTimeout();
168 if (ssl_pool_)
169 max_pool_timeout = std::max(max_pool_timeout,
170 ssl_pool_->ConnectionTimeout());
171 #endif
172 timeout_ = max_pool_timeout +
173 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds);
174 }
175 195
176 std::unique_ptr<ConnectJob> 196 std::unique_ptr<ConnectJob>
177 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob( 197 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob(
178 const std::string& group_name, 198 const std::string& group_name,
179 const PoolBase::Request& request, 199 const PoolBase::Request& request,
180 ConnectJob::Delegate* delegate) const { 200 ConnectJob::Delegate* delegate) const {
181 return std::unique_ptr<ConnectJob>(new HttpProxyConnectJob( 201 return std::unique_ptr<ConnectJob>(new HttpProxyConnectJob(
182 group_name, request.priority(), request.respect_limits(), 202 group_name, request.priority(), request.respect_limits(),
183 request.params(), ConnectionTimeout(), transport_pool_, ssl_pool_, 203 request.params(), ConnectionTimeout(), transport_pool_, ssl_pool_,
184 delegate, net_log_)); 204 delegate, net_log_));
185 } 205 }
186 206
187 base::TimeDelta 207 base::TimeDelta
188 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout( 208 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout(
189 ) const { 209 ) const {
190 return timeout_; 210 return GetConnectionTimeout(network_quality_estimator_,
211 default_connection_timeout_);
191 } 212 }
192 213
193 HttpProxyClientSocketPool::HttpProxyClientSocketPool( 214 HttpProxyClientSocketPool::HttpProxyClientSocketPool(
194 int max_sockets, 215 int max_sockets,
195 int max_sockets_per_group, 216 int max_sockets_per_group,
196 TransportClientSocketPool* transport_pool, 217 TransportClientSocketPool* transport_pool,
197 SSLClientSocketPool* ssl_pool, 218 SSLClientSocketPool* ssl_pool,
219 NetworkQualityEstimator* network_quality_estimator,
198 NetLog* net_log) 220 NetLog* net_log)
199 : transport_pool_(transport_pool), 221 : transport_pool_(transport_pool),
200 ssl_pool_(ssl_pool), 222 ssl_pool_(ssl_pool),
201 base_(this, 223 base_(this,
202 max_sockets, 224 max_sockets,
203 max_sockets_per_group, 225 max_sockets_per_group,
204 ClientSocketPool::unused_idle_socket_timeout(), 226 ClientSocketPool::unused_idle_socket_timeout(),
205 ClientSocketPool::used_idle_socket_timeout(), 227 ClientSocketPool::used_idle_socket_timeout(),
206 new HttpProxyConnectJobFactory(transport_pool, ssl_pool, net_log)) { 228 new HttpProxyConnectJobFactory(transport_pool,
229 ssl_pool,
230 network_quality_estimator,
231 net_log)) {
207 // We should always have a |transport_pool_| except in unit tests. 232 // We should always have a |transport_pool_| except in unit tests.
208 if (transport_pool_) 233 if (transport_pool_)
209 base_.AddLowerLayeredPool(transport_pool_); 234 base_.AddLowerLayeredPool(transport_pool_);
210 if (ssl_pool_) 235 if (ssl_pool_)
211 base_.AddLowerLayeredPool(ssl_pool_); 236 base_.AddLowerLayeredPool(ssl_pool_);
212 } 237 }
213 238
214 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { 239 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() {
215 } 240 }
216 241
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 base_.RemoveHigherLayeredPool(higher_pool); 350 base_.RemoveHigherLayeredPool(higher_pool);
326 } 351 }
327 352
328 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { 353 bool HttpProxyClientSocketPool::CloseOneIdleConnection() {
329 if (base_.CloseOneIdleSocket()) 354 if (base_.CloseOneIdleSocket())
330 return true; 355 return true;
331 return base_.CloseOneIdleConnectionInHigherLayeredPool(); 356 return base_.CloseOneIdleConnectionInHigherLayeredPool();
332 } 357 }
333 358
334 } // namespace net 359 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698