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