OLD | NEW |
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 "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "net/base/host_resolver.h" | 10 #include "net/base/host_resolver.h" |
11 #include "net/base/network_change_notifier.h" | |
12 #include "net/base/ssl_client_auth_cache.h" | 11 #include "net/base/ssl_client_auth_cache.h" |
13 #include "net/base/ssl_config_service.h" | 12 #include "net/base/ssl_config_service.h" |
14 #include "net/http/http_alternate_protocols.h" | 13 #include "net/http/http_alternate_protocols.h" |
15 #include "net/http/http_auth_cache.h" | 14 #include "net/http/http_auth_cache.h" |
16 #include "net/proxy/proxy_service.h" | 15 #include "net/proxy/proxy_service.h" |
17 #include "net/socket/socks_client_socket_pool.h" | 16 #include "net/socket/socks_client_socket_pool.h" |
18 #include "net/socket/tcp_client_socket_pool.h" | 17 #include "net/socket/tcp_client_socket_pool.h" |
19 #include "net/spdy/spdy_settings_storage.h" | 18 #include "net/spdy/spdy_settings_storage.h" |
20 | 19 |
21 namespace net { | 20 namespace net { |
22 | 21 |
23 class ClientSocketFactory; | 22 class ClientSocketFactory; |
24 class HttpAuthHandlerFactory; | 23 class HttpAuthHandlerFactory; |
25 class SpdySessionPool; | 24 class SpdySessionPool; |
26 class NetworkChangeNotifier; | 25 class NetworkChangeNotifier; |
27 | 26 |
28 // This class holds session objects used by HttpNetworkTransaction objects. | 27 // This class holds session objects used by HttpNetworkTransaction objects. |
29 class HttpNetworkSession | 28 class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { |
30 : public base::RefCounted<HttpNetworkSession>, | |
31 public NetworkChangeNotifier::Observer { | |
32 public: | 29 public: |
33 HttpNetworkSession( | 30 HttpNetworkSession( |
34 NetworkChangeNotifier* network_change_notifier, | 31 NetworkChangeNotifier* network_change_notifier, |
35 HostResolver* host_resolver, | 32 HostResolver* host_resolver, |
36 ProxyService* proxy_service, | 33 ProxyService* proxy_service, |
37 ClientSocketFactory* client_socket_factory, | 34 ClientSocketFactory* client_socket_factory, |
38 SSLConfigService* ssl_config_service, | 35 SSLConfigService* ssl_config_service, |
| 36 SpdySessionPool* spdy_session_pool, |
39 HttpAuthHandlerFactory* http_auth_handler_factory); | 37 HttpAuthHandlerFactory* http_auth_handler_factory); |
40 | 38 |
41 HttpAuthCache* auth_cache() { return &auth_cache_; } | 39 HttpAuthCache* auth_cache() { return &auth_cache_; } |
42 SSLClientAuthCache* ssl_client_auth_cache() { | 40 SSLClientAuthCache* ssl_client_auth_cache() { |
43 return &ssl_client_auth_cache_; | 41 return &ssl_client_auth_cache_; |
44 } | 42 } |
45 | 43 |
46 const HttpAlternateProtocols& alternate_protocols() const { | 44 const HttpAlternateProtocols& alternate_protocols() const { |
47 return alternate_protocols_; | 45 return alternate_protocols_; |
48 } | 46 } |
(...skipping 21 matching lines...) Expand all Loading... |
70 HostResolver* host_resolver() { return host_resolver_; } | 68 HostResolver* host_resolver() { return host_resolver_; } |
71 ProxyService* proxy_service() { return proxy_service_; } | 69 ProxyService* proxy_service() { return proxy_service_; } |
72 SSLConfigService* ssl_config_service() { return ssl_config_service_; } | 70 SSLConfigService* ssl_config_service() { return ssl_config_service_; } |
73 const scoped_refptr<SpdySessionPool>& spdy_session_pool() { | 71 const scoped_refptr<SpdySessionPool>& spdy_session_pool() { |
74 return spdy_session_pool_; | 72 return spdy_session_pool_; |
75 } | 73 } |
76 HttpAuthHandlerFactory* http_auth_handler_factory() { | 74 HttpAuthHandlerFactory* http_auth_handler_factory() { |
77 return http_auth_handler_factory_; | 75 return http_auth_handler_factory_; |
78 } | 76 } |
79 | 77 |
80 // Flushes cached data in the HttpNetworkSession. | 78 // Replace the current socket pool with a new one. This effectively |
81 void Flush(); | 79 // abandons the current pool. This is only used for debugging. |
82 | 80 void ReplaceTCPSocketPool(); |
83 // NetworkChangeNotifier::Observer methods: | |
84 virtual void OnIPAddressChanged(); | |
85 | 81 |
86 static void set_max_sockets_per_group(int socket_count); | 82 static void set_max_sockets_per_group(int socket_count); |
87 | 83 |
88 static uint16 fixed_http_port() { return g_fixed_http_port; } | 84 static uint16 fixed_http_port() { return g_fixed_http_port; } |
89 static void set_fixed_http_port(uint16 port) { g_fixed_http_port = port; } | 85 static void set_fixed_http_port(uint16 port) { g_fixed_http_port = port; } |
90 | 86 |
91 static uint16 fixed_https_port() { return g_fixed_https_port; } | 87 static uint16 fixed_https_port() { return g_fixed_https_port; } |
92 static void set_fixed_https_port(uint16 port) { g_fixed_https_port = port; } | 88 static void set_fixed_https_port(uint16 port) { g_fixed_https_port = port; } |
93 | 89 |
94 private: | 90 private: |
95 friend class base::RefCounted<HttpNetworkSession>; | 91 friend class base::RefCounted<HttpNetworkSession>; |
96 FRIEND_TEST(HttpNetworkTransactionTest, GroupNameForProxyConnections); | 92 FRIEND_TEST(HttpNetworkTransactionTest, GroupNameForProxyConnections); |
97 | 93 |
98 ~HttpNetworkSession(); | 94 ~HttpNetworkSession(); |
99 | 95 |
100 scoped_refptr<TCPClientSocketPool> CreateNewTCPSocketPool(); | |
101 scoped_refptr<SOCKSClientSocketPool> CreateNewSOCKSSocketPool(); | |
102 | |
103 // Total limit of sockets. Not a constant to allow experiments. | 96 // Total limit of sockets. Not a constant to allow experiments. |
104 static int max_sockets_; | 97 static int max_sockets_; |
105 | 98 |
106 // Default to allow up to 6 connections per host. Experiment and tuning may | 99 // Default to allow up to 6 connections per host. Experiment and tuning may |
107 // try other values (greater than 0). Too large may cause many problems, such | 100 // try other values (greater than 0). Too large may cause many problems, such |
108 // as home routers blocking the connections!?!? | 101 // as home routers blocking the connections!?!? |
109 static int max_sockets_per_group_; | 102 static int max_sockets_per_group_; |
110 | 103 |
111 static uint16 g_fixed_http_port; | 104 static uint16 g_fixed_http_port; |
112 static uint16 g_fixed_https_port; | 105 static uint16 g_fixed_https_port; |
113 | 106 |
114 HttpAuthCache auth_cache_; | 107 HttpAuthCache auth_cache_; |
115 SSLClientAuthCache ssl_client_auth_cache_; | 108 SSLClientAuthCache ssl_client_auth_cache_; |
116 HttpAlternateProtocols alternate_protocols_; | 109 HttpAlternateProtocols alternate_protocols_; |
117 NetworkChangeNotifier* const network_change_notifier_; | 110 NetworkChangeNotifier* const network_change_notifier_; |
| 111 scoped_refptr<TCPClientSocketPool> tcp_socket_pool_; |
| 112 scoped_refptr<SOCKSClientSocketPool> socks_socket_pool_; |
118 ClientSocketFactory* socket_factory_; | 113 ClientSocketFactory* socket_factory_; |
119 scoped_refptr<HostResolver> host_resolver_; | 114 scoped_refptr<HostResolver> host_resolver_; |
120 scoped_refptr<TCPClientSocketPool> tcp_socket_pool_; | |
121 scoped_refptr<SOCKSClientSocketPool> socks_socket_pool_; | |
122 scoped_refptr<ProxyService> proxy_service_; | 115 scoped_refptr<ProxyService> proxy_service_; |
123 scoped_refptr<SSLConfigService> ssl_config_service_; | 116 scoped_refptr<SSLConfigService> ssl_config_service_; |
124 scoped_refptr<SpdySessionPool> spdy_session_pool_; | 117 scoped_refptr<SpdySessionPool> spdy_session_pool_; |
125 HttpAuthHandlerFactory* http_auth_handler_factory_; | 118 HttpAuthHandlerFactory* http_auth_handler_factory_; |
126 SpdySettingsStorage spdy_settings_; | 119 SpdySettingsStorage spdy_settings_; |
127 }; | 120 }; |
128 | 121 |
129 } // namespace net | 122 } // namespace net |
130 | 123 |
131 #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_ | 124 #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_ |
OLD | NEW |