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 11 matching lines...) Expand all Loading... |
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 static_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 static_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 static_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, |
71 int request_load_flags, | 71 int request_load_flags, |
72 RequestPriority request_priority, | 72 RequestPriority request_priority, |
73 HttpNetworkSession* session, | 73 HttpNetworkSession* session, |
74 const ProxyInfo& proxy_info, | 74 const ProxyInfo& proxy_info, |
75 bool force_spdy_over_ssl, | 75 bool force_spdy_over_ssl, |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 int num_preconnect_streams) { | 506 int num_preconnect_streams) { |
507 return InitSocketPoolHelper( | 507 return InitSocketPoolHelper( |
508 request_url, request_extra_headers, request_load_flags, request_priority, | 508 request_url, request_extra_headers, request_load_flags, request_priority, |
509 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, | 509 session, proxy_info, force_spdy_over_ssl, want_spdy_over_npn, |
510 ssl_config_for_origin, ssl_config_for_proxy, false, privacy_mode, net_log, | 510 ssl_config_for_origin, ssl_config_for_proxy, false, privacy_mode, net_log, |
511 num_preconnect_streams, NULL, HttpNetworkSession::NORMAL_SOCKET_POOL, | 511 num_preconnect_streams, NULL, HttpNetworkSession::NORMAL_SOCKET_POOL, |
512 OnHostResolutionCallback(), CompletionCallback()); | 512 OnHostResolutionCallback(), CompletionCallback()); |
513 } | 513 } |
514 | 514 |
515 } // namespace net | 515 } // namespace net |
OLD | NEW |