| 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/ssl_client_auth_cache.h" | 13 #include "net/base/ssl_client_auth_cache.h" |
| 14 #include "net/base/ssl_config_service.h" | 14 #include "net/base/ssl_config_service.h" |
| 15 #include "net/http/http_alternate_protocols.h" | 15 #include "net/http/http_alternate_protocols.h" |
| 16 #include "net/http/http_auth_cache.h" | 16 #include "net/http/http_auth_cache.h" |
| 17 #include "net/http/http_network_delegate.h" | 17 #include "net/http/http_network_delegate.h" |
| 18 #include "net/http/http_network_transaction.h" | 18 #include "net/http/http_network_transaction.h" |
| 19 #include "net/http/http_proxy_client_socket_pool.h" | 19 #include "net/http/http_proxy_client_socket_pool.h" |
| 20 #include "net/proxy/proxy_service.h" | 20 #include "net/proxy/proxy_service.h" |
| 21 #include "net/socket/client_socket_pool_histograms.h" | 21 #include "net/socket/client_socket_pool_histograms.h" |
| 22 #include "net/socket/socks_client_socket_pool.h" | 22 #include "net/socket/socks_client_socket_pool.h" |
| 23 #include "net/socket/ssl_client_socket_pool.h" |
| 23 #include "net/socket/tcp_client_socket_pool.h" | 24 #include "net/socket/tcp_client_socket_pool.h" |
| 24 #include "net/spdy/spdy_settings_storage.h" | 25 #include "net/spdy/spdy_settings_storage.h" |
| 25 | 26 |
| 26 namespace net { | 27 namespace net { |
| 27 | 28 |
| 28 class ClientSocketFactory; | 29 class ClientSocketFactory; |
| 29 class HttpAuthHandlerFactory; | 30 class HttpAuthHandlerFactory; |
| 30 class HttpNetworkDelegate; | 31 class HttpNetworkDelegate; |
| 31 class HttpNetworkSessionPeer; | 32 class HttpNetworkSessionPeer; |
| 32 class SpdySessionPool; | 33 class SpdySessionPool; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 62 } | 63 } |
| 63 SpdySettingsStorage* mutable_spdy_settings() { | 64 SpdySettingsStorage* mutable_spdy_settings() { |
| 64 return &spdy_settings_; | 65 return &spdy_settings_; |
| 65 } | 66 } |
| 66 | 67 |
| 67 // TCP sockets come from the tcp_socket_pool(). | 68 // TCP sockets come from the tcp_socket_pool(). |
| 68 const scoped_refptr<TCPClientSocketPool>& tcp_socket_pool() { | 69 const scoped_refptr<TCPClientSocketPool>& tcp_socket_pool() { |
| 69 return tcp_socket_pool_; | 70 return tcp_socket_pool_; |
| 70 } | 71 } |
| 71 | 72 |
| 73 const scoped_refptr<SSLClientSocketPool>& ssl_socket_pool() { |
| 74 return ssl_socket_pool_; |
| 75 } |
| 76 |
| 72 const scoped_refptr<SOCKSClientSocketPool>& GetSocketPoolForSOCKSProxy( | 77 const scoped_refptr<SOCKSClientSocketPool>& GetSocketPoolForSOCKSProxy( |
| 73 const HostPortPair& socks_proxy); | 78 const HostPortPair& socks_proxy); |
| 74 | 79 |
| 75 const scoped_refptr<HttpProxyClientSocketPool>& GetSocketPoolForHTTPProxy( | 80 const scoped_refptr<HttpProxyClientSocketPool>& GetSocketPoolForHTTPProxy( |
| 76 const HostPortPair& http_proxy); | 81 const HostPortPair& http_proxy); |
| 77 | 82 |
| 83 const scoped_refptr<SSLClientSocketPool>& GetSocketPoolForSSLWithProxy( |
| 84 const HostPortPair& proxy_server); |
| 85 |
| 78 // SSL sockets come from the socket_factory(). | 86 // SSL sockets come from the socket_factory(). |
| 79 ClientSocketFactory* socket_factory() { return socket_factory_; } | 87 ClientSocketFactory* socket_factory() { return socket_factory_; } |
| 80 HostResolver* host_resolver() { return host_resolver_; } | 88 HostResolver* host_resolver() { return host_resolver_; } |
| 81 ProxyService* proxy_service() { return proxy_service_; } | 89 ProxyService* proxy_service() { return proxy_service_; } |
| 82 SSLConfigService* ssl_config_service() { return ssl_config_service_; } | 90 SSLConfigService* ssl_config_service() { return ssl_config_service_; } |
| 83 const scoped_refptr<SpdySessionPool>& spdy_session_pool() { | 91 const scoped_refptr<SpdySessionPool>& spdy_session_pool() { |
| 84 return spdy_session_pool_; | 92 return spdy_session_pool_; |
| 85 } | 93 } |
| 86 HttpAuthHandlerFactory* http_auth_handler_factory() { | 94 HttpAuthHandlerFactory* http_auth_handler_factory() { |
| 87 return http_auth_handler_factory_; | 95 return http_auth_handler_factory_; |
| 88 } | 96 } |
| 89 HttpNetworkDelegate* network_delegate() { | 97 HttpNetworkDelegate* network_delegate() { |
| 90 return network_delegate_; | 98 return network_delegate_; |
| 91 } | 99 } |
| 92 | 100 |
| 93 static void set_max_sockets_per_group(int socket_count); | 101 static void set_max_sockets_per_group(int socket_count); |
| 94 | 102 |
| 95 static uint16 fixed_http_port(); | 103 static uint16 fixed_http_port(); |
| 96 static void set_fixed_http_port(uint16 port); | 104 static void set_fixed_http_port(uint16 port); |
| 97 | 105 |
| 98 static uint16 fixed_https_port(); | 106 static uint16 fixed_https_port(); |
| 99 static void set_fixed_https_port(uint16 port); | 107 static void set_fixed_https_port(uint16 port); |
| 100 | 108 |
| 109 #ifdef UNIT_TEST |
| 110 void FlushSocketPools() { |
| 111 if (ssl_socket_pool_.get()) |
| 112 ssl_socket_pool_->Flush(); |
| 113 if (tcp_socket_pool_.get()) |
| 114 tcp_socket_pool_->Flush(); |
| 115 |
| 116 for (SSLSocketPoolMap::const_iterator it = |
| 117 ssl_socket_pools_for_proxies_.begin(); |
| 118 it != ssl_socket_pools_for_proxies_.end(); |
| 119 it++) |
| 120 it->second->Flush(); |
| 121 |
| 122 for (SOCKSSocketPoolMap::const_iterator it = |
| 123 socks_socket_pools_.begin(); |
| 124 it != socks_socket_pools_.end(); |
| 125 it++) |
| 126 it->second->Flush(); |
| 127 |
| 128 for (HTTPProxySocketPoolMap::const_iterator it = |
| 129 http_proxy_socket_pools_.begin(); |
| 130 it != http_proxy_socket_pools_.end(); |
| 131 it++) |
| 132 it->second->Flush(); |
| 133 } |
| 134 #endif |
| 135 |
| 101 private: | 136 private: |
| 102 typedef std::map<HostPortPair, scoped_refptr<HttpProxyClientSocketPool> > | 137 typedef std::map<HostPortPair, scoped_refptr<HttpProxyClientSocketPool> > |
| 103 HTTPProxySocketPoolMap; | 138 HTTPProxySocketPoolMap; |
| 104 typedef std::map<HostPortPair, scoped_refptr<SOCKSClientSocketPool> > | 139 typedef std::map<HostPortPair, scoped_refptr<SOCKSClientSocketPool> > |
| 105 SOCKSSocketPoolMap; | 140 SOCKSSocketPoolMap; |
| 141 typedef std::map<HostPortPair, scoped_refptr<SSLClientSocketPool> > |
| 142 SSLSocketPoolMap; |
| 106 | 143 |
| 107 friend class base::RefCounted<HttpNetworkSession>; | 144 friend class base::RefCounted<HttpNetworkSession>; |
| 108 friend class HttpNetworkSessionPeer; | 145 friend class HttpNetworkSessionPeer; |
| 109 | 146 |
| 110 ~HttpNetworkSession(); | 147 ~HttpNetworkSession(); |
| 111 | 148 |
| 112 HttpAuthCache auth_cache_; | 149 HttpAuthCache auth_cache_; |
| 113 SSLClientAuthCache ssl_client_auth_cache_; | 150 SSLClientAuthCache ssl_client_auth_cache_; |
| 114 HttpAlternateProtocols alternate_protocols_; | 151 HttpAlternateProtocols alternate_protocols_; |
| 115 scoped_refptr<ClientSocketPoolHistograms> tcp_pool_histograms_; | 152 scoped_refptr<ClientSocketPoolHistograms> tcp_pool_histograms_; |
| 116 scoped_refptr<ClientSocketPoolHistograms> tcp_for_http_proxy_pool_histograms_; | 153 scoped_refptr<ClientSocketPoolHistograms> tcp_for_http_proxy_pool_histograms_; |
| 117 scoped_refptr<ClientSocketPoolHistograms> http_proxy_pool_histograms_; | 154 scoped_refptr<ClientSocketPoolHistograms> http_proxy_pool_histograms_; |
| 118 scoped_refptr<ClientSocketPoolHistograms> tcp_for_socks_pool_histograms_; | 155 scoped_refptr<ClientSocketPoolHistograms> tcp_for_socks_pool_histograms_; |
| 119 scoped_refptr<ClientSocketPoolHistograms> socks_pool_histograms_; | 156 scoped_refptr<ClientSocketPoolHistograms> socks_pool_histograms_; |
| 157 scoped_refptr<ClientSocketPoolHistograms> ssl_pool_histograms_; |
| 120 scoped_refptr<TCPClientSocketPool> tcp_socket_pool_; | 158 scoped_refptr<TCPClientSocketPool> tcp_socket_pool_; |
| 121 HTTPProxySocketPoolMap http_proxy_socket_pool_; | 159 scoped_refptr<SSLClientSocketPool> ssl_socket_pool_; |
| 122 SOCKSSocketPoolMap socks_socket_pool_; | 160 HTTPProxySocketPoolMap http_proxy_socket_pools_; |
| 161 SOCKSSocketPoolMap socks_socket_pools_; |
| 162 SSLSocketPoolMap ssl_socket_pools_for_proxies_; |
| 123 ClientSocketFactory* socket_factory_; | 163 ClientSocketFactory* socket_factory_; |
| 124 scoped_refptr<HostResolver> host_resolver_; | 164 scoped_refptr<HostResolver> host_resolver_; |
| 125 scoped_refptr<ProxyService> proxy_service_; | 165 scoped_refptr<ProxyService> proxy_service_; |
| 126 scoped_refptr<SSLConfigService> ssl_config_service_; | 166 scoped_refptr<SSLConfigService> ssl_config_service_; |
| 127 scoped_refptr<SpdySessionPool> spdy_session_pool_; | 167 scoped_refptr<SpdySessionPool> spdy_session_pool_; |
| 128 HttpAuthHandlerFactory* http_auth_handler_factory_; | 168 HttpAuthHandlerFactory* http_auth_handler_factory_; |
| 129 HttpNetworkDelegate* const network_delegate_; | 169 HttpNetworkDelegate* const network_delegate_; |
| 130 NetLog* net_log_; | 170 NetLog* net_log_; |
| 131 SpdySettingsStorage spdy_settings_; | 171 SpdySettingsStorage spdy_settings_; |
| 132 }; | 172 }; |
| 133 | 173 |
| 134 } // namespace net | 174 } // namespace net |
| 135 | 175 |
| 136 #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_ | 176 #endif // NET_HTTP_HTTP_NETWORK_SESSION_H_ |
| OLD | NEW |