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

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

Issue 1808001: Implement a 15 connection per proxy server limit. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Remove extra newline. Created 10 years, 8 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <map>
8 #include "base/ref_counted.h" 9 #include "base/ref_counted.h"
9 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
11 #include "net/base/host_port_pair.h"
10 #include "net/base/host_resolver.h" 12 #include "net/base/host_resolver.h"
11 #include "net/base/ssl_client_auth_cache.h" 13 #include "net/base/ssl_client_auth_cache.h"
12 #include "net/base/ssl_config_service.h" 14 #include "net/base/ssl_config_service.h"
13 #include "net/http/http_alternate_protocols.h" 15 #include "net/http/http_alternate_protocols.h"
14 #include "net/http/http_auth_cache.h" 16 #include "net/http/http_auth_cache.h"
15 #include "net/proxy/proxy_service.h" 17 #include "net/proxy/proxy_service.h"
16 #include "net/socket/socks_client_socket_pool.h" 18 #include "net/socket/socks_client_socket_pool.h"
17 #include "net/socket/tcp_client_socket_pool.h" 19 #include "net/socket/tcp_client_socket_pool.h"
18 #include "net/spdy/spdy_settings_storage.h" 20 #include "net/spdy/spdy_settings_storage.h"
19 21
20 namespace net { 22 namespace net {
21 23
22 class ClientSocketFactory; 24 class ClientSocketFactory;
23 class HttpAuthHandlerFactory; 25 class HttpAuthHandlerFactory;
26 class HttpNetworkSessionPeer;
27 class NetworkChangeNotifier;
24 class SpdySessionPool; 28 class SpdySessionPool;
25 class NetworkChangeNotifier;
26 29
27 // This class holds session objects used by HttpNetworkTransaction objects. 30 // This class holds session objects used by HttpNetworkTransaction objects.
28 class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { 31 class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> {
29 public: 32 public:
30 HttpNetworkSession( 33 HttpNetworkSession(
31 NetworkChangeNotifier* network_change_notifier, 34 NetworkChangeNotifier* network_change_notifier,
32 HostResolver* host_resolver, 35 HostResolver* host_resolver,
33 ProxyService* proxy_service, 36 ProxyService* proxy_service,
34 ClientSocketFactory* client_socket_factory, 37 ClientSocketFactory* client_socket_factory,
35 SSLConfigService* ssl_config_service, 38 SSLConfigService* ssl_config_service,
(...skipping 17 matching lines...) Expand all
53 return spdy_settings_; 56 return spdy_settings_;
54 } 57 }
55 SpdySettingsStorage* mutable_spdy_settings() { 58 SpdySettingsStorage* mutable_spdy_settings() {
56 return &spdy_settings_; 59 return &spdy_settings_;
57 } 60 }
58 61
59 // TCP sockets come from the tcp_socket_pool(). 62 // TCP sockets come from the tcp_socket_pool().
60 const scoped_refptr<TCPClientSocketPool>& tcp_socket_pool() { 63 const scoped_refptr<TCPClientSocketPool>& tcp_socket_pool() {
61 return tcp_socket_pool_; 64 return tcp_socket_pool_;
62 } 65 }
63 const scoped_refptr<SOCKSClientSocketPool>& socks_socket_pool() { 66
64 return socks_socket_pool_; 67 const scoped_refptr<SOCKSClientSocketPool>& GetSocketPoolForSOCKSProxy(
65 } 68 const HostPortPair& socks_proxy);
69
70 const scoped_refptr<TCPClientSocketPool>& GetSocketPoolForHTTPProxy(
71 const HostPortPair& http_proxy);
72
66 // SSL sockets come from the socket_factory(). 73 // SSL sockets come from the socket_factory().
67 ClientSocketFactory* socket_factory() { return socket_factory_; } 74 ClientSocketFactory* socket_factory() { return socket_factory_; }
68 HostResolver* host_resolver() { return host_resolver_; } 75 HostResolver* host_resolver() { return host_resolver_; }
69 ProxyService* proxy_service() { return proxy_service_; } 76 ProxyService* proxy_service() { return proxy_service_; }
70 SSLConfigService* ssl_config_service() { return ssl_config_service_; } 77 SSLConfigService* ssl_config_service() { return ssl_config_service_; }
71 const scoped_refptr<SpdySessionPool>& spdy_session_pool() { 78 const scoped_refptr<SpdySessionPool>& spdy_session_pool() {
72 return spdy_session_pool_; 79 return spdy_session_pool_;
73 } 80 }
74 HttpAuthHandlerFactory* http_auth_handler_factory() { 81 HttpAuthHandlerFactory* http_auth_handler_factory() {
75 return http_auth_handler_factory_; 82 return http_auth_handler_factory_;
76 } 83 }
77 84
78 // Replace the current socket pool with a new one. This effectively 85 // Replace the current socket pool with a new one. This effectively
79 // abandons the current pool. This is only used for debugging. 86 // abandons the current pool. This is only used for debugging.
80 void ReplaceTCPSocketPool(); 87 void ReplaceTCPSocketPool();
81 88
82 static void set_max_sockets_per_group(int socket_count); 89 static void set_max_sockets_per_group(int socket_count);
83 90
84 static uint16 fixed_http_port() { return g_fixed_http_port; } 91 static uint16 fixed_http_port();
85 static void set_fixed_http_port(uint16 port) { g_fixed_http_port = port; } 92 static void set_fixed_http_port(uint16 port);
86 93
87 static uint16 fixed_https_port() { return g_fixed_https_port; } 94 static uint16 fixed_https_port();
88 static void set_fixed_https_port(uint16 port) { g_fixed_https_port = port; } 95 static void set_fixed_https_port(uint16 port);
89 96
90 private: 97 private:
98 typedef std::map<HostPortPair, scoped_refptr<TCPClientSocketPool> >
99 HTTPProxySocketPoolMap;
100 typedef std::map<HostPortPair, scoped_refptr<SOCKSClientSocketPool> >
101 SOCKSSocketPoolMap;
102
91 friend class base::RefCounted<HttpNetworkSession>; 103 friend class base::RefCounted<HttpNetworkSession>;
92 FRIEND_TEST(HttpNetworkTransactionTest, GroupNameForProxyConnections); 104 friend class HttpNetworkSessionPeer;
93 105
94 ~HttpNetworkSession(); 106 ~HttpNetworkSession();
95 107
96 // Total limit of sockets. Not a constant to allow experiments.
97 static int max_sockets_;
98
99 // Default to allow up to 6 connections per host. Experiment and tuning may
100 // try other values (greater than 0). Too large may cause many problems, such
101 // as home routers blocking the connections!?!?
102 static int max_sockets_per_group_;
103
104 static uint16 g_fixed_http_port;
105 static uint16 g_fixed_https_port;
106
107 HttpAuthCache auth_cache_; 108 HttpAuthCache auth_cache_;
108 SSLClientAuthCache ssl_client_auth_cache_; 109 SSLClientAuthCache ssl_client_auth_cache_;
109 HttpAlternateProtocols alternate_protocols_; 110 HttpAlternateProtocols alternate_protocols_;
110 NetworkChangeNotifier* const network_change_notifier_; 111 NetworkChangeNotifier* const network_change_notifier_;
111 scoped_refptr<TCPClientSocketPool> tcp_socket_pool_; 112 scoped_refptr<TCPClientSocketPool> tcp_socket_pool_;
112 scoped_refptr<SOCKSClientSocketPool> socks_socket_pool_; 113 HTTPProxySocketPoolMap http_proxy_socket_pool_;
114 SOCKSSocketPoolMap socks_socket_pool_;
113 ClientSocketFactory* socket_factory_; 115 ClientSocketFactory* socket_factory_;
114 scoped_refptr<HostResolver> host_resolver_; 116 scoped_refptr<HostResolver> host_resolver_;
115 scoped_refptr<ProxyService> proxy_service_; 117 scoped_refptr<ProxyService> proxy_service_;
116 scoped_refptr<SSLConfigService> ssl_config_service_; 118 scoped_refptr<SSLConfigService> ssl_config_service_;
117 scoped_refptr<SpdySessionPool> spdy_session_pool_; 119 scoped_refptr<SpdySessionPool> spdy_session_pool_;
118 HttpAuthHandlerFactory* http_auth_handler_factory_; 120 HttpAuthHandlerFactory* http_auth_handler_factory_;
119 SpdySettingsStorage spdy_settings_; 121 SpdySettingsStorage spdy_settings_;
120 }; 122 };
121 123
122 } // namespace net 124 } // namespace net
123 125
124 #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_ 126 #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698