Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // ClientSocketPoolManager manages access to all ClientSocketPools. It's a | 5 // ClientSocketPoolManager manages access to all ClientSocketPools. It's a |
| 6 // simple container for all of them. Most importantly, it handles the lifetime | 6 // simple container for all of them. Most importantly, it handles the lifetime |
| 7 // and destruction order properly. | 7 // and destruction order properly. |
| 8 | 8 |
| 9 #include "net/socket/client_socket_pool_manager.h" | 9 #include "net/socket/client_socket_pool_manager.h" |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "net/base/ssl_config_service.h" | 16 #include "net/base/ssl_config_service.h" |
| 17 #include "net/http/http_network_session.h" | 17 #include "net/http/http_network_session.h" |
| 18 #include "net/http/http_proxy_client_socket_pool.h" | 18 #include "net/http/http_proxy_client_socket_pool.h" |
| 19 #include "net/http/http_request_info.h" | 19 #include "net/http/http_request_info.h" |
| 20 #include "net/proxy/proxy_service.h" | 20 #include "net/proxy/proxy_service.h" |
| 21 #include "net/socket/client_socket_factory.h" | 21 #include "net/socket/client_socket_factory.h" |
| 22 #include "net/socket/client_socket_handle.h" | 22 #include "net/socket/client_socket_handle.h" |
| 23 #include "net/socket/client_socket_pool_histograms.h" | 23 #include "net/socket/client_socket_pool_histograms.h" |
| 24 #include "net/socket/socks_client_socket_pool.h" | 24 #include "net/socket/socks_client_socket_pool.h" |
| 25 #include "net/socket/ssl_client_socket_pool.h" | 25 #include "net/socket/ssl_client_socket_pool.h" |
| 26 #include "net/socket/transport_client_socket_pool.h" | 26 #include "net/socket/transport_client_socket_pool.h" |
| 27 | 27 |
| 28 namespace net { | 28 namespace net { |
| 29 | 29 |
| 30 const int kDefaultMaxSocketsPerProxyServer = 32; | |
| 31 | |
| 30 namespace { | 32 namespace { |
| 31 | 33 |
| 32 // Total limit of sockets. | 34 // Total limit of sockets. |
| 33 int g_max_sockets = 256; | 35 int g_max_sockets = 256; |
| 34 | 36 |
| 35 // Default to allow up to 6 connections per host. Experiment and tuning may | 37 // Default to allow up to 6 connections per host. Experiment and tuning may |
| 36 // try other values (greater than 0). Too large may cause many problems, such | 38 // try other values (greater than 0). Too large may cause many problems, such |
| 37 // as home routers blocking the connections!?!? See http://crbug.com/12066. | 39 // as home routers blocking the connections!?!? See http://crbug.com/12066. |
| 38 int g_max_sockets_per_group = 6; | 40 int g_max_sockets_per_group = 6; |
| 39 | 41 |
| 40 // The max number of sockets to allow per proxy server. This applies both to | 42 // The max number of sockets to allow per proxy server. This applies both to |
| 41 // http and SOCKS proxies. See http://crbug.com/12066 and | 43 // http and SOCKS proxies. See http://crbug.com/12066 and |
| 42 // http://crbug.com/44501 for details about proxy server connection limits. | 44 // http://crbug.com/44501 for details about proxy server connection limits. |
| 43 int g_max_sockets_per_proxy_server = 32; | 45 int g_max_sockets_per_proxy_server = kDefaultMaxSocketsPerProxyServer; |
| 44 | 46 |
| 45 // Appends information about all |socket_pools| to the end of |list|. | 47 // Appends information about all |socket_pools| to the end of |list|. |
| 46 template <class MapType> | 48 template <class MapType> |
| 47 static void AddSocketPoolsToList(ListValue* list, | 49 static void AddSocketPoolsToList(ListValue* list, |
| 48 const MapType& socket_pools, | 50 const MapType& socket_pools, |
| 49 const std::string& type, | 51 const std::string& type, |
| 50 bool include_nested_pools) { | 52 bool include_nested_pools) { |
| 51 for (typename MapType::const_iterator it = socket_pools.begin(); | 53 for (typename MapType::const_iterator it = socket_pools.begin(); |
| 52 it != socket_pools.end(); it++) { | 54 it != socket_pools.end(); it++) { |
| 53 list->Append(it->second->GetInfoAsValue(it->first.ToString(), | 55 list->Append(it->second->GetInfoAsValue(it->first.ToString(), |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 560 | 562 |
| 561 // static | 563 // static |
| 562 void ClientSocketPoolManager::set_max_sockets_per_proxy_server( | 564 void ClientSocketPoolManager::set_max_sockets_per_proxy_server( |
| 563 int socket_count) { | 565 int socket_count) { |
| 564 DCHECK_LT(0, socket_count); | 566 DCHECK_LT(0, socket_count); |
| 565 DCHECK_GT(100, socket_count); // Sanity check. | 567 DCHECK_GT(100, socket_count); // Sanity check. |
| 566 // Assert this case early on. The max number of sockets per group cannot | 568 // Assert this case early on. The max number of sockets per group cannot |
| 567 // exceed the max number of sockets per proxy server. | 569 // exceed the max number of sockets per proxy server. |
| 568 DCHECK_LE(g_max_sockets_per_group, socket_count); | 570 DCHECK_LE(g_max_sockets_per_group, socket_count); |
| 569 g_max_sockets_per_proxy_server = socket_count; | 571 g_max_sockets_per_proxy_server = socket_count; |
| 572 LOG(ERROR) << "### Set the count to : " << socket_count; | |
|
willchan no longer on Chromium
2011/07/07 17:22:04
I presume this is for debugging. If so, please kil
pastarmovj
2011/07/08 10:49:39
Done.
| |
| 570 } | 573 } |
| 571 | 574 |
| 572 Value* ClientSocketPoolManager::SocketPoolInfoToValue() const { | 575 Value* ClientSocketPoolManager::SocketPoolInfoToValue() const { |
| 573 ListValue* list = new ListValue(); | 576 ListValue* list = new ListValue(); |
| 574 list->Append(transport_socket_pool_->GetInfoAsValue("transport_socket_pool", | 577 list->Append(transport_socket_pool_->GetInfoAsValue("transport_socket_pool", |
| 575 "transport_socket_pool", | 578 "transport_socket_pool", |
| 576 false)); | 579 false)); |
| 577 // Third parameter is false because |ssl_socket_pool_| uses | 580 // Third parameter is false because |ssl_socket_pool_| uses |
| 578 // |transport_socket_pool_| internally, and do not want to add it a second | 581 // |transport_socket_pool_| internally, and do not want to add it a second |
| 579 // time. | 582 // time. |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 709 ssl_config_for_proxy, | 712 ssl_config_for_proxy, |
| 710 false, | 713 false, |
| 711 net_log, | 714 net_log, |
| 712 num_preconnect_streams, | 715 num_preconnect_streams, |
| 713 NULL, | 716 NULL, |
| 714 NULL); | 717 NULL); |
| 715 } | 718 } |
| 716 | 719 |
| 717 | 720 |
| 718 } // namespace net | 721 } // namespace net |
| OLD | NEW |