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 new SSLSocketParams(tcp_params, |
| 213 origin_host_port, |
| 214 ssl_config_for_origin, |
| 215 load_flags, |
| 216 force_spdy_over_ssl, |
| 217 want_spdy_over_npn); |
| 218 |
| 219 return callback(ssl_pool, connection_group, ssl_params, request_priority); |
| 220 } else { |
| 221 TransportClientSocketPool* pool = session->GetTransportSocketPool( |
| 222 HttpNetworkSession::NORMAL_SOCKET_POOL); |
| 223 |
| 224 return callback(pool, connection_group, tcp_params, request_priority); |
| 225 } |
| 226 } else if (proxy_info.is_http() || proxy_info.is_https()) { |
| 227 std::string user_agent; |
| 228 request_extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, |
| 229 &user_agent); |
| 230 scoped_refptr<SSLSocketParams> ssl_params; |
| 231 if (proxy_info.is_https()) { |
| 232 ssl_params = new SSLSocketParams(tcp_params, |
| 233 *proxy_host_port.get(), |
| 234 ssl_config_for_proxy, |
| 235 load_flags, |
| 236 force_spdy_over_ssl, |
| 237 want_spdy_over_npn); |
| 238 } |
| 239 |
| 240 scoped_refptr<HttpProxySocketParams> http_proxy_params = |
| 241 new HttpProxySocketParams(proxy_info.is_https() ? NULL : tcp_params, |
| 242 ssl_params, |
| 243 request_url, |
| 244 user_agent, |
| 245 origin_host_port, |
| 246 session->http_auth_cache(), |
| 247 session->http_auth_handler_factory(), |
| 248 session->spdy_session_pool(), |
| 249 force_tunnel || using_ssl); |
| 250 |
| 251 if (using_ssl) { |
| 252 scoped_refptr<SSLSocketParams> ssl_params = |
| 253 new SSLSocketParams(http_proxy_params, |
| 254 proxy_scheme, |
| 255 origin_host_port, |
| 256 ssl_config_for_origin, |
| 257 load_flags, |
| 258 force_spdy_over_ssl, |
| 259 want_spdy_over_npn); |
| 260 |
| 261 return callback(ssl_pool, connection_group, ssl_params, request_priority); |
| 262 } else { |
| 263 HttpProxyClientSocketPool* pool = |
| 264 session->GetSocketPoolForHTTPProxy( |
| 265 HttpNetworkSession::NORMAL_SOCKET_POOL, |
| 266 *proxy_host_port); |
| 267 |
| 268 return callback(pool, connection_group, |
| 269 http_proxy_params, request_priority); |
| 270 } |
162 } else { | 271 } else { |
163 ProxyServer proxy_server = proxy_info.proxy_server(); | 272 DCHECK(proxy_info.is_socks()); |
164 proxy_host_port.reset(new HostPortPair(proxy_server.host_port_pair())); | 273 |
165 scoped_refptr<TransportSocketParams> proxy_tcp_params( | 274 scoped_refptr<SOCKSSocketParams> socks_params = |
166 new TransportSocketParams(*proxy_host_port, | 275 new SOCKSSocketParams(tcp_params, |
167 request_priority, | 276 proxy_scheme == ProxyServer::SCHEME_SOCKS5, |
168 disable_resolver_cache, | 277 origin_host_port, |
169 ignore_limits, | 278 request_priority); |
170 resolution_callback)); | 279 |
171 | 280 if (using_ssl) { |
172 if (proxy_info.is_http() || proxy_info.is_https()) { | 281 scoped_refptr<SSLSocketParams> ssl_params = |
173 std::string user_agent; | 282 new SSLSocketParams(socks_params, |
174 request_extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, | 283 proxy_scheme, |
175 &user_agent); | 284 origin_host_port, |
176 scoped_refptr<SSLSocketParams> ssl_params; | 285 ssl_config_for_origin, |
177 if (proxy_info.is_https()) { | 286 load_flags, |
178 // Set ssl_params, and unset proxy_tcp_params | 287 force_spdy_over_ssl, |
179 ssl_params = new SSLSocketParams(proxy_tcp_params, | 288 want_spdy_over_npn); |
180 NULL, | 289 |
181 NULL, | 290 return callback(ssl_pool, connection_group, ssl_params, request_priority); |
182 ProxyServer::SCHEME_DIRECT, | |
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 { | 291 } else { |
202 DCHECK(proxy_info.is_socks()); | 292 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, | 293 HttpNetworkSession::NORMAL_SOCKET_POOL, |
237 *proxy_host_port); | 294 *proxy_host_port); |
238 } | 295 |
239 | 296 return callback(pool, connection_group, socks_params, request_priority); |
240 if (num_preconnect_streams) { | 297 } |
241 RequestSocketsForPool(ssl_pool, connection_group, ssl_params, | 298 } |
242 num_preconnect_streams, net_log); | 299 |
243 return OK; | 300 NOTREACHED(); |
244 } | 301 return ERR_UNEXPECTED; |
245 | 302 } |
246 return socket_handle->Init(connection_group, ssl_params, | 303 |
247 request_priority, callback, ssl_pool, | 304 class RequestSocketForPool { |
248 net_log); | 305 public: |
249 } | 306 RequestSocketForPool(ClientSocketHandle* socket_handle, |
250 | 307 const CompletionCallback& callback, |
251 // Finally, get the connection started. | 308 const BoundNetLog& net_log) |
252 | 309 : socket_handle_(socket_handle), |
253 if (proxy_info.is_http() || proxy_info.is_https()) { | 310 callback_(callback), |
254 HttpProxyClientSocketPool* pool = | 311 net_log_(net_log) {} |
255 session->GetSocketPoolForHTTPProxy( | 312 |
256 HttpNetworkSession::NORMAL_SOCKET_POOL, | 313 template <typename PoolType, typename SocketParams> |
257 *proxy_host_port); | 314 int operator()(PoolType* pool, |
258 if (num_preconnect_streams) { | 315 const std::string& group_name, |
259 RequestSocketsForPool(pool, connection_group, http_proxy_params, | 316 const scoped_refptr<SocketParams>& params, |
260 num_preconnect_streams, net_log); | 317 RequestPriority request_priority) const { |
261 return OK; | 318 CheckIsValidSocketParamsForPool<PoolType, SocketParams>(); |
262 } | 319 |
263 | 320 return socket_handle_->Init(group_name, params, request_priority, |
264 return socket_handle->Init(connection_group, http_proxy_params, | 321 callback_, pool, net_log_); |
265 request_priority, callback, | 322 } |
266 pool, net_log); | 323 |
267 } | 324 private: |
268 | 325 ClientSocketHandle* socket_handle_; |
269 if (proxy_info.is_socks()) { | 326 const CompletionCallback& callback_; |
270 SOCKSClientSocketPool* pool = | 327 const BoundNetLog& net_log_; |
271 session->GetSocketPoolForSOCKSProxy( | 328 }; |
272 HttpNetworkSession::NORMAL_SOCKET_POOL, | 329 |
273 *proxy_host_port); | 330 class RequestSocketsForPool { |
274 if (num_preconnect_streams) { | 331 public: |
275 RequestSocketsForPool(pool, connection_group, socks_params, | 332 RequestSocketsForPool(int num_preconnect_streams, |
276 num_preconnect_streams, net_log); | 333 const BoundNetLog& net_log) |
277 return OK; | 334 : num_preconnect_streams_(num_preconnect_streams), |
278 } | 335 net_log_(net_log) {} |
279 | 336 |
280 return socket_handle->Init(connection_group, socks_params, | 337 template <typename PoolType, typename SocketParams> |
281 request_priority, callback, pool, | 338 int operator()(PoolType* pool, |
282 net_log); | 339 const std::string& group_name, |
283 } | 340 const scoped_refptr<SocketParams>& params, |
284 | 341 RequestPriority request_priority) const { |
285 DCHECK(proxy_info.is_direct()); | 342 CheckIsValidSocketParamsForPool<PoolType, SocketParams>(); |
286 | 343 |
287 TransportClientSocketPool* pool = | 344 pool->RequestSockets( |
288 session->GetTransportSocketPool(HttpNetworkSession::NORMAL_SOCKET_POOL); | 345 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; | 346 return OK; |
293 } | 347 } |
294 | 348 |
295 return socket_handle->Init(connection_group, tcp_params, | 349 private: |
296 request_priority, callback, | 350 int num_preconnect_streams_; |
297 pool, net_log); | 351 const BoundNetLog& net_log_; |
298 } | 352 }; |
299 | 353 |
300 } // namespace | 354 } // namespace |
301 | 355 |
302 ClientSocketPoolManager::ClientSocketPoolManager() {} | 356 ClientSocketPoolManager::ClientSocketPoolManager() {} |
303 ClientSocketPoolManager::~ClientSocketPoolManager() {} | 357 ClientSocketPoolManager::~ClientSocketPoolManager() {} |
304 | 358 |
305 // static | 359 // static |
306 int ClientSocketPoolManager::max_sockets_per_pool( | 360 int ClientSocketPoolManager::max_sockets_per_pool( |
307 HttpNetworkSession::SocketPoolType pool_type) { | 361 HttpNetworkSession::SocketPoolType pool_type) { |
308 DCHECK_LT(pool_type, HttpNetworkSession::NUM_SOCKET_POOL_TYPES); | 362 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, | 427 const ProxyInfo& proxy_info, |
374 bool force_spdy_over_ssl, | 428 bool force_spdy_over_ssl, |
375 bool want_spdy_over_npn, | 429 bool want_spdy_over_npn, |
376 const SSLConfig& ssl_config_for_origin, | 430 const SSLConfig& ssl_config_for_origin, |
377 const SSLConfig& ssl_config_for_proxy, | 431 const SSLConfig& ssl_config_for_proxy, |
378 const BoundNetLog& net_log, | 432 const BoundNetLog& net_log, |
379 ClientSocketHandle* socket_handle, | 433 ClientSocketHandle* socket_handle, |
380 const OnHostResolutionCallback& resolution_callback, | 434 const OnHostResolutionCallback& resolution_callback, |
381 const CompletionCallback& callback) { | 435 const CompletionCallback& callback) { |
382 DCHECK(socket_handle); | 436 DCHECK(socket_handle); |
383 return InitSocketPoolHelper( | 437 |
| 438 RequestSocketForPool socketRequest(socket_handle, callback, net_log); |
| 439 |
| 440 return InvokeWithSocketParamsAndPool( |
384 request_url, request_extra_headers, request_load_flags, request_priority, | 441 request_url, request_extra_headers, request_load_flags, request_priority, |
385 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, | 442 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, |
386 ssl_config_for_origin, ssl_config_for_proxy, false, net_log, 0, | 443 ssl_config_for_origin, ssl_config_for_proxy, false, |
387 socket_handle, resolution_callback, callback); | 444 resolution_callback, socketRequest); |
388 } | 445 } |
389 | 446 |
390 int InitSocketHandleForRawConnect( | 447 int InitSocketHandleForRawConnect( |
391 const HostPortPair& host_port_pair, | 448 const HostPortPair& host_port_pair, |
392 HttpNetworkSession* session, | 449 HttpNetworkSession* session, |
393 const ProxyInfo& proxy_info, | 450 const ProxyInfo& proxy_info, |
394 const SSLConfig& ssl_config_for_origin, | 451 const SSLConfig& ssl_config_for_origin, |
395 const SSLConfig& ssl_config_for_proxy, | 452 const SSLConfig& ssl_config_for_proxy, |
396 const BoundNetLog& net_log, | 453 const BoundNetLog& net_log, |
397 ClientSocketHandle* socket_handle, | 454 ClientSocketHandle* socket_handle, |
398 const CompletionCallback& callback) { | 455 const CompletionCallback& callback) { |
399 DCHECK(socket_handle); | 456 DCHECK(socket_handle); |
| 457 |
| 458 RequestSocketForPool socketRequest(socket_handle, callback, net_log); |
| 459 |
400 // Synthesize an HttpRequestInfo. | 460 // Synthesize an HttpRequestInfo. |
401 GURL request_url = GURL("http://" + host_port_pair.ToString()); | 461 GURL request_url = GURL("http://" + host_port_pair.ToString()); |
402 HttpRequestHeaders request_extra_headers; | 462 HttpRequestHeaders request_extra_headers; |
403 int request_load_flags = 0; | 463 int request_load_flags = 0; |
404 RequestPriority request_priority = MEDIUM; | 464 RequestPriority request_priority = MEDIUM; |
405 | 465 |
406 return InitSocketPoolHelper( | 466 return InvokeWithSocketParamsAndPool( |
407 request_url, request_extra_headers, request_load_flags, request_priority, | 467 request_url, request_extra_headers, request_load_flags, request_priority, |
408 session, proxy_info, false, false, ssl_config_for_origin, | 468 session, proxy_info, false, false, |
409 ssl_config_for_proxy, true, net_log, 0, socket_handle, | 469 ssl_config_for_origin, ssl_config_for_proxy, true, |
410 OnHostResolutionCallback(), callback); | 470 OnHostResolutionCallback(), socketRequest); |
411 } | 471 } |
412 | 472 |
413 int PreconnectSocketsForHttpRequest( | 473 int PreconnectSocketsForHttpRequest( |
414 const GURL& request_url, | 474 const GURL& request_url, |
415 const HttpRequestHeaders& request_extra_headers, | 475 const HttpRequestHeaders& request_extra_headers, |
416 int request_load_flags, | 476 int request_load_flags, |
417 RequestPriority request_priority, | 477 RequestPriority request_priority, |
418 HttpNetworkSession* session, | 478 HttpNetworkSession* session, |
419 const ProxyInfo& proxy_info, | 479 const ProxyInfo& proxy_info, |
420 bool force_spdy_over_ssl, | 480 bool force_spdy_over_ssl, |
421 bool want_spdy_over_npn, | 481 bool want_spdy_over_npn, |
422 const SSLConfig& ssl_config_for_origin, | 482 const SSLConfig& ssl_config_for_origin, |
423 const SSLConfig& ssl_config_for_proxy, | 483 const SSLConfig& ssl_config_for_proxy, |
424 const BoundNetLog& net_log, | 484 const BoundNetLog& net_log, |
425 int num_preconnect_streams) { | 485 int num_preconnect_streams) { |
426 return InitSocketPoolHelper( | 486 RequestSocketsForPool socketsRequest(num_preconnect_streams, net_log); |
| 487 |
| 488 return InvokeWithSocketParamsAndPool( |
427 request_url, request_extra_headers, request_load_flags, request_priority, | 489 request_url, request_extra_headers, request_load_flags, request_priority, |
428 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, | 490 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, |
429 ssl_config_for_origin, ssl_config_for_proxy, false, net_log, | 491 ssl_config_for_origin, ssl_config_for_proxy, false, |
430 num_preconnect_streams, NULL, OnHostResolutionCallback(), | 492 OnHostResolutionCallback(), socketsRequest); |
431 CompletionCallback()); | |
432 } | 493 } |
433 | 494 |
434 } // namespace net | 495 } // namespace net |
OLD | NEW |