| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_SPDY_SPDY_SESSION_POOL_H_ | 5 #ifndef NET_SPDY_SPDY_SESSION_POOL_H_ |
| 6 #define NET_SPDY_SPDY_SESSION_POOL_H_ | 6 #define NET_SPDY_SPDY_SESSION_POOL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "net/proxy/proxy_server.h" | 25 #include "net/proxy/proxy_server.h" |
| 26 #include "net/spdy/spdy_settings_storage.h" | 26 #include "net/spdy/spdy_settings_storage.h" |
| 27 | 27 |
| 28 namespace net { | 28 namespace net { |
| 29 | 29 |
| 30 class AddressList; | 30 class AddressList; |
| 31 class BoundNetLog; | 31 class BoundNetLog; |
| 32 class ClientSocketHandle; | 32 class ClientSocketHandle; |
| 33 class HostResolver; | 33 class HostResolver; |
| 34 class HttpNetworkSession; | 34 class HttpNetworkSession; |
| 35 class HttpServerProperties; |
| 35 class SpdySession; | 36 class SpdySession; |
| 36 | 37 |
| 37 // This is a very simple pool for open SpdySessions. | 38 // This is a very simple pool for open SpdySessions. |
| 38 class NET_EXPORT SpdySessionPool | 39 class NET_EXPORT SpdySessionPool |
| 39 : public NetworkChangeNotifier::IPAddressObserver, | 40 : public NetworkChangeNotifier::IPAddressObserver, |
| 40 public SSLConfigService::Observer, | 41 public SSLConfigService::Observer, |
| 41 public CertDatabase::Observer { | 42 public CertDatabase::Observer { |
| 42 public: | 43 public: |
| 43 SpdySessionPool(HostResolver* host_resolver, | 44 SpdySessionPool(HostResolver* host_resolver, |
| 44 SSLConfigService* ssl_config_service); | 45 SSLConfigService* ssl_config_service, |
| 46 HttpServerProperties* http_server_properties); |
| 45 virtual ~SpdySessionPool(); | 47 virtual ~SpdySessionPool(); |
| 46 | 48 |
| 47 // Either returns an existing SpdySession or creates a new SpdySession for | 49 // Either returns an existing SpdySession or creates a new SpdySession for |
| 48 // use. | 50 // use. |
| 49 scoped_refptr<SpdySession> Get( | 51 scoped_refptr<SpdySession> Get( |
| 50 const HostPortProxyPair& host_port_proxy_pair, | 52 const HostPortProxyPair& host_port_proxy_pair, |
| 51 const BoundNetLog& net_log); | 53 const BoundNetLog& net_log); |
| 52 | 54 |
| 53 // Only returns a SpdySession if it already exists. | 55 // Only returns a SpdySession if it already exists. |
| 54 scoped_refptr<SpdySession> GetIfExists( | 56 scoped_refptr<SpdySession> GetIfExists( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 // by SpdySession, because otherwise session->state_ is not set to CLOSED. | 101 // by SpdySession, because otherwise session->state_ is not set to CLOSED. |
| 100 void Remove(const scoped_refptr<SpdySession>& session); | 102 void Remove(const scoped_refptr<SpdySession>& session); |
| 101 | 103 |
| 102 // Creates a Value summary of the state of the spdy session pool. The caller | 104 // Creates a Value summary of the state of the spdy session pool. The caller |
| 103 // responsible for deleting the returned value. | 105 // responsible for deleting the returned value. |
| 104 base::Value* SpdySessionPoolInfoToValue() const; | 106 base::Value* SpdySessionPoolInfoToValue() const; |
| 105 | 107 |
| 106 SpdySettingsStorage* mutable_spdy_settings() { return &spdy_settings_; } | 108 SpdySettingsStorage* mutable_spdy_settings() { return &spdy_settings_; } |
| 107 const SpdySettingsStorage& spdy_settings() const { return spdy_settings_; } | 109 const SpdySettingsStorage& spdy_settings() const { return spdy_settings_; } |
| 108 | 110 |
| 111 HttpServerProperties* http_server_properties() { |
| 112 return http_server_properties_; |
| 113 } |
| 114 |
| 109 // NetworkChangeNotifier::IPAddressObserver methods: | 115 // NetworkChangeNotifier::IPAddressObserver methods: |
| 110 | 116 |
| 111 // We flush all idle sessions and release references to the active ones so | 117 // We flush all idle sessions and release references to the active ones so |
| 112 // they won't get re-used. The active ones will either complete successfully | 118 // they won't get re-used. The active ones will either complete successfully |
| 113 // or error out due to the IP address change. | 119 // or error out due to the IP address change. |
| 114 virtual void OnIPAddressChanged(); | 120 virtual void OnIPAddressChanged(); |
| 115 | 121 |
| 116 // SSLConfigService::Observer methods: | 122 // SSLConfigService::Observer methods: |
| 117 | 123 |
| 118 // We perform the same flushing as described above when SSL settings change. | 124 // We perform the same flushing as described above when SSL settings change. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 bool LookupAddresses(const HostPortProxyPair& pair, | 171 bool LookupAddresses(const HostPortProxyPair& pair, |
| 166 AddressList* addresses) const; | 172 AddressList* addresses) const; |
| 167 | 173 |
| 168 // Add |address| as an IP-equivalent address for |pair|. | 174 // Add |address| as an IP-equivalent address for |pair|. |
| 169 void AddAlias(const addrinfo* address, const HostPortProxyPair& pair); | 175 void AddAlias(const addrinfo* address, const HostPortProxyPair& pair); |
| 170 | 176 |
| 171 // Remove all aliases for |pair| from the aliases table. | 177 // Remove all aliases for |pair| from the aliases table. |
| 172 void RemoveAliases(const HostPortProxyPair& pair); | 178 void RemoveAliases(const HostPortProxyPair& pair); |
| 173 | 179 |
| 174 SpdySettingsStorage spdy_settings_; | 180 SpdySettingsStorage spdy_settings_; |
| 181 HttpServerProperties* const http_server_properties_; |
| 175 | 182 |
| 176 // This is our weak session pool - one session per domain. | 183 // This is our weak session pool - one session per domain. |
| 177 SpdySessionsMap sessions_; | 184 SpdySessionsMap sessions_; |
| 178 // A map of IPEndPoint aliases for sessions. | 185 // A map of IPEndPoint aliases for sessions. |
| 179 SpdyAliasMap aliases_; | 186 SpdyAliasMap aliases_; |
| 180 | 187 |
| 181 static size_t g_max_sessions_per_domain; | 188 static size_t g_max_sessions_per_domain; |
| 182 static bool g_force_single_domain; | 189 static bool g_force_single_domain; |
| 183 static bool g_enable_ip_pooling; | 190 static bool g_enable_ip_pooling; |
| 184 | 191 |
| 185 const scoped_refptr<SSLConfigService> ssl_config_service_; | 192 const scoped_refptr<SSLConfigService> ssl_config_service_; |
| 186 HostResolver* const resolver_; | 193 HostResolver* const resolver_; |
| 187 | 194 |
| 188 // Defaults to true. May be controlled via SpdySessionPoolPeer for tests. | 195 // Defaults to true. May be controlled via SpdySessionPoolPeer for tests. |
| 189 bool verify_domain_authentication_; | 196 bool verify_domain_authentication_; |
| 190 | 197 |
| 191 DISALLOW_COPY_AND_ASSIGN(SpdySessionPool); | 198 DISALLOW_COPY_AND_ASSIGN(SpdySessionPool); |
| 192 }; | 199 }; |
| 193 | 200 |
| 194 } // namespace net | 201 } // namespace net |
| 195 | 202 |
| 196 #endif // NET_SPDY_SPDY_SESSION_POOL_H_ | 203 #endif // NET_SPDY_SPDY_SESSION_POOL_H_ |
| OLD | NEW |