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

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: Rebased 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(
mmenke 2017/06/07 21:31:25 Why do we have two methods?
tbansal1 2017/06/08 05:01:50 Done.
39 NetworkQualityProvider* network_quality_provider,
40 base::TimeDelta default_connection_timeout) {
41 // TODO(tbansal): https://crbug.com/704339. Use NQE and field trial to
42 // determine the connection timeout.
mmenke 2017/06/07 21:31:26 Should this logic be in the socket pools in in net
tbansal1 2017/06/08 05:01:50 The timeout is now dynamic i.e., it can change wit
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
mmenke 2017/06/07 21:31:26 #else seems a bit more natural here (And I don't t
tbansal1 2017/06/08 05:01:50 Modified this. Hopefully the new one is better.
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(TransportClientSocketPool* transport_pool,
154 TransportClientSocketPool* transport_pool, 184 SSLClientSocketPool* ssl_pool,
155 SSLClientSocketPool* ssl_pool, 185 NetworkQualityProvider* network_quality_provider,
156 NetLog* net_log) 186 NetLog* net_log)
157 : transport_pool_(transport_pool), 187 : transport_pool_(transport_pool),
158 ssl_pool_(ssl_pool), 188 ssl_pool_(ssl_pool),
159 net_log_(net_log) { 189 network_quality_provider_(network_quality_provider),
160 base::TimeDelta max_pool_timeout = base::TimeDelta(); 190 default_connection_timeout_(
161 191 GetMaxPoolTimeout(transport_pool, ssl_pool) +
162 // TODO(kundaji): Proxy connect timeout should be independent of platform and be 192 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds)),
163 // based on proxy. Bug http://crbug.com/407446. 193 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 194
176 std::unique_ptr<ConnectJob> 195 std::unique_ptr<ConnectJob>
177 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob( 196 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob(
178 const std::string& group_name, 197 const std::string& group_name,
179 const PoolBase::Request& request, 198 const PoolBase::Request& request,
180 ConnectJob::Delegate* delegate) const { 199 ConnectJob::Delegate* delegate) const {
181 return std::unique_ptr<ConnectJob>(new HttpProxyConnectJob( 200 return std::unique_ptr<ConnectJob>(new HttpProxyConnectJob(
182 group_name, request.priority(), request.respect_limits(), 201 group_name, request.priority(), request.respect_limits(),
183 request.params(), ConnectionTimeout(), transport_pool_, ssl_pool_, 202 request.params(), ConnectionTimeout(), transport_pool_, ssl_pool_,
184 delegate, net_log_)); 203 delegate, net_log_));
185 } 204 }
186 205
187 base::TimeDelta 206 base::TimeDelta
188 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout( 207 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout(
189 ) const { 208 ) const {
190 return timeout_; 209 return GetConnectionTimeout(network_quality_provider_,
210 default_connection_timeout_);
191 } 211 }
192 212
193 HttpProxyClientSocketPool::HttpProxyClientSocketPool( 213 HttpProxyClientSocketPool::HttpProxyClientSocketPool(
194 int max_sockets, 214 int max_sockets,
195 int max_sockets_per_group, 215 int max_sockets_per_group,
196 TransportClientSocketPool* transport_pool, 216 TransportClientSocketPool* transport_pool,
197 SSLClientSocketPool* ssl_pool, 217 SSLClientSocketPool* ssl_pool,
218 NetworkQualityProvider* network_quality_provider,
198 NetLog* net_log) 219 NetLog* net_log)
199 : transport_pool_(transport_pool), 220 : transport_pool_(transport_pool),
200 ssl_pool_(ssl_pool), 221 ssl_pool_(ssl_pool),
201 base_(this, 222 base_(this,
202 max_sockets, 223 max_sockets,
203 max_sockets_per_group, 224 max_sockets_per_group,
204 ClientSocketPool::unused_idle_socket_timeout(), 225 ClientSocketPool::unused_idle_socket_timeout(),
205 ClientSocketPool::used_idle_socket_timeout(), 226 ClientSocketPool::used_idle_socket_timeout(),
206 new HttpProxyConnectJobFactory(transport_pool, ssl_pool, net_log)) { 227 new HttpProxyConnectJobFactory(transport_pool,
228 ssl_pool,
229 network_quality_provider,
230 net_log)) {
207 // We should always have a |transport_pool_| except in unit tests. 231 // We should always have a |transport_pool_| except in unit tests.
208 if (transport_pool_) 232 if (transport_pool_)
209 base_.AddLowerLayeredPool(transport_pool_); 233 base_.AddLowerLayeredPool(transport_pool_);
210 if (ssl_pool_) 234 if (ssl_pool_)
211 base_.AddLowerLayeredPool(ssl_pool_); 235 base_.AddLowerLayeredPool(ssl_pool_);
212 } 236 }
213 237
214 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { 238 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() {
215 } 239 }
216 240
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 base_.RemoveHigherLayeredPool(higher_pool); 349 base_.RemoveHigherLayeredPool(higher_pool);
326 } 350 }
327 351
328 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { 352 bool HttpProxyClientSocketPool::CloseOneIdleConnection() {
329 if (base_.CloseOneIdleSocket()) 353 if (base_.CloseOneIdleSocket())
330 return true; 354 return true;
331 return base_.CloseOneIdleConnectionInHigherLayeredPool(); 355 return base_.CloseOneIdleConnectionInHigherLayeredPool();
332 } 356 }
333 357
334 } // namespace net 358 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698