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 <map> | 8 #include <map> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // was no error. | 77 // was no error. |
78 // | 78 // |
79 // If successful, OK is returned and |available_session| will be | 79 // If successful, OK is returned and |available_session| will be |
80 // non-NULL and available. Otherwise, an error is returned and | 80 // non-NULL and available. Otherwise, an error is returned and |
81 // |available_session| will be NULL. | 81 // |available_session| will be NULL. |
82 net::Error CreateAvailableSessionFromSocket( | 82 net::Error CreateAvailableSessionFromSocket( |
83 const SpdySessionKey& key, | 83 const SpdySessionKey& key, |
84 scoped_ptr<ClientSocketHandle> connection, | 84 scoped_ptr<ClientSocketHandle> connection, |
85 const BoundNetLog& net_log, | 85 const BoundNetLog& net_log, |
86 int certificate_error_code, | 86 int certificate_error_code, |
87 scoped_refptr<SpdySession>* available_session, | 87 base::WeakPtr<SpdySession>* available_session, |
88 bool is_secure); | 88 bool is_secure); |
89 | 89 |
90 // Find an available session for the given key, or NULL if there isn't one. | 90 // Find an available session for the given key, or NULL if there isn't one. |
91 scoped_refptr<SpdySession> FindAvailableSession(const SpdySessionKey& key, | 91 base::WeakPtr<SpdySession> FindAvailableSession(const SpdySessionKey& key, |
92 const BoundNetLog& net_log); | 92 const BoundNetLog& net_log); |
93 | 93 |
94 // Remove all mappings and aliases for the given session, which must | 94 // Remove all mappings and aliases for the given session, which must |
95 // still be available. Except for in tests, this must be called by | 95 // still be available. Except for in tests, this must be called by |
96 // the given session itself. | 96 // the given session itself. |
97 void MakeSessionUnavailable( | 97 void MakeSessionUnavailable( |
98 const scoped_refptr<SpdySession>& available_session); | 98 const base::WeakPtr<SpdySession>& available_session); |
99 | 99 |
100 // Removes an unavailable session from the pool. Except for in | 100 // Removes an unavailable session from the pool. Except for in |
101 // tests, this must be called by the given session itself. | 101 // tests, this must be called by the given session itself. |
102 void RemoveUnavailableSession( | 102 void RemoveUnavailableSession( |
103 const scoped_refptr<SpdySession>& unavailable_session); | 103 const base::WeakPtr<SpdySession>& unavailable_session); |
104 | 104 |
105 // Close only the currently existing SpdySessions with |error|. | 105 // Close only the currently existing SpdySessions with |error|. |
106 // Let any new ones created while this method is running continue to | 106 // Let any new ones created while this method is running continue to |
107 // live. | 107 // live. |
108 void CloseCurrentSessions(net::Error error); | 108 void CloseCurrentSessions(net::Error error); |
109 | 109 |
110 // Close only the currently existing SpdySessions that are idle. | 110 // Close only the currently existing SpdySessions that are idle. |
111 // Let any new ones created while this method is running continue to | 111 // Let any new ones created while this method is running continue to |
112 // live. | 112 // live. |
113 void CloseCurrentIdleSessions(); | 113 void CloseCurrentIdleSessions(); |
(...skipping 23 matching lines...) Expand all Loading... |
137 virtual void OnSSLConfigChanged() OVERRIDE; | 137 virtual void OnSSLConfigChanged() OVERRIDE; |
138 | 138 |
139 // CertDatabase::Observer methods: | 139 // CertDatabase::Observer methods: |
140 virtual void OnCertAdded(const X509Certificate* cert) OVERRIDE; | 140 virtual void OnCertAdded(const X509Certificate* cert) OVERRIDE; |
141 virtual void OnCertTrustChanged(const X509Certificate* cert) OVERRIDE; | 141 virtual void OnCertTrustChanged(const X509Certificate* cert) OVERRIDE; |
142 | 142 |
143 private: | 143 private: |
144 friend class SpdySessionPoolPeer; // For testing. | 144 friend class SpdySessionPoolPeer; // For testing. |
145 | 145 |
146 typedef std::set<scoped_refptr<SpdySession> > SessionSet; | 146 typedef std::set<scoped_refptr<SpdySession> > SessionSet; |
147 typedef std::map<SpdySessionKey, scoped_refptr<SpdySession> > | 147 typedef std::map<SpdySessionKey, base::WeakPtr<SpdySession> > |
148 AvailableSessionMap; | 148 AvailableSessionMap; |
149 typedef std::map<IPEndPoint, SpdySessionKey> AliasMap; | 149 typedef std::map<IPEndPoint, SpdySessionKey> AliasMap; |
150 | 150 |
151 // Returns true iff |session| is in |available_sessions_|. | 151 // Returns true iff |session| is in |available_sessions_|. |
152 bool IsSessionAvailable(const scoped_refptr<SpdySession>& session) const; | 152 bool IsSessionAvailable(const base::WeakPtr<SpdySession>& session) const; |
153 | 153 |
154 // Returns a normalized version of the given key suitable for lookup | 154 // Returns a normalized version of the given key suitable for lookup |
155 // into |available_sessions_|. | 155 // into |available_sessions_|. |
156 const SpdySessionKey& NormalizeListKey(const SpdySessionKey& key) const; | 156 const SpdySessionKey& NormalizeListKey(const SpdySessionKey& key) const; |
157 | 157 |
158 // Map the given key to the given session. There must not already be | 158 // Map the given key to the given session. There must not already be |
159 // a mapping for |key|. | 159 // a mapping for |key|. |
160 void MapKeyToAvailableSession(const SpdySessionKey& key, | 160 void MapKeyToAvailableSession(const SpdySessionKey& key, |
161 const scoped_refptr<SpdySession>& session); | 161 const base::WeakPtr<SpdySession>& session); |
162 | 162 |
163 // Returns an iterator into |available_sessions_| for the given key, | 163 // Returns an iterator into |available_sessions_| for the given key, |
164 // which may be equal to |available_sessions_.end()|. | 164 // which may be equal to |available_sessions_.end()|. |
165 AvailableSessionMap::iterator LookupAvailableSessionByKey( | 165 AvailableSessionMap::iterator LookupAvailableSessionByKey( |
166 const SpdySessionKey& key); | 166 const SpdySessionKey& key); |
167 | 167 |
168 // Remove the mapping of the given key, which must exist. | 168 // Remove the mapping of the given key, which must exist. |
169 void UnmapKey(const SpdySessionKey& key); | 169 void UnmapKey(const SpdySessionKey& key); |
170 | 170 |
171 // Remove all aliases for |key| from the aliases table. | 171 // Remove all aliases for |key| from the aliases table. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 // This SPDY proxy is allowed to push resources from origins that are | 214 // This SPDY proxy is allowed to push resources from origins that are |
215 // different from those of their associated streams. | 215 // different from those of their associated streams. |
216 HostPortPair trusted_spdy_proxy_; | 216 HostPortPair trusted_spdy_proxy_; |
217 | 217 |
218 DISALLOW_COPY_AND_ASSIGN(SpdySessionPool); | 218 DISALLOW_COPY_AND_ASSIGN(SpdySessionPool); |
219 }; | 219 }; |
220 | 220 |
221 } // namespace net | 221 } // namespace net |
222 | 222 |
223 #endif // NET_SPDY_SPDY_SESSION_POOL_H_ | 223 #endif // NET_SPDY_SPDY_SESSION_POOL_H_ |
OLD | NEW |