Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(329)

Side by Side Diff: net/quic/quic_stream_factory.h

Issue 190063008: Include the scheme in the key for QUIC the session map. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: net-internals Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 // The key used to find session by hostname. Includes
174 typedef std::set<HostPortProxyPair> AliasSet; 168 // the hostname, port, and scheme.
169 struct SessionKey {
170 SessionKey();
171 SessionKey(HostPortProxyPair host_port_proxy_pair,
172 bool is_https);
173 ~SessionKey();
174
175 HostPortProxyPair host_port_proxy_pair;
176 bool is_https;
177
178 // Needed to be an element of std::set.
179 bool operator<(const SessionKey &other) const;
180 bool operator==(const SessionKey &other) const;
181 };
182
183 // The key used to find session by hostname. Includes
184 // the ip address, port, and scheme.
185 struct IpAliasKey {
186 IpAliasKey();
187 IpAliasKey(IPEndPoint ip_endpoint, bool is_https);
188 ~IpAliasKey();
189
190 IPEndPoint ip_endpoint;
191 bool is_https;
192
193 // Needed to be an element of std::set.
194 bool operator<(const IpAliasKey &other) const;
195 bool operator==(const IpAliasKey &other) const;
196 };
197
198 typedef std::map<SessionKey, QuicClientSession*> SessionMap;
199 typedef std::set<SessionKey> AliasSet;
175 typedef std::map<QuicClientSession*, AliasSet> SessionAliasMap; 200 typedef std::map<QuicClientSession*, AliasSet> SessionAliasMap;
176 typedef std::set<QuicClientSession*> SessionSet; 201 typedef std::set<QuicClientSession*> SessionSet;
177 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; 202 typedef std::map<IpAliasKey, SessionSet> IPAliasMap;
178 typedef std::map<HostPortProxyPair, QuicCryptoClientConfig*> CryptoConfigMap; 203 typedef std::map<SessionKey, QuicCryptoClientConfig*> CryptoConfigMap;
179 typedef std::map<HostPortPair, HostPortProxyPair> CanonicalHostMap; 204 typedef std::map<SessionKey, SessionKey> CanonicalHostMap;
180 typedef std::map<HostPortProxyPair, Job*> JobMap; 205 typedef std::map<SessionKey, Job*> JobMap;
181 typedef std::map<QuicStreamRequest*, Job*> RequestMap; 206 typedef std::map<QuicStreamRequest*, Job*> RequestMap;
182 typedef std::set<QuicStreamRequest*> RequestSet; 207 typedef std::set<QuicStreamRequest*> RequestSet;
183 typedef std::map<Job*, RequestSet> JobRequestsMap; 208 typedef std::map<Job*, RequestSet> JobRequestsMap;
184 209
185 bool OnResolution(const HostPortProxyPair& host_port_proxy_pair, 210 // Returns a newly created QuicHttpStream owned by the caller, if a
211 // matching session already exists. Returns NULL otherwise.
212 scoped_ptr<QuicHttpStream> CreateIfSessionExists(const SessionKey& key,
213 const BoundNetLog& net_log);
214
215 bool OnResolution(const SessionKey& session_key,
186 const AddressList& address_list); 216 const AddressList& address_list);
187 void OnJobComplete(Job* job, int rv); 217 void OnJobComplete(Job* job, int rv);
188 bool HasActiveSession(const HostPortProxyPair& host_port_proxy_pair); 218 bool HasActiveSession(const SessionKey& session_key) const;
189 bool HasActiveJob(const HostPortProxyPair& host_port_proxy_pair); 219 bool HasActiveJob(const SessionKey& session_key) const;
190 int CreateSession(const HostPortProxyPair& host_port_proxy_pair, 220 int CreateSession(const HostPortProxyPair& host_port_proxy_pair,
191 bool is_https, 221 bool is_https,
192 CertVerifier* cert_verifier, 222 CertVerifier* cert_verifier,
193 const AddressList& address_list, 223 const AddressList& address_list,
194 const BoundNetLog& net_log, 224 const BoundNetLog& net_log,
195 QuicClientSession** session); 225 QuicClientSession** session);
196 void ActivateSession(const HostPortProxyPair& host_port_proxy_pair, 226 void ActivateSession(const SessionKey& key,
197 QuicClientSession* session); 227 QuicClientSession* session);
198 228
199 QuicCryptoClientConfig* GetOrCreateCryptoConfig( 229 QuicCryptoClientConfig* GetOrCreateCryptoConfig(
200 const HostPortProxyPair& host_port_proxy_pair); 230 const SessionKey& session_key);
201 231
202 // If |host_port_proxy_pair| suffix contains ".c.youtube.com" (in future we 232 // If the suffix of the hostname in |session_key| is in |canoncial_suffixes_|,
203 // could support other suffixes), then populate |crypto_config| with a 233 // then populate |crypto_config| with a canonical server config data from
204 // canonical server config data from |canonical_hostname_to_origin_map_| for 234 // |canonical_hostname_to_origin_map_| for that suffix.
205 // that suffix.
206 void PopulateFromCanonicalConfig( 235 void PopulateFromCanonicalConfig(
207 const HostPortProxyPair& host_port_proxy_pair, 236 const SessionKey& session_key,
208 QuicCryptoClientConfig* crypto_config); 237 QuicCryptoClientConfig* crypto_config);
209 238
210 bool require_confirmation_; 239 bool require_confirmation_;
211 HostResolver* host_resolver_; 240 HostResolver* host_resolver_;
212 ClientSocketFactory* client_socket_factory_; 241 ClientSocketFactory* client_socket_factory_;
213 base::WeakPtr<HttpServerProperties> http_server_properties_; 242 base::WeakPtr<HttpServerProperties> http_server_properties_;
214 QuicServerInfoFactory* quic_server_info_factory_; 243 QuicServerInfoFactory* quic_server_info_factory_;
215 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_; 244 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_;
216 QuicRandom* random_generator_; 245 QuicRandom* random_generator_;
217 scoped_ptr<QuicClock> clock_; 246 scoped_ptr<QuicClock> clock_;
(...skipping 15 matching lines...) Expand all
233 // Origins which have gone away recently. 262 // Origins which have gone away recently.
234 AliasSet gone_away_aliases_; 263 AliasSet gone_away_aliases_;
235 264
236 // Contains owning pointers to QuicCryptoClientConfig. QuicCryptoClientConfig 265 // Contains owning pointers to QuicCryptoClientConfig. QuicCryptoClientConfig
237 // contains configuration and cached state about servers. 266 // contains configuration and cached state about servers.
238 // TODO(rtenneti): Persist all_crypto_configs_ to disk and decide when to 267 // TODO(rtenneti): Persist all_crypto_configs_ to disk and decide when to
239 // clear the data in the map. 268 // clear the data in the map.
240 CryptoConfigMap all_crypto_configs_; 269 CryptoConfigMap all_crypto_configs_;
241 270
242 // Contains a map of servers which could share the same server config. Map 271 // Contains a map of servers which could share the same server config. Map
243 // from a Canonical host/port (host is some postfix of host names) to an 272 // from a Canonical host/port/scheme (host is some postfix of host names) to
244 // actual origin, which has a plausible set of initial certificates (or at 273 // an actual origin, which has a plausible set of initial certificates (or at
245 // least server public key). 274 // least server public key).
246 CanonicalHostMap canonical_hostname_to_origin_map_; 275 CanonicalHostMap canonical_hostname_to_origin_map_;
247 276
248 // Contains list of suffixes (for exmaple ".c.youtube.com", 277 // Contains list of suffixes (for exmaple ".c.youtube.com",
249 // ".googlevideo.com") of canoncial hostnames. 278 // ".googlevideo.com") of canoncial hostnames.
250 std::vector<std::string> canoncial_suffixes_; 279 std::vector<std::string> canoncial_suffixes_;
251 280
252 QuicConfig config_; 281 QuicConfig config_;
253 282
254 JobMap active_jobs_; 283 JobMap active_jobs_;
(...skipping 19 matching lines...) Expand all
274 uint64 port_seed_; 303 uint64 port_seed_;
275 304
276 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; 305 base::WeakPtrFactory<QuicStreamFactory> weak_factory_;
277 306
278 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); 307 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory);
279 }; 308 };
280 309
281 } // namespace net 310 } // namespace net
282 311
283 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ 312 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698