| 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 <map> | 8 #include <map> |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "net/base/host_port_pair.h" | 11 #include "net/base/host_port_pair.h" |
| 12 #include "net/base/host_resolver.h" | 12 #include "net/base/host_resolver.h" |
| 13 #include "net/base/network_change_notifier.h" | |
| 14 #include "net/base/ssl_client_auth_cache.h" | 13 #include "net/base/ssl_client_auth_cache.h" |
| 15 #include "net/base/ssl_config_service.h" | 14 #include "net/base/ssl_config_service.h" |
| 16 #include "net/http/http_alternate_protocols.h" | 15 #include "net/http/http_alternate_protocols.h" |
| 17 #include "net/http/http_auth_cache.h" | 16 #include "net/http/http_auth_cache.h" |
| 18 #include "net/proxy/proxy_service.h" | 17 #include "net/proxy/proxy_service.h" |
| 19 #include "net/socket/socks_client_socket_pool.h" | 18 #include "net/socket/socks_client_socket_pool.h" |
| 20 #include "net/socket/tcp_client_socket_pool.h" | 19 #include "net/socket/tcp_client_socket_pool.h" |
| 21 #include "net/spdy/spdy_settings_storage.h" | 20 #include "net/spdy/spdy_settings_storage.h" |
| 22 | 21 |
| 23 namespace net { | 22 namespace net { |
| 24 | 23 |
| 25 class ClientSocketFactory; | 24 class ClientSocketFactory; |
| 26 class HttpAuthHandlerFactory; | 25 class HttpAuthHandlerFactory; |
| 27 class HttpNetworkSessionPeer; | 26 class HttpNetworkSessionPeer; |
| 28 class NetworkChangeNotifier; | 27 class NetworkChangeNotifier; |
| 29 class SpdySessionPool; | 28 class SpdySessionPool; |
| 30 | 29 |
| 31 // This class holds session objects used by HttpNetworkTransaction objects. | 30 // This class holds session objects used by HttpNetworkTransaction objects. |
| 32 class HttpNetworkSession | 31 class HttpNetworkSession : public base::RefCounted<HttpNetworkSession> { |
| 33 : public base::RefCounted<HttpNetworkSession>, | |
| 34 public NetworkChangeNotifier::Observer { | |
| 35 public: | 32 public: |
| 36 HttpNetworkSession( | 33 HttpNetworkSession( |
| 37 NetworkChangeNotifier* network_change_notifier, | 34 NetworkChangeNotifier* network_change_notifier, |
| 38 HostResolver* host_resolver, | 35 HostResolver* host_resolver, |
| 39 ProxyService* proxy_service, | 36 ProxyService* proxy_service, |
| 40 ClientSocketFactory* client_socket_factory, | 37 ClientSocketFactory* client_socket_factory, |
| 41 SSLConfigService* ssl_config_service, | 38 SSLConfigService* ssl_config_service, |
| 39 SpdySessionPool* spdy_session_pool, |
| 42 HttpAuthHandlerFactory* http_auth_handler_factory); | 40 HttpAuthHandlerFactory* http_auth_handler_factory); |
| 43 | 41 |
| 44 // NetworkChangeNotifier::Observer methods: | |
| 45 virtual void OnIPAddressChanged(); | |
| 46 | |
| 47 // Flushes cached data in the HttpNetworkSession. Typically called on IP | |
| 48 // address change. | |
| 49 void Flush(); | |
| 50 | |
| 51 HttpAuthCache* auth_cache() { return &auth_cache_; } | 42 HttpAuthCache* auth_cache() { return &auth_cache_; } |
| 52 SSLClientAuthCache* ssl_client_auth_cache() { | 43 SSLClientAuthCache* ssl_client_auth_cache() { |
| 53 return &ssl_client_auth_cache_; | 44 return &ssl_client_auth_cache_; |
| 54 } | 45 } |
| 55 | 46 |
| 56 const HttpAlternateProtocols& alternate_protocols() const { | 47 const HttpAlternateProtocols& alternate_protocols() const { |
| 57 return alternate_protocols_; | 48 return alternate_protocols_; |
| 58 } | 49 } |
| 59 HttpAlternateProtocols* mutable_alternate_protocols() { | 50 HttpAlternateProtocols* mutable_alternate_protocols() { |
| 60 return &alternate_protocols_; | 51 return &alternate_protocols_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 84 HostResolver* host_resolver() { return host_resolver_; } | 75 HostResolver* host_resolver() { return host_resolver_; } |
| 85 ProxyService* proxy_service() { return proxy_service_; } | 76 ProxyService* proxy_service() { return proxy_service_; } |
| 86 SSLConfigService* ssl_config_service() { return ssl_config_service_; } | 77 SSLConfigService* ssl_config_service() { return ssl_config_service_; } |
| 87 const scoped_refptr<SpdySessionPool>& spdy_session_pool() { | 78 const scoped_refptr<SpdySessionPool>& spdy_session_pool() { |
| 88 return spdy_session_pool_; | 79 return spdy_session_pool_; |
| 89 } | 80 } |
| 90 HttpAuthHandlerFactory* http_auth_handler_factory() { | 81 HttpAuthHandlerFactory* http_auth_handler_factory() { |
| 91 return http_auth_handler_factory_; | 82 return http_auth_handler_factory_; |
| 92 } | 83 } |
| 93 | 84 |
| 85 // Replace the current socket pool with a new one. This effectively |
| 86 // abandons the current pool. This is only used for debugging. |
| 87 void ReplaceTCPSocketPool(); |
| 88 |
| 94 static void set_max_sockets_per_group(int socket_count); | 89 static void set_max_sockets_per_group(int socket_count); |
| 95 | 90 |
| 96 static uint16 fixed_http_port(); | 91 static uint16 fixed_http_port(); |
| 97 static void set_fixed_http_port(uint16 port); | 92 static void set_fixed_http_port(uint16 port); |
| 98 | 93 |
| 99 static uint16 fixed_https_port(); | 94 static uint16 fixed_https_port(); |
| 100 static void set_fixed_https_port(uint16 port); | 95 static void set_fixed_https_port(uint16 port); |
| 101 | 96 |
| 102 private: | 97 private: |
| 103 typedef std::map<HostPortPair, scoped_refptr<TCPClientSocketPool> > | 98 typedef std::map<HostPortPair, scoped_refptr<TCPClientSocketPool> > |
| 104 HTTPProxySocketPoolMap; | 99 HTTPProxySocketPoolMap; |
| 105 typedef std::map<HostPortPair, scoped_refptr<SOCKSClientSocketPool> > | 100 typedef std::map<HostPortPair, scoped_refptr<SOCKSClientSocketPool> > |
| 106 SOCKSSocketPoolMap; | 101 SOCKSSocketPoolMap; |
| 107 | 102 |
| 108 friend class base::RefCounted<HttpNetworkSession>; | 103 friend class base::RefCounted<HttpNetworkSession>; |
| 109 friend class HttpNetworkSessionPeer; | 104 friend class HttpNetworkSessionPeer; |
| 110 | 105 |
| 111 ~HttpNetworkSession(); | 106 ~HttpNetworkSession(); |
| 112 | 107 |
| 113 scoped_refptr<TCPClientSocketPool> CreateNewTCPSocketPool(); | |
| 114 | |
| 115 HttpAuthCache auth_cache_; | 108 HttpAuthCache auth_cache_; |
| 116 SSLClientAuthCache ssl_client_auth_cache_; | 109 SSLClientAuthCache ssl_client_auth_cache_; |
| 117 HttpAlternateProtocols alternate_protocols_; | 110 HttpAlternateProtocols alternate_protocols_; |
| 118 NetworkChangeNotifier* const network_change_notifier_; | 111 NetworkChangeNotifier* const network_change_notifier_; |
| 119 ClientSocketFactory* socket_factory_; | |
| 120 scoped_refptr<HostResolver> host_resolver_; | |
| 121 scoped_refptr<TCPClientSocketPool> tcp_socket_pool_; | 112 scoped_refptr<TCPClientSocketPool> tcp_socket_pool_; |
| 122 HTTPProxySocketPoolMap http_proxy_socket_pool_; | 113 HTTPProxySocketPoolMap http_proxy_socket_pool_; |
| 123 SOCKSSocketPoolMap socks_socket_pool_; | 114 SOCKSSocketPoolMap socks_socket_pool_; |
| 115 ClientSocketFactory* socket_factory_; |
| 116 scoped_refptr<HostResolver> host_resolver_; |
| 124 scoped_refptr<ProxyService> proxy_service_; | 117 scoped_refptr<ProxyService> proxy_service_; |
| 125 scoped_refptr<SSLConfigService> ssl_config_service_; | 118 scoped_refptr<SSLConfigService> ssl_config_service_; |
| 126 scoped_refptr<SpdySessionPool> spdy_session_pool_; | 119 scoped_refptr<SpdySessionPool> spdy_session_pool_; |
| 127 HttpAuthHandlerFactory* http_auth_handler_factory_; | 120 HttpAuthHandlerFactory* http_auth_handler_factory_; |
| 128 SpdySettingsStorage spdy_settings_; | 121 SpdySettingsStorage spdy_settings_; |
| 129 }; | 122 }; |
| 130 | 123 |
| 131 } // namespace net | 124 } // namespace net |
| 132 | 125 |
| 133 #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_ | 126 #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_ |
| OLD | NEW |