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