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_QUIC_QUIC_STREAM_FACTORY_H_ | 5 #ifndef NET_QUIC_QUIC_STREAM_FACTORY_H_ |
6 #define NET_QUIC_QUIC_STREAM_FACTORY_H_ | 6 #define NET_QUIC_QUIC_STREAM_FACTORY_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 // already exists, this method will return OK. If no matching session exists, | 105 // already exists, this method will return OK. If no matching session exists, |
106 // this will return ERR_IO_PENDING and will invoke OnRequestComplete | 106 // this will return ERR_IO_PENDING and will invoke OnRequestComplete |
107 // asynchronously. | 107 // asynchronously. |
108 int Create(const HostPortProxyPair& host_port_proxy_pair, | 108 int Create(const HostPortProxyPair& host_port_proxy_pair, |
109 bool is_https, | 109 bool is_https, |
110 base::StringPiece method, | 110 base::StringPiece method, |
111 CertVerifier* cert_verifier, | 111 CertVerifier* cert_verifier, |
112 const BoundNetLog& net_log, | 112 const BoundNetLog& net_log, |
113 QuicStreamRequest* request); | 113 QuicStreamRequest* request); |
114 | 114 |
115 // Returns a newly created QuicHttpStream owned by the caller, if a | |
116 // matching session already exists. Returns NULL otherwise. | |
117 scoped_ptr<QuicHttpStream> CreateIfSessionExists( | |
118 const HostPortProxyPair& host_port_proxy_pair, | |
119 const BoundNetLog& net_log); | |
120 | |
121 // Called by a session when it becomes idle. | 115 // Called by a session when it becomes idle. |
122 void OnIdleSession(QuicClientSession* session); | 116 void OnIdleSession(QuicClientSession* session); |
123 | 117 |
124 // Called by a session when it is going away and no more streams should be | 118 // Called by a session when it is going away and no more streams should be |
125 // created on it. | 119 // created on it. |
126 void OnSessionGoingAway(QuicClientSession* session); | 120 void OnSessionGoingAway(QuicClientSession* session); |
127 | 121 |
128 // Called by a session after it shuts down. | 122 // Called by a session after it shuts down. |
129 void OnSessionClosed(QuicClientSession* session); | 123 void OnSessionClosed(QuicClientSession* session); |
130 | 124 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 DCHECK(!quic_server_info_factory_); | 157 DCHECK(!quic_server_info_factory_); |
164 quic_server_info_factory_ = quic_server_info_factory; | 158 quic_server_info_factory_ = quic_server_info_factory; |
165 } | 159 } |
166 | 160 |
167 bool enable_pacing() const { return enable_pacing_; } | 161 bool enable_pacing() const { return enable_pacing_; } |
168 | 162 |
169 private: | 163 private: |
170 class Job; | 164 class Job; |
171 friend class test::QuicStreamFactoryPeer; | 165 friend class test::QuicStreamFactoryPeer; |
172 | 166 |
173 typedef std::map<HostPortProxyPair, QuicClientSession*> SessionMap; | 167 struct SessionKey { |
174 typedef std::set<HostPortProxyPair> AliasSet; | 168 SessionKey(); |
| 169 SessionKey(HostPortProxyPair host_port_proxy_pair, |
| 170 bool is_https); |
| 171 ~SessionKey(); |
| 172 |
| 173 HostPortProxyPair host_port_proxy_pair; |
| 174 bool is_https; |
| 175 |
| 176 // Needed to be an element of std::set. |
| 177 bool operator<(const SessionKey &other) const; |
| 178 bool operator==(const SessionKey &other) const; |
| 179 }; |
| 180 |
| 181 struct IpAliasKey { |
| 182 IpAliasKey(); |
| 183 IpAliasKey(IPEndPoint ip_endpoint, bool is_https); |
| 184 ~IpAliasKey(); |
| 185 |
| 186 IPEndPoint ip_endpoint; |
| 187 bool is_https; |
| 188 |
| 189 // Needed to be an element of std::set. |
| 190 bool operator<(const IpAliasKey &other) const; |
| 191 bool operator==(const IpAliasKey &other) const; |
| 192 }; |
| 193 |
| 194 typedef std::map<SessionKey, QuicClientSession*> SessionMap; |
| 195 typedef std::set<SessionKey> AliasSet; |
175 typedef std::map<QuicClientSession*, AliasSet> SessionAliasMap; | 196 typedef std::map<QuicClientSession*, AliasSet> SessionAliasMap; |
176 typedef std::set<QuicClientSession*> SessionSet; | 197 typedef std::set<QuicClientSession*> SessionSet; |
177 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; | 198 typedef std::map<IpAliasKey, SessionSet> IPAliasMap; |
178 typedef std::map<HostPortProxyPair, QuicCryptoClientConfig*> CryptoConfigMap; | 199 typedef std::map<HostPortProxyPair, QuicCryptoClientConfig*> CryptoConfigMap; |
179 typedef std::map<HostPortPair, HostPortProxyPair> CanonicalHostMap; | 200 typedef std::map<HostPortPair, HostPortProxyPair> CanonicalHostMap; |
180 typedef std::map<HostPortProxyPair, Job*> JobMap; | 201 typedef std::map<SessionKey, Job*> JobMap; |
181 typedef std::map<QuicStreamRequest*, Job*> RequestMap; | 202 typedef std::map<QuicStreamRequest*, Job*> RequestMap; |
182 typedef std::set<QuicStreamRequest*> RequestSet; | 203 typedef std::set<QuicStreamRequest*> RequestSet; |
183 typedef std::map<Job*, RequestSet> JobRequestsMap; | 204 typedef std::map<Job*, RequestSet> JobRequestsMap; |
184 | 205 |
185 bool OnResolution(const HostPortProxyPair& host_port_proxy_pair, | 206 // Returns a newly created QuicHttpStream owned by the caller, if a |
| 207 // matching session already exists. Returns NULL otherwise. |
| 208 scoped_ptr<QuicHttpStream> CreateIfSessionExists(const SessionKey& key, |
| 209 const BoundNetLog& net_log); |
| 210 |
| 211 bool OnResolution(const SessionKey& session_key, |
186 const AddressList& address_list); | 212 const AddressList& address_list); |
187 void OnJobComplete(Job* job, int rv); | 213 void OnJobComplete(Job* job, int rv); |
188 bool HasActiveSession(const HostPortProxyPair& host_port_proxy_pair); | 214 bool HasActiveSession(const SessionKey& session_key) const; |
189 bool HasActiveJob(const HostPortProxyPair& host_port_proxy_pair); | 215 bool HasActiveJob(const SessionKey& session_key) const; |
190 int CreateSession(const HostPortProxyPair& host_port_proxy_pair, | 216 int CreateSession(const HostPortProxyPair& host_port_proxy_pair, |
191 bool is_https, | 217 bool is_https, |
192 CertVerifier* cert_verifier, | 218 CertVerifier* cert_verifier, |
193 const AddressList& address_list, | 219 const AddressList& address_list, |
194 const BoundNetLog& net_log, | 220 const BoundNetLog& net_log, |
195 QuicClientSession** session); | 221 QuicClientSession** session); |
196 void ActivateSession(const HostPortProxyPair& host_port_proxy_pair, | 222 void ActivateSession(const SessionKey& key, |
197 QuicClientSession* session); | 223 QuicClientSession* session); |
198 | 224 |
199 QuicCryptoClientConfig* GetOrCreateCryptoConfig( | 225 QuicCryptoClientConfig* GetOrCreateCryptoConfig( |
200 const HostPortProxyPair& host_port_proxy_pair); | 226 const HostPortProxyPair& host_port_proxy_pair); |
201 | 227 |
202 // If |host_port_proxy_pair| suffix contains ".c.youtube.com" (in future we | 228 // If |host_port_proxy_pair| suffix contains ".c.youtube.com" (in future we |
203 // could support other suffixes), then populate |crypto_config| with a | 229 // could support other suffixes), then populate |crypto_config| with a |
204 // canonical server config data from |canonical_hostname_to_origin_map_| for | 230 // canonical server config data from |canonical_hostname_to_origin_map_| for |
205 // that suffix. | 231 // that suffix. |
206 void PopulateFromCanonicalConfig( | 232 void PopulateFromCanonicalConfig( |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 uint64 port_seed_; | 300 uint64 port_seed_; |
275 | 301 |
276 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 302 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
277 | 303 |
278 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 304 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
279 }; | 305 }; |
280 | 306 |
281 } // namespace net | 307 } // namespace net |
282 | 308 |
283 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 309 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
OLD | NEW |