Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: net/http/http_network_session.h

Issue 149027: Limit total number of sockets in the system.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: reorder Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | net/http/http_network_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 #ifndef NET_HTTP_HTTP_NETWORK_SESSION_H_ 5 #ifndef NET_HTTP_HTTP_NETWORK_SESSION_H_
6 #define NET_HTTP_HTTP_NETWORK_SESSION_H_ 6 #define NET_HTTP_HTTP_NETWORK_SESSION_H_
7 7
8 #include "base/logging.h"
9 #include "base/ref_counted.h" 8 #include "base/ref_counted.h"
10 #include "net/base/ssl_client_auth_cache.h" 9 #include "net/base/ssl_client_auth_cache.h"
11 #include "net/base/ssl_config_service.h" 10 #include "net/base/ssl_config_service.h"
12 #include "net/http/http_auth_cache.h" 11 #include "net/http/http_auth_cache.h"
13 #include "net/socket/tcp_client_socket_pool.h" 12 #include "net/socket/tcp_client_socket_pool.h"
14 13
15 namespace net { 14 namespace net {
16 15
17 class ClientSocketFactory; 16 class ClientSocketFactory;
18 class HostResolver; 17 class HostResolver;
19 class ProxyService; 18 class ProxyService;
20 19
21 // This class holds session objects used by HttpNetworkTransaction objects. 20 // This class holds session objects used by HttpNetworkTransaction objects.
22 class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { 21 class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
23 public: 22 public:
24 HttpNetworkSession(HostResolver* host_resolver, ProxyService* proxy_service, 23 HttpNetworkSession(HostResolver* host_resolver, ProxyService* proxy_service,
25 ClientSocketFactory* client_socket_factory) 24 ClientSocketFactory* client_socket_factory);
26 : connection_pool_(new TCPClientSocketPool(
27 max_sockets_per_group_, host_resolver, client_socket_factory)),
28 host_resolver_(host_resolver),
29 proxy_service_(proxy_service) {
30 DCHECK(proxy_service);
31 }
32 25
33 HttpAuthCache* auth_cache() { return &auth_cache_; } 26 HttpAuthCache* auth_cache() { return &auth_cache_; }
34 SSLClientAuthCache* ssl_client_auth_cache() { 27 SSLClientAuthCache* ssl_client_auth_cache() {
35 return &ssl_client_auth_cache_; 28 return &ssl_client_auth_cache_;
36 } 29 }
37 ClientSocketPool* connection_pool() { return connection_pool_; } 30 ClientSocketPool* connection_pool() { return connection_pool_; }
38 HostResolver* host_resolver() { return host_resolver_; } 31 HostResolver* host_resolver() { return host_resolver_; }
39 ProxyService* proxy_service() { return proxy_service_; } 32 ProxyService* proxy_service() { return proxy_service_; }
40 #if defined(OS_WIN) 33 #if defined(OS_WIN)
41 SSLConfigService* ssl_config_service() { return &ssl_config_service_; } 34 SSLConfigService* ssl_config_service() { return &ssl_config_service_; }
42 #endif 35 #endif
43 36
44 static void set_max_sockets_per_group(int socket_count); 37 static void set_max_sockets_per_group(int socket_count);
45 38
46 private: 39 private:
47 FRIEND_TEST(HttpNetworkTransactionTest, GroupNameForProxyConnections); 40 FRIEND_TEST(HttpNetworkTransactionTest, GroupNameForProxyConnections);
48 41
42 // Total limit of sockets. Not a constant to allow experiments.
43 static int max_sockets_;
44
49 // Default to allow up to 6 connections per host. Experiment and tuning may 45 // Default to allow up to 6 connections per host. Experiment and tuning may
50 // try other values (greater than 0). Too large may cause many problems, such 46 // try other values (greater than 0). Too large may cause many problems, such
51 // as home routers blocking the connections!?!? 47 // as home routers blocking the connections!?!?
52 static int max_sockets_per_group_; 48 static int max_sockets_per_group_;
53 49
54 HttpAuthCache auth_cache_; 50 HttpAuthCache auth_cache_;
55 SSLClientAuthCache ssl_client_auth_cache_; 51 SSLClientAuthCache ssl_client_auth_cache_;
56 scoped_refptr<ClientSocketPool> connection_pool_; 52 scoped_refptr<ClientSocketPool> connection_pool_;
57 scoped_refptr<HostResolver> host_resolver_; 53 scoped_refptr<HostResolver> host_resolver_;
58 ProxyService* proxy_service_; 54 ProxyService* proxy_service_;
59 #if defined(OS_WIN) 55 #if defined(OS_WIN)
60 // TODO(port): Port the SSLConfigService class to Linux and Mac OS X. 56 // TODO(port): Port the SSLConfigService class to Linux and Mac OS X.
61 SSLConfigService ssl_config_service_; 57 SSLConfigService ssl_config_service_;
62 #endif 58 #endif
63 }; 59 };
64 60
65 } // namespace net 61 } // namespace net
66 62
67 #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_ 63 #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_
OLDNEW
« no previous file with comments | « no previous file | net/http/http_network_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698