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

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: fix compile error 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 // HttpProxyConnectJobs will time out after this many seconds. Note this is on
38 // top of the timeout for the transport socket.
39 // TODO(kundaji): Proxy connect timeout should be independent of platform and be
40 // based on proxy. Bug http://crbug.com/407446.
41 #if defined(OS_ANDROID) || defined(OS_IOS)
42 static const int kHttpProxyConnectJobTimeoutInSeconds = 10;
43 #else
44 static const int kHttpProxyConnectJobTimeoutInSeconds = 30;
45 #endif
46
47 } // namespace
48
35 HttpProxySocketParams::HttpProxySocketParams( 49 HttpProxySocketParams::HttpProxySocketParams(
36 const scoped_refptr<TransportSocketParams>& transport_params, 50 const scoped_refptr<TransportSocketParams>& transport_params,
37 const scoped_refptr<SSLSocketParams>& ssl_params, 51 const scoped_refptr<SSLSocketParams>& ssl_params,
38 const std::string& user_agent, 52 const std::string& user_agent,
39 const HostPortPair& endpoint, 53 const HostPortPair& endpoint,
40 HttpAuthCache* http_auth_cache, 54 HttpAuthCache* http_auth_cache,
41 HttpAuthHandlerFactory* http_auth_handler_factory, 55 HttpAuthHandlerFactory* http_auth_handler_factory,
42 SpdySessionPool* spdy_session_pool, 56 SpdySessionPool* spdy_session_pool,
43 bool tunnel, 57 bool tunnel,
44 ProxyDelegate* proxy_delegate) 58 ProxyDelegate* proxy_delegate)
(...skipping 13 matching lines...) Expand all
58 const HostResolver::RequestInfo& HttpProxySocketParams::destination() const { 72 const HostResolver::RequestInfo& HttpProxySocketParams::destination() const {
59 if (transport_params_.get() == NULL) { 73 if (transport_params_.get() == NULL) {
60 return ssl_params_->GetDirectConnectionParams()->destination(); 74 return ssl_params_->GetDirectConnectionParams()->destination();
61 } else { 75 } else {
62 return transport_params_->destination(); 76 return transport_params_->destination();
63 } 77 }
64 } 78 }
65 79
66 HttpProxySocketParams::~HttpProxySocketParams() {} 80 HttpProxySocketParams::~HttpProxySocketParams() {}
67 81
68 // HttpProxyConnectJobs will time out after this many seconds. Note this is on
69 // top of the timeout for the transport socket.
70 // TODO(kundaji): Proxy connect timeout should be independent of platform and be
71 // based on proxy. Bug http://crbug.com/407446.
72 #if defined(OS_ANDROID) || defined(OS_IOS)
73 static const int kHttpProxyConnectJobTimeoutInSeconds = 10;
74 #else
75 static const int kHttpProxyConnectJobTimeoutInSeconds = 30;
76 #endif
77
78 HttpProxyConnectJob::HttpProxyConnectJob( 82 HttpProxyConnectJob::HttpProxyConnectJob(
79 const std::string& group_name, 83 const std::string& group_name,
80 RequestPriority priority, 84 RequestPriority priority,
81 ClientSocketPool::RespectLimits respect_limits, 85 ClientSocketPool::RespectLimits respect_limits,
82 const scoped_refptr<HttpProxySocketParams>& params, 86 const scoped_refptr<HttpProxySocketParams>& params,
83 const base::TimeDelta& timeout_duration, 87 const base::TimeDelta& timeout_duration,
84 TransportClientSocketPool* transport_pool, 88 TransportClientSocketPool* transport_pool,
85 SSLClientSocketPool* ssl_pool, 89 SSLClientSocketPool* ssl_pool,
86 Delegate* delegate, 90 Delegate* delegate,
87 NetLog* net_log) 91 NetLog* net_log)
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED) 146 if (result == ERR_SSL_CLIENT_AUTH_CERT_NEEDED)
143 error_response_info_ = client_socket_->GetAdditionalErrorState(); 147 error_response_info_ = client_socket_->GetAdditionalErrorState();
144 148
145 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED || 149 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED ||
146 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { 150 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) {
147 SetSocket(std::move(client_socket_)); 151 SetSocket(std::move(client_socket_));
148 } 152 }
149 return result; 153 return result;
150 } 154 }
151 155
152 HttpProxyClientSocketPool:: 156 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::
153 HttpProxyConnectJobFactory::HttpProxyConnectJobFactory( 157 HttpProxyConnectJobFactory(TransportClientSocketPool* transport_pool,
154 TransportClientSocketPool* transport_pool, 158 SSLClientSocketPool* ssl_pool,
155 SSLClientSocketPool* ssl_pool, 159 NetworkQualityProvider* network_quality_provider,
156 NetLog* net_log) 160 NetLog* net_log)
157 : transport_pool_(transport_pool), 161 : transport_pool_(transport_pool),
158 ssl_pool_(ssl_pool), 162 ssl_pool_(ssl_pool),
159 net_log_(net_log) { 163 network_quality_provider_(network_quality_provider),
160 base::TimeDelta max_pool_timeout = base::TimeDelta(); 164 net_log_(net_log) {}
161
162 // TODO(kundaji): Proxy connect timeout should be independent of platform and be
163 // based on proxy. Bug http://crbug.com/407446.
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 165
176 std::unique_ptr<ConnectJob> 166 std::unique_ptr<ConnectJob>
177 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob( 167 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob(
178 const std::string& group_name, 168 const std::string& group_name,
179 const PoolBase::Request& request, 169 const PoolBase::Request& request,
180 ConnectJob::Delegate* delegate) const { 170 ConnectJob::Delegate* delegate) const {
181 return std::unique_ptr<ConnectJob>(new HttpProxyConnectJob( 171 return std::unique_ptr<ConnectJob>(new HttpProxyConnectJob(
182 group_name, request.priority(), request.respect_limits(), 172 group_name, request.priority(), request.respect_limits(),
183 request.params(), ConnectionTimeout(), transport_pool_, ssl_pool_, 173 request.params(), ConnectionTimeout(), transport_pool_, ssl_pool_,
184 delegate, net_log_)); 174 delegate, net_log_));
185 } 175 }
186 176
187 base::TimeDelta 177 base::TimeDelta
188 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout( 178 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout(
189 ) const { 179 ) const {
190 return timeout_; 180 // TODO(tbansal): https://crbug.com/704339. Use |network_quality_provider_|
181 // and field trial to determine the connection timeout.
182 ALLOW_UNUSED_LOCAL(network_quality_provider_);
183
184 // Return the default proxy connection timeout.
185 base::TimeDelta max_pool_timeout = base::TimeDelta();
186 #if (!defined(OS_ANDROID) && !defined(OS_IOS))
187 if (transport_pool_)
188 max_pool_timeout = transport_pool_->ConnectionTimeout();
189 if (ssl_pool_) {
190 max_pool_timeout =
191 std::max(max_pool_timeout, ssl_pool_->ConnectionTimeout());
192 }
193 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
194
195 return max_pool_timeout +
196 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds);
191 } 197 }
192 198
193 HttpProxyClientSocketPool::HttpProxyClientSocketPool( 199 HttpProxyClientSocketPool::HttpProxyClientSocketPool(
194 int max_sockets, 200 int max_sockets,
195 int max_sockets_per_group, 201 int max_sockets_per_group,
196 TransportClientSocketPool* transport_pool, 202 TransportClientSocketPool* transport_pool,
197 SSLClientSocketPool* ssl_pool, 203 SSLClientSocketPool* ssl_pool,
204 NetworkQualityProvider* network_quality_provider,
198 NetLog* net_log) 205 NetLog* net_log)
199 : transport_pool_(transport_pool), 206 : transport_pool_(transport_pool),
200 ssl_pool_(ssl_pool), 207 ssl_pool_(ssl_pool),
201 base_(this, 208 base_(this,
202 max_sockets, 209 max_sockets,
203 max_sockets_per_group, 210 max_sockets_per_group,
204 ClientSocketPool::unused_idle_socket_timeout(), 211 ClientSocketPool::unused_idle_socket_timeout(),
205 ClientSocketPool::used_idle_socket_timeout(), 212 ClientSocketPool::used_idle_socket_timeout(),
206 new HttpProxyConnectJobFactory(transport_pool, ssl_pool, net_log)) { 213 new HttpProxyConnectJobFactory(transport_pool,
214 ssl_pool,
215 network_quality_provider,
216 net_log)) {
207 // We should always have a |transport_pool_| except in unit tests. 217 // We should always have a |transport_pool_| except in unit tests.
208 if (transport_pool_) 218 if (transport_pool_)
209 base_.AddLowerLayeredPool(transport_pool_); 219 base_.AddLowerLayeredPool(transport_pool_);
210 if (ssl_pool_) 220 if (ssl_pool_)
211 base_.AddLowerLayeredPool(ssl_pool_); 221 base_.AddLowerLayeredPool(ssl_pool_);
212 } 222 }
213 223
214 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { 224 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() {
215 } 225 }
216 226
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 base_.RemoveHigherLayeredPool(higher_pool); 335 base_.RemoveHigherLayeredPool(higher_pool);
326 } 336 }
327 337
328 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { 338 bool HttpProxyClientSocketPool::CloseOneIdleConnection() {
329 if (base_.CloseOneIdleSocket()) 339 if (base_.CloseOneIdleSocket())
330 return true; 340 return true;
331 return base_.CloseOneIdleConnectionInHigherLayeredPool(); 341 return base_.CloseOneIdleConnectionInHigherLayeredPool();
332 } 342 }
333 343
334 } // namespace net 344 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket_pool.h ('k') | net/http/http_proxy_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698