OLD | NEW |
---|---|
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/socket/client_socket_pool_manager.h" | 5 #include "net/socket/client_socket_pool_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 // http://crbug.com/44501 for details about proxy server connection limits. | 57 // http://crbug.com/44501 for details about proxy server connection limits. |
58 int g_max_sockets_per_proxy_server[] = { | 58 int g_max_sockets_per_proxy_server[] = { |
59 kDefaultMaxSocketsPerProxyServer, // NORMAL_SOCKET_POOL | 59 kDefaultMaxSocketsPerProxyServer, // NORMAL_SOCKET_POOL |
60 kDefaultMaxSocketsPerProxyServer // WEBSOCKET_SOCKET_POOL | 60 kDefaultMaxSocketsPerProxyServer // WEBSOCKET_SOCKET_POOL |
61 }; | 61 }; |
62 | 62 |
63 COMPILE_ASSERT(arraysize(g_max_sockets_per_proxy_server) == | 63 COMPILE_ASSERT(arraysize(g_max_sockets_per_proxy_server) == |
64 HttpNetworkSession::NUM_SOCKET_POOL_TYPES, | 64 HttpNetworkSession::NUM_SOCKET_POOL_TYPES, |
65 max_sockets_per_proxy_server_length_mismatch); | 65 max_sockets_per_proxy_server_length_mismatch); |
66 | 66 |
67 // The meat of the implementation for the InitSocketHandleForHttpRequest, | 67 std::string ConnectionGroupForUrl(const GURL& request_url, |
68 // InitSocketHandleForRawConnect and PreconnectSocketsForHttpRequest methods. | 68 bool force_ssl, |
69 int InitSocketPoolHelper(const GURL& request_url, | 69 const HostPortPair& host_port, |
70 const HttpRequestHeaders& request_extra_headers, | 70 uint16 ssl_version_max, |
71 int request_load_flags, | 71 ProxyServer::Scheme proxy_scheme) { |
72 RequestPriority request_priority, | |
73 HttpNetworkSession* session, | |
74 const ProxyInfo& proxy_info, | |
75 bool force_spdy_over_ssl, | |
76 bool want_spdy_over_npn, | |
77 const SSLConfig& ssl_config_for_origin, | |
78 const SSLConfig& ssl_config_for_proxy, | |
79 bool force_tunnel, | |
80 const BoundNetLog& net_log, | |
81 int num_preconnect_streams, | |
82 ClientSocketHandle* socket_handle, | |
83 const OnHostResolutionCallback& resolution_callback, | |
84 const CompletionCallback& callback) { | |
85 scoped_refptr<TransportSocketParams> tcp_params; | |
86 scoped_refptr<HttpProxySocketParams> http_proxy_params; | |
87 scoped_refptr<SOCKSSocketParams> socks_params; | |
88 scoped_ptr<HostPortPair> proxy_host_port; | |
89 | |
90 bool using_ssl = request_url.SchemeIs("https") || force_spdy_over_ssl; | |
91 | |
92 HostPortPair origin_host_port = | |
93 HostPortPair(request_url.HostNoBrackets(), | |
94 request_url.EffectiveIntPort()); | |
95 | |
96 if (!using_ssl && session->params().testing_fixed_http_port != 0) { | |
97 origin_host_port.set_port(session->params().testing_fixed_http_port); | |
98 } else if (using_ssl && session->params().testing_fixed_https_port != 0) { | |
99 origin_host_port.set_port(session->params().testing_fixed_https_port); | |
100 } | |
101 | |
102 bool disable_resolver_cache = | |
103 request_load_flags & LOAD_BYPASS_CACHE || | |
104 request_load_flags & LOAD_VALIDATE_CACHE || | |
105 request_load_flags & LOAD_DISABLE_CACHE; | |
106 | |
107 int load_flags = request_load_flags; | |
108 if (session->params().ignore_certificate_errors) | |
109 load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS; | |
110 | |
111 // Build the string used to uniquely identify connections of this type. | 72 // Build the string used to uniquely identify connections of this type. |
112 // Determine the host and port to connect to. | 73 // Determine the host and port to connect to. |
113 std::string connection_group = origin_host_port.ToString(); | 74 std::string connection_group = host_port.ToString(); |
114 DCHECK(!connection_group.empty()); | 75 DCHECK(!connection_group.empty()); |
115 if (request_url.SchemeIs("ftp")) { | 76 if (request_url.SchemeIs("ftp")) { |
116 // Combining FTP with forced SPDY over SSL would be a "path to madness". | |
117 // Make sure we never do that. | |
118 DCHECK(!using_ssl); | |
119 connection_group = "ftp/" + connection_group; | 77 connection_group = "ftp/" + connection_group; |
120 } | 78 } else if (force_ssl || request_url.SchemeIs("https")) { |
121 if (using_ssl) { | |
122 // All connections in a group should use the same SSLConfig settings. | 79 // All connections in a group should use the same SSLConfig settings. |
123 // Encode version_max in the connection group's name, unless it's the | 80 // Encode version_max in the connection group's name, unless it's the |
124 // default version_max. (We want the common case to use the shortest | 81 // default version_max. (We want the common case to use the shortest |
125 // encoding). A version_max of TLS 1.1 is encoded as "ssl(max:3.2)/" | 82 // encoding). A version_max of TLS 1.1 is encoded as "ssl(max:3.2)/" |
126 // rather than "tlsv1.1/" because the actual protocol version, which | 83 // rather than "tlsv1.1/" because the actual protocol version, which |
127 // is selected by the server, may not be TLS 1.1. Do not encode | 84 // is selected by the server, may not be TLS 1.1. Do not encode |
128 // version_min in the connection group's name because version_min | 85 // version_min in the connection group's name because version_min |
129 // should be the same for all connections, whereas version_max may | 86 // should be the same for all connections, whereas version_max may |
130 // change for version fallbacks. | 87 // change for version fallbacks. |
131 std::string prefix = "ssl/"; | 88 std::string prefix = "ssl/"; |
132 if (ssl_config_for_origin.version_max != | 89 if (ssl_version_max != |
133 SSLConfigService::default_version_max()) { | 90 SSLConfigService::default_version_max()) { |
134 switch (ssl_config_for_origin.version_max) { | 91 switch (ssl_version_max) { |
135 case SSL_PROTOCOL_VERSION_TLS1_2: | 92 case SSL_PROTOCOL_VERSION_TLS1_2: |
136 prefix = "ssl(max:3.3)/"; | 93 prefix = "ssl(max:3.3)/"; |
137 break; | 94 break; |
138 case SSL_PROTOCOL_VERSION_TLS1_1: | 95 case SSL_PROTOCOL_VERSION_TLS1_1: |
139 prefix = "ssl(max:3.2)/"; | 96 prefix = "ssl(max:3.2)/"; |
140 break; | 97 break; |
141 case SSL_PROTOCOL_VERSION_TLS1: | 98 case SSL_PROTOCOL_VERSION_TLS1: |
142 prefix = "ssl(max:3.1)/"; | 99 prefix = "ssl(max:3.1)/"; |
143 break; | 100 break; |
144 case SSL_PROTOCOL_VERSION_SSL3: | 101 case SSL_PROTOCOL_VERSION_SSL3: |
145 prefix = "sslv3/"; | 102 prefix = "sslv3/"; |
146 break; | 103 break; |
147 default: | 104 default: |
148 CHECK(false); | 105 CHECK(false); |
149 break; | 106 break; |
150 } | 107 } |
151 } | 108 } |
152 connection_group = prefix + connection_group; | 109 connection_group = prefix + connection_group; |
153 } | 110 } |
154 | 111 |
155 bool ignore_limits = (request_load_flags & LOAD_IGNORE_LIMITS) != 0; | 112 char socks_version = 0; |
113 if (proxy_scheme == ProxyServer::SCHEME_SOCKS4) | |
114 socks_version = '4'; | |
115 else if (proxy_scheme == ProxyServer::SCHEME_SOCKS5) | |
116 socks_version = '5'; | |
117 | |
118 if (socks_version) | |
119 connection_group = base::StringPrintf("socks%c/%s", socks_version, | |
120 connection_group.c_str()); | |
121 | |
122 return connection_group; | |
123 } | |
124 | |
125 HostPortPair HostPortPairFromUrlForSession(const GURL& request_url, | |
126 bool using_ssl, | |
127 HttpNetworkSession* session) { | |
128 HostPortPair host_port(request_url.HostNoBrackets(), | |
129 request_url.EffectiveIntPort()); | |
130 | |
131 if (!using_ssl && session->params().testing_fixed_http_port != 0) { | |
132 host_port.set_port(session->params().testing_fixed_http_port); | |
133 } else if (using_ssl && session->params().testing_fixed_https_port != 0) { | |
134 host_port.set_port(session->params().testing_fixed_https_port); | |
135 } | |
136 | |
137 return host_port; | |
138 } | |
139 | |
140 template<typename Callback> | |
141 int | |
142 InvokeWithSocketParamsAndPool( | |
143 const GURL& request_url, | |
144 const HttpRequestHeaders& request_extra_headers, | |
145 int request_load_flags, | |
146 RequestPriority request_priority, | |
147 HttpNetworkSession* session, | |
148 const ProxyInfo& proxy_info, | |
149 bool force_spdy_over_ssl, | |
150 bool want_spdy_over_npn, | |
151 const SSLConfig& ssl_config_for_origin, | |
152 const SSLConfig& ssl_config_for_proxy, | |
153 bool force_tunnel, | |
154 const OnHostResolutionCallback& resolution_callback, | |
155 const Callback& callback) { | |
156 bool using_ssl = request_url.SchemeIs("https") || force_spdy_over_ssl; | |
157 // Combining FTP with forced SPDY over SSL would be a "path to madness". | |
158 // Make sure we never do that. | |
159 DCHECK(!(using_ssl && request_url.SchemeIs("ftp"))); | |
160 | |
161 HostPortPair origin_host_port = | |
162 HostPortPairFromUrlForSession(request_url, using_ssl, session); | |
163 | |
164 ProxyServer::Scheme proxy_scheme = proxy_info.proxy_server().scheme(); | |
165 std::string connection_group = | |
166 ConnectionGroupForUrl(request_url, force_spdy_over_ssl, origin_host_port, | |
167 using_ssl ? ssl_config_for_origin.version_max : 0, | |
168 proxy_scheme); | |
169 | |
170 scoped_ptr<HostPortPair> proxy_host_port; | |
171 HostPortPair* target_host_port = NULL; | |
156 if (proxy_info.is_direct()) { | 172 if (proxy_info.is_direct()) { |
157 tcp_params = new TransportSocketParams(origin_host_port, | 173 target_host_port = &origin_host_port; |
174 } else { | |
175 proxy_host_port.reset( | |
176 new HostPortPair(proxy_info.proxy_server().host_port_pair())); | |
177 target_host_port = proxy_host_port.get(); | |
178 } | |
179 | |
180 SSLClientSocketPool* ssl_pool = NULL; | |
181 if (using_ssl) { | |
182 if (proxy_info.is_direct()) | |
183 ssl_pool = session->GetSSLSocketPool( | |
184 HttpNetworkSession::NORMAL_SOCKET_POOL); | |
185 else | |
186 ssl_pool = session->GetSocketPoolForSSLWithProxy( | |
187 HttpNetworkSession::NORMAL_SOCKET_POOL, | |
188 *proxy_host_port); | |
189 } | |
190 | |
191 int load_flags = request_load_flags; | |
192 if (session->params().ignore_certificate_errors) | |
193 load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS; | |
194 | |
195 scoped_refptr<TransportSocketParams> tcp_params; | |
196 { | |
197 bool disable_resolver_cache = | |
198 request_load_flags & LOAD_BYPASS_CACHE || | |
199 request_load_flags & LOAD_VALIDATE_CACHE || | |
200 request_load_flags & LOAD_DISABLE_CACHE; | |
201 bool ignore_limits = (request_load_flags & LOAD_IGNORE_LIMITS) != 0; | |
202 tcp_params = new TransportSocketParams(*target_host_port, | |
158 request_priority, | 203 request_priority, |
159 disable_resolver_cache, | 204 disable_resolver_cache, |
160 ignore_limits, | 205 ignore_limits, |
161 resolution_callback); | 206 resolution_callback); |
207 } | |
208 | |
209 if (proxy_info.is_direct()) { | |
210 if (using_ssl) { | |
211 scoped_refptr<SSLSocketParams> ssl_params = | |
212 SSLSocketParams::CreateForDirectConnection( | |
213 tcp_params, | |
214 origin_host_port, | |
215 ssl_config_for_origin, | |
216 load_flags, | |
217 force_spdy_over_ssl, | |
218 want_spdy_over_npn); | |
219 | |
220 return callback(ssl_pool, connection_group, ssl_params, request_priority); | |
221 } else { | |
222 TransportClientSocketPool* pool = session->GetTransportSocketPool( | |
223 HttpNetworkSession::NORMAL_SOCKET_POOL); | |
224 | |
225 return callback(pool, connection_group, tcp_params, request_priority); | |
226 } | |
227 } else if (proxy_info.is_http() || proxy_info.is_https()) { | |
228 std::string user_agent; | |
229 request_extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, | |
230 &user_agent); | |
231 scoped_refptr<SSLSocketParams> ssl_params; | |
232 if (proxy_info.is_https()) { | |
233 ssl_params = SSLSocketParams::CreateForDirectConnection( | |
234 tcp_params, | |
235 *proxy_host_port.get(), | |
236 ssl_config_for_proxy, | |
237 load_flags, | |
238 force_spdy_over_ssl, | |
239 want_spdy_over_npn); | |
240 } | |
241 | |
242 scoped_refptr<HttpProxySocketParams> http_proxy_params = | |
243 new HttpProxySocketParams(proxy_info.is_https() ? NULL : tcp_params, | |
244 ssl_params, | |
245 request_url, | |
246 user_agent, | |
247 origin_host_port, | |
248 session->http_auth_cache(), | |
249 session->http_auth_handler_factory(), | |
250 session->spdy_session_pool(), | |
251 force_tunnel || using_ssl); | |
252 | |
253 if (using_ssl) { | |
254 scoped_refptr<SSLSocketParams> ssl_params = | |
255 SSLSocketParams::CreateForHttpProxy( | |
256 http_proxy_params, | |
257 proxy_scheme, | |
258 origin_host_port, | |
259 ssl_config_for_origin, | |
260 load_flags, | |
261 force_spdy_over_ssl, | |
262 want_spdy_over_npn); | |
263 | |
264 return callback(ssl_pool, connection_group, ssl_params, request_priority); | |
265 } else { | |
266 HttpProxyClientSocketPool* pool = | |
267 session->GetSocketPoolForHTTPProxy( | |
268 HttpNetworkSession::NORMAL_SOCKET_POOL, | |
269 *proxy_host_port); | |
270 | |
271 return callback(pool, connection_group, | |
272 http_proxy_params, request_priority); | |
273 } | |
162 } else { | 274 } else { |
163 ProxyServer proxy_server = proxy_info.proxy_server(); | 275 DCHECK(proxy_info.is_socks()); |
164 proxy_host_port.reset(new HostPortPair(proxy_server.host_port_pair())); | 276 |
165 scoped_refptr<TransportSocketParams> proxy_tcp_params( | 277 scoped_refptr<SOCKSSocketParams> socks_params = |
166 new TransportSocketParams(*proxy_host_port, | 278 new SOCKSSocketParams(tcp_params, |
167 request_priority, | 279 proxy_scheme == ProxyServer::SCHEME_SOCKS5, |
168 disable_resolver_cache, | 280 origin_host_port, |
169 ignore_limits, | 281 request_priority); |
170 resolution_callback)); | 282 |
171 | 283 if (using_ssl) { |
172 if (proxy_info.is_http() || proxy_info.is_https()) { | 284 scoped_refptr<SSLSocketParams> ssl_params = |
173 std::string user_agent; | 285 SSLSocketParams::CreateForSocksProxy( |
174 request_extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, | 286 socks_params, |
175 &user_agent); | 287 proxy_scheme, |
176 scoped_refptr<SSLSocketParams> ssl_params; | 288 origin_host_port, |
177 if (proxy_info.is_https()) { | 289 ssl_config_for_origin, |
178 // Set ssl_params, and unset proxy_tcp_params | 290 load_flags, |
179 ssl_params = new SSLSocketParams(proxy_tcp_params, | 291 force_spdy_over_ssl, |
180 NULL, | 292 want_spdy_over_npn); |
181 NULL, | 293 |
182 ProxyServer::SCHEME_DIRECT, | 294 return callback(ssl_pool, connection_group, ssl_params, request_priority); |
183 *proxy_host_port.get(), | |
184 ssl_config_for_proxy, | |
185 load_flags, | |
186 force_spdy_over_ssl, | |
187 want_spdy_over_npn); | |
188 proxy_tcp_params = NULL; | |
189 } | |
190 | |
191 http_proxy_params = | |
192 new HttpProxySocketParams(proxy_tcp_params, | |
193 ssl_params, | |
194 request_url, | |
195 user_agent, | |
196 origin_host_port, | |
197 session->http_auth_cache(), | |
198 session->http_auth_handler_factory(), | |
199 session->spdy_session_pool(), | |
200 force_tunnel || using_ssl); | |
201 } else { | 295 } else { |
202 DCHECK(proxy_info.is_socks()); | 296 SOCKSClientSocketPool* pool = session->GetSocketPoolForSOCKSProxy( |
203 char socks_version; | |
204 if (proxy_server.scheme() == ProxyServer::SCHEME_SOCKS5) | |
205 socks_version = '5'; | |
206 else | |
207 socks_version = '4'; | |
208 connection_group = base::StringPrintf( | |
209 "socks%c/%s", socks_version, connection_group.c_str()); | |
210 | |
211 socks_params = new SOCKSSocketParams(proxy_tcp_params, | |
212 socks_version == '5', | |
213 origin_host_port, | |
214 request_priority); | |
215 } | |
216 } | |
217 | |
218 // Deal with SSL - which layers on top of any given proxy. | |
219 if (using_ssl) { | |
220 scoped_refptr<SSLSocketParams> ssl_params = | |
221 new SSLSocketParams(tcp_params, | |
222 socks_params, | |
223 http_proxy_params, | |
224 proxy_info.proxy_server().scheme(), | |
225 origin_host_port, | |
226 ssl_config_for_origin, | |
227 load_flags, | |
228 force_spdy_over_ssl, | |
229 want_spdy_over_npn); | |
230 SSLClientSocketPool* ssl_pool = NULL; | |
231 if (proxy_info.is_direct()) { | |
232 ssl_pool = session->GetSSLSocketPool( | |
233 HttpNetworkSession::NORMAL_SOCKET_POOL); | |
234 } else { | |
235 ssl_pool = session->GetSocketPoolForSSLWithProxy( | |
236 HttpNetworkSession::NORMAL_SOCKET_POOL, | 297 HttpNetworkSession::NORMAL_SOCKET_POOL, |
237 *proxy_host_port); | 298 *proxy_host_port); |
238 } | 299 |
239 | 300 return callback(pool, connection_group, socks_params, request_priority); |
240 if (num_preconnect_streams) { | 301 } |
241 RequestSocketsForPool(ssl_pool, connection_group, ssl_params, | 302 } |
242 num_preconnect_streams, net_log); | 303 |
243 return OK; | 304 NOTREACHED(); |
244 } | 305 return ERR_UNEXPECTED; |
245 | 306 } |
246 return socket_handle->Init(connection_group, ssl_params, | 307 |
247 request_priority, callback, ssl_pool, | 308 class RequestSocketForPool { |
mmenke
2013/05/01 19:31:12
I think that these are sufficiently ugly that we s
| |
248 net_log); | 309 public: |
249 } | 310 RequestSocketForPool(ClientSocketHandle* socket_handle, |
250 | 311 const CompletionCallback& callback, |
251 // Finally, get the connection started. | 312 const BoundNetLog& net_log) |
252 | 313 : socket_handle_(socket_handle), |
253 if (proxy_info.is_http() || proxy_info.is_https()) { | 314 callback_(callback), |
254 HttpProxyClientSocketPool* pool = | 315 net_log_(net_log) {} |
255 session->GetSocketPoolForHTTPProxy( | 316 |
256 HttpNetworkSession::NORMAL_SOCKET_POOL, | 317 template <typename PoolType, typename SocketParams> |
257 *proxy_host_port); | 318 int operator()(PoolType* pool, |
258 if (num_preconnect_streams) { | 319 const std::string& group_name, |
259 RequestSocketsForPool(pool, connection_group, http_proxy_params, | 320 const scoped_refptr<SocketParams>& params, |
260 num_preconnect_streams, net_log); | 321 RequestPriority request_priority) const { |
261 return OK; | 322 CheckIsValidSocketParamsForPool<PoolType, SocketParams>(); |
262 } | 323 |
263 | 324 return socket_handle_->Init(group_name, params, request_priority, |
264 return socket_handle->Init(connection_group, http_proxy_params, | 325 callback_, pool, net_log_); |
265 request_priority, callback, | 326 } |
266 pool, net_log); | 327 |
267 } | 328 private: |
268 | 329 ClientSocketHandle* socket_handle_; |
269 if (proxy_info.is_socks()) { | 330 const CompletionCallback& callback_; |
270 SOCKSClientSocketPool* pool = | 331 const BoundNetLog& net_log_; |
271 session->GetSocketPoolForSOCKSProxy( | 332 }; |
272 HttpNetworkSession::NORMAL_SOCKET_POOL, | 333 |
273 *proxy_host_port); | 334 class RequestSocketsForPool { |
274 if (num_preconnect_streams) { | 335 public: |
275 RequestSocketsForPool(pool, connection_group, socks_params, | 336 RequestSocketsForPool(int num_preconnect_streams, |
276 num_preconnect_streams, net_log); | 337 const BoundNetLog& net_log) |
277 return OK; | 338 : num_preconnect_streams_(num_preconnect_streams), |
278 } | 339 net_log_(net_log) {} |
279 | 340 |
280 return socket_handle->Init(connection_group, socks_params, | 341 template <typename PoolType, typename SocketParams> |
281 request_priority, callback, pool, | 342 int operator()(PoolType* pool, |
282 net_log); | 343 const std::string& group_name, |
283 } | 344 const scoped_refptr<SocketParams>& params, |
284 | 345 RequestPriority request_priority) const { |
285 DCHECK(proxy_info.is_direct()); | 346 CheckIsValidSocketParamsForPool<PoolType, SocketParams>(); |
286 | 347 |
287 TransportClientSocketPool* pool = | 348 pool->RequestSockets( |
288 session->GetTransportSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL); | 349 group_name, ¶ms, num_preconnect_streams_, net_log_); |
289 if (num_preconnect_streams) { | |
290 RequestSocketsForPool(pool, connection_group, tcp_params, | |
291 num_preconnect_streams, net_log); | |
292 return OK; | 350 return OK; |
293 } | 351 } |
294 | 352 |
295 return socket_handle->Init(connection_group, tcp_params, | 353 private: |
296 request_priority, callback, | 354 int num_preconnect_streams_; |
297 pool, net_log); | 355 const BoundNetLog& net_log_; |
298 } | 356 }; |
299 | 357 |
300 } // namespace | 358 } // namespace |
301 | 359 |
302 ClientSocketPoolManager::ClientSocketPoolManager() {} | 360 ClientSocketPoolManager::ClientSocketPoolManager() {} |
303 ClientSocketPoolManager::~ClientSocketPoolManager() {} | 361 ClientSocketPoolManager::~ClientSocketPoolManager() {} |
304 | 362 |
305 // static | 363 // static |
306 int ClientSocketPoolManager::max_sockets_per_pool( | 364 int ClientSocketPoolManager::max_sockets_per_pool( |
307 HttpNetworkSession::SocketPoolType pool_type) { | 365 HttpNetworkSession::SocketPoolType pool_type) { |
308 DCHECK_LT(pool_type, HttpNetworkSession::NUM_SOCKET_POOL_TYPES); | 366 DCHECK_LT(pool_type, HttpNetworkSession::NUM_SOCKET_POOL_TYPES); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 const ProxyInfo& proxy_info, | 431 const ProxyInfo& proxy_info, |
374 bool force_spdy_over_ssl, | 432 bool force_spdy_over_ssl, |
375 bool want_spdy_over_npn, | 433 bool want_spdy_over_npn, |
376 const SSLConfig& ssl_config_for_origin, | 434 const SSLConfig& ssl_config_for_origin, |
377 const SSLConfig& ssl_config_for_proxy, | 435 const SSLConfig& ssl_config_for_proxy, |
378 const BoundNetLog& net_log, | 436 const BoundNetLog& net_log, |
379 ClientSocketHandle* socket_handle, | 437 ClientSocketHandle* socket_handle, |
380 const OnHostResolutionCallback& resolution_callback, | 438 const OnHostResolutionCallback& resolution_callback, |
381 const CompletionCallback& callback) { | 439 const CompletionCallback& callback) { |
382 DCHECK(socket_handle); | 440 DCHECK(socket_handle); |
383 return InitSocketPoolHelper( | 441 |
442 RequestSocketForPool socketRequest(socket_handle, callback, net_log); | |
443 | |
444 return InvokeWithSocketParamsAndPool( | |
384 request_url, request_extra_headers, request_load_flags, request_priority, | 445 request_url, request_extra_headers, request_load_flags, request_priority, |
385 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, | 446 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, |
386 ssl_config_for_origin, ssl_config_for_proxy, false, net_log, 0, | 447 ssl_config_for_origin, ssl_config_for_proxy, false, |
387 socket_handle, resolution_callback, callback); | 448 resolution_callback, socketRequest); |
388 } | 449 } |
389 | 450 |
390 int InitSocketHandleForRawConnect( | 451 int InitSocketHandleForRawConnect( |
391 const HostPortPair& host_port_pair, | 452 const HostPortPair& host_port_pair, |
392 HttpNetworkSession* session, | 453 HttpNetworkSession* session, |
393 const ProxyInfo& proxy_info, | 454 const ProxyInfo& proxy_info, |
394 const SSLConfig& ssl_config_for_origin, | 455 const SSLConfig& ssl_config_for_origin, |
395 const SSLConfig& ssl_config_for_proxy, | 456 const SSLConfig& ssl_config_for_proxy, |
396 const BoundNetLog& net_log, | 457 const BoundNetLog& net_log, |
397 ClientSocketHandle* socket_handle, | 458 ClientSocketHandle* socket_handle, |
398 const CompletionCallback& callback) { | 459 const CompletionCallback& callback) { |
399 DCHECK(socket_handle); | 460 DCHECK(socket_handle); |
461 | |
462 RequestSocketForPool socketRequest(socket_handle, callback, net_log); | |
463 | |
400 // Synthesize an HttpRequestInfo. | 464 // Synthesize an HttpRequestInfo. |
401 GURL request_url = GURL("http://" + host_port_pair.ToString()); | 465 GURL request_url = GURL("http://" + host_port_pair.ToString()); |
402 HttpRequestHeaders request_extra_headers; | 466 HttpRequestHeaders request_extra_headers; |
403 int request_load_flags = 0; | 467 int request_load_flags = 0; |
404 RequestPriority request_priority = MEDIUM; | 468 RequestPriority request_priority = MEDIUM; |
405 | 469 |
406 return InitSocketPoolHelper( | 470 return InvokeWithSocketParamsAndPool( |
407 request_url, request_extra_headers, request_load_flags, request_priority, | 471 request_url, request_extra_headers, request_load_flags, request_priority, |
408 session, proxy_info, false, false, ssl_config_for_origin, | 472 session, proxy_info, false, false, |
409 ssl_config_for_proxy, true, net_log, 0, socket_handle, | 473 ssl_config_for_origin, ssl_config_for_proxy, true, |
410 OnHostResolutionCallback(), callback); | 474 OnHostResolutionCallback(), socketRequest); |
411 } | 475 } |
412 | 476 |
413 int PreconnectSocketsForHttpRequest( | 477 int PreconnectSocketsForHttpRequest( |
414 const GURL& request_url, | 478 const GURL& request_url, |
415 const HttpRequestHeaders& request_extra_headers, | 479 const HttpRequestHeaders& request_extra_headers, |
416 int request_load_flags, | 480 int request_load_flags, |
417 RequestPriority request_priority, | 481 RequestPriority request_priority, |
418 HttpNetworkSession* session, | 482 HttpNetworkSession* session, |
419 const ProxyInfo& proxy_info, | 483 const ProxyInfo& proxy_info, |
420 bool force_spdy_over_ssl, | 484 bool force_spdy_over_ssl, |
421 bool want_spdy_over_npn, | 485 bool want_spdy_over_npn, |
422 const SSLConfig& ssl_config_for_origin, | 486 const SSLConfig& ssl_config_for_origin, |
423 const SSLConfig& ssl_config_for_proxy, | 487 const SSLConfig& ssl_config_for_proxy, |
424 const BoundNetLog& net_log, | 488 const BoundNetLog& net_log, |
425 int num_preconnect_streams) { | 489 int num_preconnect_streams) { |
426 return InitSocketPoolHelper( | 490 RequestSocketsForPool socketsRequest(num_preconnect_streams, net_log); |
491 | |
492 return InvokeWithSocketParamsAndPool( | |
427 request_url, request_extra_headers, request_load_flags, request_priority, | 493 request_url, request_extra_headers, request_load_flags, request_priority, |
428 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, | 494 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, |
429 ssl_config_for_origin, ssl_config_for_proxy, false, net_log, | 495 ssl_config_for_origin, ssl_config_for_proxy, false, |
430 num_preconnect_streams, NULL, OnHostResolutionCallback(), | 496 OnHostResolutionCallback(), socketsRequest); |
431 CompletionCallback()); | |
432 } | 497 } |
433 | 498 |
434 } // namespace net | 499 } // namespace net |
OLD | NEW |