| 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" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "net/base/load_flags.h" | 12 #include "net/base/load_flags.h" |
| 13 #include "net/http/http_proxy_client_socket_pool.h" | 13 #include "net/http/http_proxy_client_socket_pool.h" |
| 14 #include "net/http/http_request_info.h" | 14 #include "net/http/http_request_info.h" |
| 15 #include "net/http/http_stream_factory.h" | 15 #include "net/http/http_stream_factory.h" |
| 16 #include "net/proxy/proxy_info.h" | 16 #include "net/proxy/proxy_info.h" |
| 17 #include "net/socket/client_socket_handle.h" | 17 #include "net/socket/client_socket_handle.h" |
| 18 #include "net/socket/socks_client_socket_pool.h" | 18 #include "net/socket/socks_client_socket_pool.h" |
| 19 #include "net/socket/ssl_client_socket_pool.h" | 19 #include "net/socket/ssl_client_socket_pool.h" |
| 20 #include "net/socket/transport_client_socket_pool.h" | 20 #include "net/socket/transport_client_socket_pool.h" |
| 21 | 21 |
| 22 namespace net { | 22 namespace net { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 // Limit of sockets of each socket pool. | 26 // Limit of sockets of each socket pool. |
| 27 int g_max_sockets_per_pool[] = { | 27 int g_max_sockets_per_pool[] = { |
| 28 256, // NORMAL_SOCKET_POOL | 28 256, // NORMAL_SOCKET_POOL |
| 29 256 // WEBSOCKET_SOCKET_POOL | 29 256 // WEBSOCKET_SOCKET_POOL |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 COMPILE_ASSERT(arraysize(g_max_sockets_per_pool) == | 32 COMPILE_ASSERT(arraysize(g_max_sockets_per_pool) == |
| 33 HttpNetworkSession::NUM_SOCKET_POOL_TYPES, | 33 HttpNetworkSession::NUM_SOCKET_POOL_TYPES, |
| 34 max_sockets_per_pool_length_mismatch); | 34 max_sockets_per_pool_length_mismatch); |
| 35 | 35 |
| 36 // Default to allow up to 6 connections per host. Experiment and tuning may | 36 // Default to allow up to 6 connections per host. Experiment and tuning may |
| 37 // try other values (greater than 0). Too large may cause many problems, such | 37 // try other values (greater than 0). Too large may cause many problems, such |
| 38 // as home routers blocking the connections!?!? See http://crbug.com/12066. | 38 // as home routers blocking the connections!?!? See http://crbug.com/12066. |
| 39 // | 39 // |
| 40 // WebSocket connections are long-lived, and should be treated differently | 40 // WebSocket connections are long-lived, and should be treated differently |
| 41 // than normal other connections. 6 connections per group sounded too small | 41 // than normal other connections. 6 connections per group sounded too small |
| 42 // for such use, thus we use a larger limit which was determined somewhat | 42 // for such use, thus we use a larger limit which was determined somewhat |
| 43 // arbitrarily. | 43 // arbitrarily. |
| 44 // TODO(yutak): Look at the usage and determine the right value after | 44 // TODO(yutak): Look at the usage and determine the right value after |
| 45 // WebSocket protocol stack starts to work. | 45 // WebSocket protocol stack starts to work. |
| 46 int g_max_sockets_per_group[] = { | 46 int g_max_sockets_per_group[] = { |
| 47 6, // NORMAL_SOCKET_POOL | 47 6, // NORMAL_SOCKET_POOL |
| 48 30 // WEBSOCKET_SOCKET_POOL | 48 30 // WEBSOCKET_SOCKET_POOL |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 COMPILE_ASSERT(arraysize(g_max_sockets_per_group) == | 51 COMPILE_ASSERT(arraysize(g_max_sockets_per_group) == |
| 52 HttpNetworkSession::NUM_SOCKET_POOL_TYPES, | 52 HttpNetworkSession::NUM_SOCKET_POOL_TYPES, |
| 53 max_sockets_per_group_length_mismatch); | 53 max_sockets_per_group_length_mismatch); |
| 54 | 54 |
| 55 // The max number of sockets to allow per proxy server. This applies both to | 55 // The max number of sockets to allow per proxy server. This applies both to |
| 56 // http and SOCKS proxies. See http://crbug.com/12066 and | 56 // http and SOCKS proxies. See http://crbug.com/12066 and |
| 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 // The meat of the implementation for the InitSocketHandleForHttpRequest, |
| 68 // InitSocketHandleForRawConnect and PreconnectSocketsForHttpRequest methods. | 68 // InitSocketHandleForRawConnect and PreconnectSocketsForHttpRequest methods. |
| 69 int InitSocketPoolHelper(const GURL& request_url, | 69 int InitSocketPoolHelper(const GURL& request_url, |
| 70 const HttpRequestHeaders& request_extra_headers, | 70 const HttpRequestHeaders& request_extra_headers, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 83 ClientSocketHandle* socket_handle, | 83 ClientSocketHandle* socket_handle, |
| 84 HttpNetworkSession::SocketPoolType socket_pool_type, | 84 HttpNetworkSession::SocketPoolType socket_pool_type, |
| 85 const OnHostResolutionCallback& resolution_callback, | 85 const OnHostResolutionCallback& resolution_callback, |
| 86 const CompletionCallback& callback) { | 86 const CompletionCallback& callback) { |
| 87 scoped_refptr<TransportSocketParams> tcp_params; | 87 scoped_refptr<TransportSocketParams> tcp_params; |
| 88 scoped_refptr<HttpProxySocketParams> http_proxy_params; | 88 scoped_refptr<HttpProxySocketParams> http_proxy_params; |
| 89 scoped_refptr<SOCKSSocketParams> socks_params; | 89 scoped_refptr<SOCKSSocketParams> socks_params; |
| 90 scoped_ptr<HostPortPair> proxy_host_port; | 90 scoped_ptr<HostPortPair> proxy_host_port; |
| 91 | 91 |
| 92 bool using_ssl = request_url.SchemeIs("https") || | 92 bool using_ssl = request_url.SchemeIs("https") || |
| 93 request_url.SchemeIs("wss") || force_spdy_over_ssl; | 93 request_url.SchemeIs("wss") || force_spdy_over_ssl; |
| 94 | 94 |
| 95 HostPortPair origin_host_port = | 95 HostPortPair origin_host_port = HostPortPair(request_url.HostNoBrackets(), |
| 96 HostPortPair(request_url.HostNoBrackets(), | 96 request_url.EffectiveIntPort()); |
| 97 request_url.EffectiveIntPort()); | |
| 98 | 97 |
| 99 if (!using_ssl && session->params().testing_fixed_http_port != 0) { | 98 if (!using_ssl && session->params().testing_fixed_http_port != 0) { |
| 100 origin_host_port.set_port(session->params().testing_fixed_http_port); | 99 origin_host_port.set_port(session->params().testing_fixed_http_port); |
| 101 } else if (using_ssl && session->params().testing_fixed_https_port != 0) { | 100 } else if (using_ssl && session->params().testing_fixed_https_port != 0) { |
| 102 origin_host_port.set_port(session->params().testing_fixed_https_port); | 101 origin_host_port.set_port(session->params().testing_fixed_https_port); |
| 103 } | 102 } |
| 104 | 103 |
| 105 bool disable_resolver_cache = | 104 bool disable_resolver_cache = request_load_flags & LOAD_BYPASS_CACHE || |
| 106 request_load_flags & LOAD_BYPASS_CACHE || | 105 request_load_flags & LOAD_VALIDATE_CACHE || |
| 107 request_load_flags & LOAD_VALIDATE_CACHE || | 106 request_load_flags & LOAD_DISABLE_CACHE; |
| 108 request_load_flags & LOAD_DISABLE_CACHE; | |
| 109 | 107 |
| 110 int load_flags = request_load_flags; | 108 int load_flags = request_load_flags; |
| 111 if (session->params().ignore_certificate_errors) | 109 if (session->params().ignore_certificate_errors) |
| 112 load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS; | 110 load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS; |
| 113 | 111 |
| 114 // Build the string used to uniquely identify connections of this type. | 112 // Build the string used to uniquely identify connections of this type. |
| 115 // Determine the host and port to connect to. | 113 // Determine the host and port to connect to. |
| 116 std::string connection_group = origin_host_port.ToString(); | 114 std::string connection_group = origin_host_port.ToString(); |
| 117 DCHECK(!connection_group.empty()); | 115 DCHECK(!connection_group.empty()); |
| 118 if (request_url.SchemeIs("ftp")) { | 116 if (request_url.SchemeIs("ftp")) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 } else { | 199 } else { |
| 202 DCHECK(proxy_info.is_socks()); | 200 DCHECK(proxy_info.is_socks()); |
| 203 char socks_version; | 201 char socks_version; |
| 204 if (proxy_server.scheme() == ProxyServer::SCHEME_SOCKS5) | 202 if (proxy_server.scheme() == ProxyServer::SCHEME_SOCKS5) |
| 205 socks_version = '5'; | 203 socks_version = '5'; |
| 206 else | 204 else |
| 207 socks_version = '4'; | 205 socks_version = '4'; |
| 208 connection_group = base::StringPrintf( | 206 connection_group = base::StringPrintf( |
| 209 "socks%c/%s", socks_version, connection_group.c_str()); | 207 "socks%c/%s", socks_version, connection_group.c_str()); |
| 210 | 208 |
| 211 socks_params = new SOCKSSocketParams(proxy_tcp_params, | 209 socks_params = new SOCKSSocketParams( |
| 212 socks_version == '5', | 210 proxy_tcp_params, socks_version == '5', origin_host_port); |
| 213 origin_host_port); | |
| 214 } | 211 } |
| 215 } | 212 } |
| 216 | 213 |
| 217 // Change group name if privacy mode is enabled. | 214 // Change group name if privacy mode is enabled. |
| 218 if (privacy_mode == PRIVACY_MODE_ENABLED) | 215 if (privacy_mode == PRIVACY_MODE_ENABLED) |
| 219 connection_group = "pm/" + connection_group; | 216 connection_group = "pm/" + connection_group; |
| 220 | 217 |
| 221 // Deal with SSL - which layers on top of any given proxy. | 218 // Deal with SSL - which layers on top of any given proxy. |
| 222 if (using_ssl) { | 219 if (using_ssl) { |
| 223 scoped_refptr<SSLSocketParams> ssl_params = | 220 scoped_refptr<SSLSocketParams> ssl_params = |
| 224 new SSLSocketParams(tcp_params, | 221 new SSLSocketParams(tcp_params, |
| 225 socks_params, | 222 socks_params, |
| 226 http_proxy_params, | 223 http_proxy_params, |
| 227 origin_host_port, | 224 origin_host_port, |
| 228 ssl_config_for_origin, | 225 ssl_config_for_origin, |
| 229 privacy_mode, | 226 privacy_mode, |
| 230 load_flags, | 227 load_flags, |
| 231 force_spdy_over_ssl, | 228 force_spdy_over_ssl, |
| 232 want_spdy_over_npn); | 229 want_spdy_over_npn); |
| 233 SSLClientSocketPool* ssl_pool = NULL; | 230 SSLClientSocketPool* ssl_pool = NULL; |
| 234 if (proxy_info.is_direct()) { | 231 if (proxy_info.is_direct()) { |
| 235 ssl_pool = session->GetSSLSocketPool(socket_pool_type); | 232 ssl_pool = session->GetSSLSocketPool(socket_pool_type); |
| 236 } else { | 233 } else { |
| 237 ssl_pool = session->GetSocketPoolForSSLWithProxy(socket_pool_type, | 234 ssl_pool = session->GetSocketPoolForSSLWithProxy(socket_pool_type, |
| 238 *proxy_host_port); | 235 *proxy_host_port); |
| 239 } | 236 } |
| 240 | 237 |
| 241 if (num_preconnect_streams) { | 238 if (num_preconnect_streams) { |
| 242 RequestSocketsForPool(ssl_pool, connection_group, ssl_params, | 239 RequestSocketsForPool(ssl_pool, |
| 243 num_preconnect_streams, net_log); | 240 connection_group, |
| 241 ssl_params, |
| 242 num_preconnect_streams, |
| 243 net_log); |
| 244 return OK; | 244 return OK; |
| 245 } | 245 } |
| 246 | 246 |
| 247 return socket_handle->Init(connection_group, ssl_params, | 247 return socket_handle->Init(connection_group, |
| 248 request_priority, callback, ssl_pool, | 248 ssl_params, |
| 249 request_priority, |
| 250 callback, |
| 251 ssl_pool, |
| 249 net_log); | 252 net_log); |
| 250 } | 253 } |
| 251 | 254 |
| 252 // Finally, get the connection started. | 255 // Finally, get the connection started. |
| 253 | 256 |
| 254 if (proxy_info.is_http() || proxy_info.is_https()) { | 257 if (proxy_info.is_http() || proxy_info.is_https()) { |
| 255 HttpProxyClientSocketPool* pool = | 258 HttpProxyClientSocketPool* pool = |
| 256 session->GetSocketPoolForHTTPProxy(socket_pool_type, *proxy_host_port); | 259 session->GetSocketPoolForHTTPProxy(socket_pool_type, *proxy_host_port); |
| 257 if (num_preconnect_streams) { | 260 if (num_preconnect_streams) { |
| 258 RequestSocketsForPool(pool, connection_group, http_proxy_params, | 261 RequestSocketsForPool(pool, |
| 259 num_preconnect_streams, net_log); | 262 connection_group, |
| 263 http_proxy_params, |
| 264 num_preconnect_streams, |
| 265 net_log); |
| 260 return OK; | 266 return OK; |
| 261 } | 267 } |
| 262 | 268 |
| 263 return socket_handle->Init(connection_group, http_proxy_params, | 269 return socket_handle->Init(connection_group, |
| 264 request_priority, callback, | 270 http_proxy_params, |
| 265 pool, net_log); | 271 request_priority, |
| 272 callback, |
| 273 pool, |
| 274 net_log); |
| 266 } | 275 } |
| 267 | 276 |
| 268 if (proxy_info.is_socks()) { | 277 if (proxy_info.is_socks()) { |
| 269 SOCKSClientSocketPool* pool = | 278 SOCKSClientSocketPool* pool = |
| 270 session->GetSocketPoolForSOCKSProxy(socket_pool_type, *proxy_host_port); | 279 session->GetSocketPoolForSOCKSProxy(socket_pool_type, *proxy_host_port); |
| 271 if (num_preconnect_streams) { | 280 if (num_preconnect_streams) { |
| 272 RequestSocketsForPool(pool, connection_group, socks_params, | 281 RequestSocketsForPool(pool, |
| 273 num_preconnect_streams, net_log); | 282 connection_group, |
| 283 socks_params, |
| 284 num_preconnect_streams, |
| 285 net_log); |
| 274 return OK; | 286 return OK; |
| 275 } | 287 } |
| 276 | 288 |
| 277 return socket_handle->Init(connection_group, socks_params, | 289 return socket_handle->Init(connection_group, |
| 278 request_priority, callback, pool, | 290 socks_params, |
| 291 request_priority, |
| 292 callback, |
| 293 pool, |
| 279 net_log); | 294 net_log); |
| 280 } | 295 } |
| 281 | 296 |
| 282 DCHECK(proxy_info.is_direct()); | 297 DCHECK(proxy_info.is_direct()); |
| 283 | 298 |
| 284 TransportClientSocketPool* pool = | 299 TransportClientSocketPool* pool = |
| 285 session->GetTransportSocketPool(socket_pool_type); | 300 session->GetTransportSocketPool(socket_pool_type); |
| 286 if (num_preconnect_streams) { | 301 if (num_preconnect_streams) { |
| 287 RequestSocketsForPool(pool, connection_group, tcp_params, | 302 RequestSocketsForPool( |
| 288 num_preconnect_streams, net_log); | 303 pool, connection_group, tcp_params, num_preconnect_streams, net_log); |
| 289 return OK; | 304 return OK; |
| 290 } | 305 } |
| 291 | 306 |
| 292 return socket_handle->Init(connection_group, tcp_params, | 307 return socket_handle->Init( |
| 293 request_priority, callback, | 308 connection_group, tcp_params, request_priority, callback, pool, net_log); |
| 294 pool, net_log); | |
| 295 } | 309 } |
| 296 | 310 |
| 297 } // namespace | 311 } // namespace |
| 298 | 312 |
| 299 ClientSocketPoolManager::ClientSocketPoolManager() {} | 313 ClientSocketPoolManager::ClientSocketPoolManager() { |
| 300 ClientSocketPoolManager::~ClientSocketPoolManager() {} | 314 } |
| 315 ClientSocketPoolManager::~ClientSocketPoolManager() { |
| 316 } |
| 301 | 317 |
| 302 // static | 318 // static |
| 303 int ClientSocketPoolManager::max_sockets_per_pool( | 319 int ClientSocketPoolManager::max_sockets_per_pool( |
| 304 HttpNetworkSession::SocketPoolType pool_type) { | 320 HttpNetworkSession::SocketPoolType pool_type) { |
| 305 DCHECK_LT(pool_type, HttpNetworkSession::NUM_SOCKET_POOL_TYPES); | 321 DCHECK_LT(pool_type, HttpNetworkSession::NUM_SOCKET_POOL_TYPES); |
| 306 return g_max_sockets_per_pool[pool_type]; | 322 return g_max_sockets_per_pool[pool_type]; |
| 307 } | 323 } |
| 308 | 324 |
| 309 // static | 325 // static |
| 310 void ClientSocketPoolManager::set_max_sockets_per_pool( | 326 void ClientSocketPoolManager::set_max_sockets_per_pool( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 bool force_spdy_over_ssl, | 387 bool force_spdy_over_ssl, |
| 372 bool want_spdy_over_npn, | 388 bool want_spdy_over_npn, |
| 373 const SSLConfig& ssl_config_for_origin, | 389 const SSLConfig& ssl_config_for_origin, |
| 374 const SSLConfig& ssl_config_for_proxy, | 390 const SSLConfig& ssl_config_for_proxy, |
| 375 PrivacyMode privacy_mode, | 391 PrivacyMode privacy_mode, |
| 376 const BoundNetLog& net_log, | 392 const BoundNetLog& net_log, |
| 377 ClientSocketHandle* socket_handle, | 393 ClientSocketHandle* socket_handle, |
| 378 const OnHostResolutionCallback& resolution_callback, | 394 const OnHostResolutionCallback& resolution_callback, |
| 379 const CompletionCallback& callback) { | 395 const CompletionCallback& callback) { |
| 380 DCHECK(socket_handle); | 396 DCHECK(socket_handle); |
| 381 return InitSocketPoolHelper( | 397 return InitSocketPoolHelper(request_url, |
| 382 request_url, request_extra_headers, request_load_flags, request_priority, | 398 request_extra_headers, |
| 383 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, | 399 request_load_flags, |
| 384 ssl_config_for_origin, ssl_config_for_proxy, false, privacy_mode, net_log, | 400 request_priority, |
| 385 0, socket_handle, HttpNetworkSession::NORMAL_SOCKET_POOL, | 401 session, |
| 386 resolution_callback, callback); | 402 proxy_info, |
| 403 force_spdy_over_ssl, |
| 404 want_spdy_over_npn, |
| 405 ssl_config_for_origin, |
| 406 ssl_config_for_proxy, |
| 407 false, |
| 408 privacy_mode, |
| 409 net_log, |
| 410 0, |
| 411 socket_handle, |
| 412 HttpNetworkSession::NORMAL_SOCKET_POOL, |
| 413 resolution_callback, |
| 414 callback); |
| 387 } | 415 } |
| 388 | 416 |
| 389 int InitSocketHandleForWebSocketRequest( | 417 int InitSocketHandleForWebSocketRequest( |
| 390 const GURL& request_url, | 418 const GURL& request_url, |
| 391 const HttpRequestHeaders& request_extra_headers, | 419 const HttpRequestHeaders& request_extra_headers, |
| 392 int request_load_flags, | 420 int request_load_flags, |
| 393 RequestPriority request_priority, | 421 RequestPriority request_priority, |
| 394 HttpNetworkSession* session, | 422 HttpNetworkSession* session, |
| 395 const ProxyInfo& proxy_info, | 423 const ProxyInfo& proxy_info, |
| 396 bool force_spdy_over_ssl, | 424 bool force_spdy_over_ssl, |
| 397 bool want_spdy_over_npn, | 425 bool want_spdy_over_npn, |
| 398 const SSLConfig& ssl_config_for_origin, | 426 const SSLConfig& ssl_config_for_origin, |
| 399 const SSLConfig& ssl_config_for_proxy, | 427 const SSLConfig& ssl_config_for_proxy, |
| 400 PrivacyMode privacy_mode, | 428 PrivacyMode privacy_mode, |
| 401 const BoundNetLog& net_log, | 429 const BoundNetLog& net_log, |
| 402 ClientSocketHandle* socket_handle, | 430 ClientSocketHandle* socket_handle, |
| 403 const OnHostResolutionCallback& resolution_callback, | 431 const OnHostResolutionCallback& resolution_callback, |
| 404 const CompletionCallback& callback) { | 432 const CompletionCallback& callback) { |
| 405 DCHECK(socket_handle); | 433 DCHECK(socket_handle); |
| 406 return InitSocketPoolHelper( | 434 return InitSocketPoolHelper(request_url, |
| 407 request_url, request_extra_headers, request_load_flags, request_priority, | 435 request_extra_headers, |
| 408 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, | 436 request_load_flags, |
| 409 ssl_config_for_origin, ssl_config_for_proxy, true, privacy_mode, net_log, | 437 request_priority, |
| 410 0, socket_handle, HttpNetworkSession::WEBSOCKET_SOCKET_POOL, | 438 session, |
| 411 resolution_callback, callback); | 439 proxy_info, |
| 440 force_spdy_over_ssl, |
| 441 want_spdy_over_npn, |
| 442 ssl_config_for_origin, |
| 443 ssl_config_for_proxy, |
| 444 true, |
| 445 privacy_mode, |
| 446 net_log, |
| 447 0, |
| 448 socket_handle, |
| 449 HttpNetworkSession::WEBSOCKET_SOCKET_POOL, |
| 450 resolution_callback, |
| 451 callback); |
| 412 } | 452 } |
| 413 | 453 |
| 414 int InitSocketHandleForRawConnect( | 454 int InitSocketHandleForRawConnect(const HostPortPair& host_port_pair, |
| 415 const HostPortPair& host_port_pair, | 455 HttpNetworkSession* session, |
| 416 HttpNetworkSession* session, | 456 const ProxyInfo& proxy_info, |
| 417 const ProxyInfo& proxy_info, | 457 const SSLConfig& ssl_config_for_origin, |
| 418 const SSLConfig& ssl_config_for_origin, | 458 const SSLConfig& ssl_config_for_proxy, |
| 419 const SSLConfig& ssl_config_for_proxy, | 459 PrivacyMode privacy_mode, |
| 420 PrivacyMode privacy_mode, | 460 const BoundNetLog& net_log, |
| 421 const BoundNetLog& net_log, | 461 ClientSocketHandle* socket_handle, |
| 422 ClientSocketHandle* socket_handle, | 462 const CompletionCallback& callback) { |
| 423 const CompletionCallback& callback) { | |
| 424 DCHECK(socket_handle); | 463 DCHECK(socket_handle); |
| 425 // Synthesize an HttpRequestInfo. | 464 // Synthesize an HttpRequestInfo. |
| 426 GURL request_url = GURL("http://" + host_port_pair.ToString()); | 465 GURL request_url = GURL("http://" + host_port_pair.ToString()); |
| 427 HttpRequestHeaders request_extra_headers; | 466 HttpRequestHeaders request_extra_headers; |
| 428 int request_load_flags = 0; | 467 int request_load_flags = 0; |
| 429 RequestPriority request_priority = MEDIUM; | 468 RequestPriority request_priority = MEDIUM; |
| 430 | 469 |
| 431 return InitSocketPoolHelper( | 470 return InitSocketPoolHelper(request_url, |
| 432 request_url, request_extra_headers, request_load_flags, request_priority, | 471 request_extra_headers, |
| 433 session, proxy_info, false, false, ssl_config_for_origin, | 472 request_load_flags, |
| 434 ssl_config_for_proxy, true, privacy_mode, net_log, 0, socket_handle, | 473 request_priority, |
| 435 HttpNetworkSession::NORMAL_SOCKET_POOL, OnHostResolutionCallback(), | 474 session, |
| 436 callback); | 475 proxy_info, |
| 476 false, |
| 477 false, |
| 478 ssl_config_for_origin, |
| 479 ssl_config_for_proxy, |
| 480 true, |
| 481 privacy_mode, |
| 482 net_log, |
| 483 0, |
| 484 socket_handle, |
| 485 HttpNetworkSession::NORMAL_SOCKET_POOL, |
| 486 OnHostResolutionCallback(), |
| 487 callback); |
| 437 } | 488 } |
| 438 | 489 |
| 439 int InitSocketHandleForTlsConnect( | 490 int InitSocketHandleForTlsConnect(const HostPortPair& host_port_pair, |
| 440 const HostPortPair& host_port_pair, | 491 HttpNetworkSession* session, |
| 441 HttpNetworkSession* session, | 492 const ProxyInfo& proxy_info, |
| 442 const ProxyInfo& proxy_info, | 493 const SSLConfig& ssl_config_for_origin, |
| 443 const SSLConfig& ssl_config_for_origin, | 494 const SSLConfig& ssl_config_for_proxy, |
| 444 const SSLConfig& ssl_config_for_proxy, | 495 PrivacyMode privacy_mode, |
| 445 PrivacyMode privacy_mode, | 496 const BoundNetLog& net_log, |
| 446 const BoundNetLog& net_log, | 497 ClientSocketHandle* socket_handle, |
| 447 ClientSocketHandle* socket_handle, | 498 const CompletionCallback& callback) { |
| 448 const CompletionCallback& callback) { | |
| 449 DCHECK(socket_handle); | 499 DCHECK(socket_handle); |
| 450 // Synthesize an HttpRequestInfo. | 500 // Synthesize an HttpRequestInfo. |
| 451 GURL request_url = GURL("https://" + host_port_pair.ToString()); | 501 GURL request_url = GURL("https://" + host_port_pair.ToString()); |
| 452 HttpRequestHeaders request_extra_headers; | 502 HttpRequestHeaders request_extra_headers; |
| 453 int request_load_flags = 0; | 503 int request_load_flags = 0; |
| 454 RequestPriority request_priority = MEDIUM; | 504 RequestPriority request_priority = MEDIUM; |
| 455 | 505 |
| 456 return InitSocketPoolHelper( | 506 return InitSocketPoolHelper(request_url, |
| 457 request_url, request_extra_headers, request_load_flags, request_priority, | 507 request_extra_headers, |
| 458 session, proxy_info, false, false, ssl_config_for_origin, | 508 request_load_flags, |
| 459 ssl_config_for_proxy, true, privacy_mode, net_log, 0, socket_handle, | 509 request_priority, |
| 460 HttpNetworkSession::NORMAL_SOCKET_POOL, OnHostResolutionCallback(), | 510 session, |
| 461 callback); | 511 proxy_info, |
| 512 false, |
| 513 false, |
| 514 ssl_config_for_origin, |
| 515 ssl_config_for_proxy, |
| 516 true, |
| 517 privacy_mode, |
| 518 net_log, |
| 519 0, |
| 520 socket_handle, |
| 521 HttpNetworkSession::NORMAL_SOCKET_POOL, |
| 522 OnHostResolutionCallback(), |
| 523 callback); |
| 462 } | 524 } |
| 463 | 525 |
| 464 int PreconnectSocketsForHttpRequest( | 526 int PreconnectSocketsForHttpRequest( |
| 465 const GURL& request_url, | 527 const GURL& request_url, |
| 466 const HttpRequestHeaders& request_extra_headers, | 528 const HttpRequestHeaders& request_extra_headers, |
| 467 int request_load_flags, | 529 int request_load_flags, |
| 468 RequestPriority request_priority, | 530 RequestPriority request_priority, |
| 469 HttpNetworkSession* session, | 531 HttpNetworkSession* session, |
| 470 const ProxyInfo& proxy_info, | 532 const ProxyInfo& proxy_info, |
| 471 bool force_spdy_over_ssl, | 533 bool force_spdy_over_ssl, |
| 472 bool want_spdy_over_npn, | 534 bool want_spdy_over_npn, |
| 473 const SSLConfig& ssl_config_for_origin, | 535 const SSLConfig& ssl_config_for_origin, |
| 474 const SSLConfig& ssl_config_for_proxy, | 536 const SSLConfig& ssl_config_for_proxy, |
| 475 PrivacyMode privacy_mode, | 537 PrivacyMode privacy_mode, |
| 476 const BoundNetLog& net_log, | 538 const BoundNetLog& net_log, |
| 477 int num_preconnect_streams) { | 539 int num_preconnect_streams) { |
| 478 return InitSocketPoolHelper( | 540 return InitSocketPoolHelper(request_url, |
| 479 request_url, request_extra_headers, request_load_flags, request_priority, | 541 request_extra_headers, |
| 480 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, | 542 request_load_flags, |
| 481 ssl_config_for_origin, ssl_config_for_proxy, false, privacy_mode, net_log, | 543 request_priority, |
| 482 num_preconnect_streams, NULL, HttpNetworkSession::NORMAL_SOCKET_POOL, | 544 session, |
| 483 OnHostResolutionCallback(), CompletionCallback()); | 545 proxy_info, |
| 546 force_spdy_over_ssl, |
| 547 want_spdy_over_npn, |
| 548 ssl_config_for_origin, |
| 549 ssl_config_for_proxy, |
| 550 false, |
| 551 privacy_mode, |
| 552 net_log, |
| 553 num_preconnect_streams, |
| 554 NULL, |
| 555 HttpNetworkSession::NORMAL_SOCKET_POOL, |
| 556 OnHostResolutionCallback(), |
| 557 CompletionCallback()); |
| 484 } | 558 } |
| 485 | 559 |
| 486 } // namespace net | 560 } // namespace net |
| OLD | NEW |