OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "net/base/host_port_pair.h" | 18 #include "net/base/host_port_pair.h" |
19 #include "net/base/ip_endpoint.h" | 19 #include "net/base/ip_endpoint.h" |
20 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
21 #include "net/base/net_export.h" | 21 #include "net/base/net_export.h" |
22 #include "net/base/network_change_notifier.h" | 22 #include "net/base/network_change_notifier.h" |
23 #include "net/cert/cert_database.h" | 23 #include "net/cert/cert_database.h" |
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/socket/next_proto.h" | |
27 #include "net/spdy/spdy_session_key.h" | 26 #include "net/spdy/spdy_session_key.h" |
28 #include "net/ssl/ssl_config_service.h" | 27 #include "net/ssl/ssl_config_service.h" |
29 | 28 |
30 namespace net { | 29 namespace net { |
31 | 30 |
32 class AddressList; | 31 class AddressList; |
33 class BoundNetLog; | 32 class BoundNetLog; |
34 class ClientSocketHandle; | 33 class ClientSocketHandle; |
35 class HostResolver; | 34 class HostResolver; |
36 class HttpServerProperties; | 35 class HttpServerProperties; |
37 class ProxyDelegate; | 36 class ProxyDelegate; |
38 class SpdySession; | 37 class SpdySession; |
39 class TransportSecurityState; | 38 class TransportSecurityState; |
40 | 39 |
41 // This is a very simple pool for open SpdySessions. | 40 // This is a very simple pool for open SpdySessions. |
42 class NET_EXPORT SpdySessionPool | 41 class NET_EXPORT SpdySessionPool |
43 : public NetworkChangeNotifier::IPAddressObserver, | 42 : public NetworkChangeNotifier::IPAddressObserver, |
44 public SSLConfigService::Observer, | 43 public SSLConfigService::Observer, |
45 public CertDatabase::Observer { | 44 public CertDatabase::Observer { |
46 public: | 45 public: |
47 typedef base::TimeTicks (*TimeFunc)(void); | 46 typedef base::TimeTicks (*TimeFunc)(void); |
48 | 47 |
49 // |default_protocol| may be kProtoUnknown (e.g., if SPDY is | |
50 // disabled), in which case it's set to a default value. Otherwise, | |
51 // it must be a SPDY protocol. | |
52 SpdySessionPool(HostResolver* host_resolver, | 48 SpdySessionPool(HostResolver* host_resolver, |
53 SSLConfigService* ssl_config_service, | 49 SSLConfigService* ssl_config_service, |
54 HttpServerProperties* http_server_properties, | 50 HttpServerProperties* http_server_properties, |
55 TransportSecurityState* transport_security_state, | 51 TransportSecurityState* transport_security_state, |
56 bool enable_ping_based_connection_checking, | 52 bool enable_ping_based_connection_checking, |
57 bool enable_priority_dependencies, | 53 bool enable_priority_dependencies, |
58 NextProto default_protocol, | |
59 size_t session_max_recv_window_size, | 54 size_t session_max_recv_window_size, |
60 size_t stream_max_recv_window_size, | 55 size_t stream_max_recv_window_size, |
61 SpdySessionPool::TimeFunc time_func, | 56 SpdySessionPool::TimeFunc time_func, |
62 ProxyDelegate* proxy_delegate); | 57 ProxyDelegate* proxy_delegate); |
63 ~SpdySessionPool() override; | 58 ~SpdySessionPool() override; |
64 | 59 |
65 // In the functions below, a session is "available" if this pool has | 60 // In the functions below, a session is "available" if this pool has |
66 // a reference to it and there is some SpdySessionKey for which | 61 // a reference to it and there is some SpdySessionKey for which |
67 // FindAvailableSession() will return it. A session is "unavailable" | 62 // FindAvailableSession() will return it. A session is "unavailable" |
68 // if this pool has a reference to it but it won't be returned by | 63 // if this pool has a reference to it but it won't be returned by |
69 // FindAvailableSession() for any SpdySessionKey; for example, this | 64 // FindAvailableSession() for any SpdySessionKey; for example, this |
70 // can happen when a session receives a GOAWAY frame and is still | 65 // can happen when a session receives a GOAWAY frame and is still |
71 // processing existing streams. | 66 // processing existing streams. |
72 | 67 |
73 // Create a new SPDY session from an existing socket. There must | 68 // Create a new SPDY session from an existing socket. There must |
74 // not already be a session for the given key. This pool must have | 69 // not already be a session for the given key. |
75 // been constructed with a valid |default_protocol| value. | |
76 // | 70 // |
77 // |is_secure| can be false for testing or when SPDY is configured | 71 // |is_secure| can be false for testing or when SPDY is configured |
78 // to work with non-secure sockets. If |is_secure| is true, | 72 // to work with non-secure sockets. If |is_secure| is true, |
79 // |certificate_error_code| indicates that the certificate error | 73 // |certificate_error_code| indicates that the certificate error |
80 // encountered when connecting the SSL socket, with OK meaning there | 74 // encountered when connecting the SSL socket, with OK meaning there |
81 // was no error. | 75 // was no error. |
82 // | 76 // |
83 // Returns the new SpdySession. Note that the SpdySession begins reading from | 77 // Returns the new SpdySession. Note that the SpdySession begins reading from |
84 // |connection| on a subsequent event loop iteration, so it may be closed | 78 // |connection| on a subsequent event loop iteration, so it may be closed |
85 // immediately afterwards if the first read of |connection| fails. | 79 // immediately afterwards if the first read of |connection| fails. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 UnclaimedPushedStreamMap unclaimed_pushed_streams_; | 215 UnclaimedPushedStreamMap unclaimed_pushed_streams_; |
222 | 216 |
223 const scoped_refptr<SSLConfigService> ssl_config_service_; | 217 const scoped_refptr<SSLConfigService> ssl_config_service_; |
224 HostResolver* const resolver_; | 218 HostResolver* const resolver_; |
225 | 219 |
226 // Defaults to true. May be controlled via SpdySessionPoolPeer for tests. | 220 // Defaults to true. May be controlled via SpdySessionPoolPeer for tests. |
227 bool verify_domain_authentication_; | 221 bool verify_domain_authentication_; |
228 bool enable_sending_initial_data_; | 222 bool enable_sending_initial_data_; |
229 bool enable_ping_based_connection_checking_; | 223 bool enable_ping_based_connection_checking_; |
230 const bool enable_priority_dependencies_; | 224 const bool enable_priority_dependencies_; |
231 const NextProto default_protocol_; | |
232 size_t session_max_recv_window_size_; | 225 size_t session_max_recv_window_size_; |
233 size_t stream_max_recv_window_size_; | 226 size_t stream_max_recv_window_size_; |
234 TimeFunc time_func_; | 227 TimeFunc time_func_; |
235 | 228 |
236 // Determines if a proxy is a trusted SPDY proxy, which is allowed to push | 229 // Determines if a proxy is a trusted SPDY proxy, which is allowed to push |
237 // resources from origins that are different from those of their associated | 230 // resources from origins that are different from those of their associated |
238 // streams. May be nullptr. | 231 // streams. May be nullptr. |
239 ProxyDelegate* proxy_delegate_; | 232 ProxyDelegate* proxy_delegate_; |
240 | 233 |
241 DISALLOW_COPY_AND_ASSIGN(SpdySessionPool); | 234 DISALLOW_COPY_AND_ASSIGN(SpdySessionPool); |
242 }; | 235 }; |
243 | 236 |
244 } // namespace net | 237 } // namespace net |
245 | 238 |
246 #endif // NET_SPDY_SPDY_SESSION_POOL_H_ | 239 #endif // NET_SPDY_SPDY_SESSION_POOL_H_ |
OLD | NEW |