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

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

Issue 1580903002: Convert ignore_limits from a SocketParam to a socket request argument. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: RespectLimits Created 4 years, 11 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 ssl_params_(ssl_params), 44 ssl_params_(ssl_params),
45 spdy_session_pool_(spdy_session_pool), 45 spdy_session_pool_(spdy_session_pool),
46 user_agent_(user_agent), 46 user_agent_(user_agent),
47 endpoint_(endpoint), 47 endpoint_(endpoint),
48 http_auth_cache_(tunnel ? http_auth_cache : NULL), 48 http_auth_cache_(tunnel ? http_auth_cache : NULL),
49 http_auth_handler_factory_(tunnel ? http_auth_handler_factory : NULL), 49 http_auth_handler_factory_(tunnel ? http_auth_handler_factory : NULL),
50 tunnel_(tunnel), 50 tunnel_(tunnel),
51 proxy_delegate_(proxy_delegate) { 51 proxy_delegate_(proxy_delegate) {
52 DCHECK((transport_params.get() == NULL && ssl_params.get() != NULL) || 52 DCHECK((transport_params.get() == NULL && ssl_params.get() != NULL) ||
53 (transport_params.get() != NULL && ssl_params.get() == NULL)); 53 (transport_params.get() != NULL && ssl_params.get() == NULL));
54 if (transport_params_.get()) {
55 ignore_limits_ = transport_params->ignore_limits();
56 } else {
57 ignore_limits_ = ssl_params->ignore_limits();
58 }
59 } 54 }
60 55
61 const HostResolver::RequestInfo& HttpProxySocketParams::destination() const { 56 const HostResolver::RequestInfo& HttpProxySocketParams::destination() const {
62 if (transport_params_.get() == NULL) { 57 if (transport_params_.get() == NULL) {
63 return ssl_params_->GetDirectConnectionParams()->destination(); 58 return ssl_params_->GetDirectConnectionParams()->destination();
64 } else { 59 } else {
65 return transport_params_->destination(); 60 return transport_params_->destination();
66 } 61 }
67 } 62 }
68 63
69 HttpProxySocketParams::~HttpProxySocketParams() {} 64 HttpProxySocketParams::~HttpProxySocketParams() {}
70 65
71 // HttpProxyConnectJobs will time out after this many seconds. Note this is on 66 // HttpProxyConnectJobs will time out after this many seconds. Note this is on
72 // top of the timeout for the transport socket. 67 // top of the timeout for the transport socket.
73 // TODO(kundaji): Proxy connect timeout should be independent of platform and be 68 // TODO(kundaji): Proxy connect timeout should be independent of platform and be
74 // based on proxy. Bug http://crbug.com/407446. 69 // based on proxy. Bug http://crbug.com/407446.
75 #if defined(OS_ANDROID) || defined(OS_IOS) 70 #if defined(OS_ANDROID) || defined(OS_IOS)
76 static const int kHttpProxyConnectJobTimeoutInSeconds = 10; 71 static const int kHttpProxyConnectJobTimeoutInSeconds = 10;
77 #else 72 #else
78 static const int kHttpProxyConnectJobTimeoutInSeconds = 30; 73 static const int kHttpProxyConnectJobTimeoutInSeconds = 30;
79 #endif 74 #endif
80 75
81 HttpProxyConnectJob::HttpProxyConnectJob( 76 HttpProxyConnectJob::HttpProxyConnectJob(
82 const std::string& group_name, 77 const std::string& group_name,
83 RequestPriority priority, 78 RequestPriority priority,
79 ClientSocketPool::RespectLimits respect_limits,
84 const scoped_refptr<HttpProxySocketParams>& params, 80 const scoped_refptr<HttpProxySocketParams>& params,
85 const base::TimeDelta& timeout_duration, 81 const base::TimeDelta& timeout_duration,
86 TransportClientSocketPool* transport_pool, 82 TransportClientSocketPool* transport_pool,
87 SSLClientSocketPool* ssl_pool, 83 SSLClientSocketPool* ssl_pool,
88 Delegate* delegate, 84 Delegate* delegate,
89 NetLog* net_log) 85 NetLog* net_log)
90 : ConnectJob(group_name, 86 : ConnectJob(group_name,
91 base::TimeDelta() /* The socket takes care of timeouts */, 87 base::TimeDelta() /* The socket takes care of timeouts */,
92 priority, 88 priority,
89 respect_limits,
93 delegate, 90 delegate,
94 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), 91 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)),
95 client_socket_(new HttpProxyClientSocketWrapper( 92 client_socket_(new HttpProxyClientSocketWrapper(
96 group_name, 93 group_name,
97 priority, 94 priority,
95 respect_limits,
98 timeout_duration, 96 timeout_duration,
99 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds), 97 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds),
100 transport_pool, 98 transport_pool,
101 ssl_pool, 99 ssl_pool,
102 params->transport_params(), 100 params->transport_params(),
103 params->ssl_params(), 101 params->ssl_params(),
104 params->user_agent(), 102 params->user_agent(),
105 params->endpoint(), 103 params->endpoint(),
106 params->http_auth_cache(), 104 params->http_auth_cache(),
107 params->http_auth_handler_factory(), 105 params->http_auth_handler_factory(),
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 timeout_ = max_pool_timeout + 168 timeout_ = max_pool_timeout +
171 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds); 169 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds);
172 } 170 }
173 171
174 172
175 scoped_ptr<ConnectJob> 173 scoped_ptr<ConnectJob>
176 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob( 174 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob(
177 const std::string& group_name, 175 const std::string& group_name,
178 const PoolBase::Request& request, 176 const PoolBase::Request& request,
179 ConnectJob::Delegate* delegate) const { 177 ConnectJob::Delegate* delegate) const {
180 return scoped_ptr<ConnectJob>(new HttpProxyConnectJob(group_name, 178 return scoped_ptr<ConnectJob>(new HttpProxyConnectJob(
181 request.priority(), 179 group_name, request.priority(), request.respect_limits(),
182 request.params(), 180 request.params(), ConnectionTimeout(), transport_pool_, ssl_pool_,
183 ConnectionTimeout(), 181 delegate, net_log_));
184 transport_pool_,
185 ssl_pool_,
186 delegate,
187 net_log_));
188 } 182 }
189 183
190 base::TimeDelta 184 base::TimeDelta
191 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout( 185 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout(
192 ) const { 186 ) const {
193 return timeout_; 187 return timeout_;
194 } 188 }
195 189
196 HttpProxyClientSocketPool::HttpProxyClientSocketPool( 190 HttpProxyClientSocketPool::HttpProxyClientSocketPool(
197 int max_sockets, 191 int max_sockets,
(...skipping 12 matching lines...) Expand all
210 // We should always have a |transport_pool_| except in unit tests. 204 // We should always have a |transport_pool_| except in unit tests.
211 if (transport_pool_) 205 if (transport_pool_)
212 base_.AddLowerLayeredPool(transport_pool_); 206 base_.AddLowerLayeredPool(transport_pool_);
213 if (ssl_pool_) 207 if (ssl_pool_)
214 base_.AddLowerLayeredPool(ssl_pool_); 208 base_.AddLowerLayeredPool(ssl_pool_);
215 } 209 }
216 210
217 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { 211 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() {
218 } 212 }
219 213
220 int HttpProxyClientSocketPool::RequestSocket( 214 int HttpProxyClientSocketPool::RequestSocket(const std::string& group_name,
221 const std::string& group_name, const void* socket_params, 215 const void* socket_params,
222 RequestPriority priority, ClientSocketHandle* handle, 216 RequestPriority priority,
223 const CompletionCallback& callback, const BoundNetLog& net_log) { 217 RespectLimits respect_limits,
218 ClientSocketHandle* handle,
219 const CompletionCallback& callback,
220 const BoundNetLog& net_log) {
224 const scoped_refptr<HttpProxySocketParams>* casted_socket_params = 221 const scoped_refptr<HttpProxySocketParams>* casted_socket_params =
225 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params); 222 static_cast<const scoped_refptr<HttpProxySocketParams>*>(socket_params);
226 223
227 return base_.RequestSocket(group_name, *casted_socket_params, priority, 224 return base_.RequestSocket(group_name, *casted_socket_params, priority,
228 handle, callback, net_log); 225 respect_limits, handle, callback, net_log);
229 } 226 }
230 227
231 void HttpProxyClientSocketPool::RequestSockets( 228 void HttpProxyClientSocketPool::RequestSockets(
232 const std::string& group_name, 229 const std::string& group_name,
233 const void* params, 230 const void* params,
234 int num_sockets, 231 int num_sockets,
235 const BoundNetLog& net_log) { 232 const BoundNetLog& net_log) {
236 const scoped_refptr<HttpProxySocketParams>* casted_params = 233 const scoped_refptr<HttpProxySocketParams>* casted_params =
237 static_cast<const scoped_refptr<HttpProxySocketParams>*>(params); 234 static_cast<const scoped_refptr<HttpProxySocketParams>*>(params);
238 235
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 base_.RemoveHigherLayeredPool(higher_pool); 310 base_.RemoveHigherLayeredPool(higher_pool);
314 } 311 }
315 312
316 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { 313 bool HttpProxyClientSocketPool::CloseOneIdleConnection() {
317 if (base_.CloseOneIdleSocket()) 314 if (base_.CloseOneIdleSocket())
318 return true; 315 return true;
319 return base_.CloseOneIdleConnectionInHigherLayeredPool(); 316 return base_.CloseOneIdleConnectionInHigherLayeredPool();
320 } 317 }
321 318
322 } // namespace net 319 } // 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