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

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

Issue 881133004: QUIC - Race two connections. One connection which loads data from disk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comments for Patch Set 10 Created 5 years, 10 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
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 <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 bool has_quic_server_info_factory() { 171 bool has_quic_server_info_factory() {
172 return quic_server_info_factory_ != NULL; 172 return quic_server_info_factory_ != NULL;
173 } 173 }
174 174
175 void set_quic_server_info_factory( 175 void set_quic_server_info_factory(
176 QuicServerInfoFactory* quic_server_info_factory) { 176 QuicServerInfoFactory* quic_server_info_factory) {
177 DCHECK(!quic_server_info_factory_); 177 DCHECK(!quic_server_info_factory_);
178 quic_server_info_factory_ = quic_server_info_factory; 178 quic_server_info_factory_ = quic_server_info_factory;
179 } 179 }
180 180
181 bool enable_connection_racing() const { return enable_connection_racing_; }
182 void set_enable_connection_racing(bool enable_connection_racing) {
183 enable_connection_racing_ = enable_connection_racing;
184 }
185
181 private: 186 private:
182 class Job; 187 class Job;
183 friend class test::QuicStreamFactoryPeer; 188 friend class test::QuicStreamFactoryPeer;
184 189
185 // The key used to find session by ip. Includes 190 // The key used to find session by ip. Includes
186 // the ip address, port, and scheme. 191 // the ip address, port, and scheme.
187 struct NET_EXPORT_PRIVATE IpAliasKey { 192 struct NET_EXPORT_PRIVATE IpAliasKey {
188 IpAliasKey(); 193 IpAliasKey();
189 IpAliasKey(IPEndPoint ip_endpoint, bool is_https); 194 IpAliasKey(IPEndPoint ip_endpoint, bool is_https);
190 ~IpAliasKey(); 195 ~IpAliasKey();
191 196
192 IPEndPoint ip_endpoint; 197 IPEndPoint ip_endpoint;
193 bool is_https; 198 bool is_https;
194 199
195 // Needed to be an element of std::set. 200 // Needed to be an element of std::set.
196 bool operator<(const IpAliasKey &other) const; 201 bool operator<(const IpAliasKey &other) const;
197 bool operator==(const IpAliasKey &other) const; 202 bool operator==(const IpAliasKey &other) const;
198 }; 203 };
199 204
200 typedef std::map<QuicServerId, QuicClientSession*> SessionMap; 205 typedef std::map<QuicServerId, QuicClientSession*> SessionMap;
201 typedef std::map<QuicClientSession*, QuicServerId> SessionIdMap; 206 typedef std::map<QuicClientSession*, QuicServerId> SessionIdMap;
202 typedef std::set<QuicServerId> AliasSet; 207 typedef std::set<QuicServerId> AliasSet;
203 typedef std::map<QuicClientSession*, AliasSet> SessionAliasMap; 208 typedef std::map<QuicClientSession*, AliasSet> SessionAliasMap;
204 typedef std::set<QuicClientSession*> SessionSet; 209 typedef std::set<QuicClientSession*> SessionSet;
205 typedef std::map<IpAliasKey, SessionSet> IPAliasMap; 210 typedef std::map<IpAliasKey, SessionSet> IPAliasMap;
206 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap; 211 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap;
207 typedef std::map<QuicServerId, Job*> JobMap; 212 typedef std::set<Job*> JobSet;
208 typedef std::map<QuicStreamRequest*, Job*> RequestMap; 213 typedef std::map<QuicServerId, JobSet> JobMap;
214 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap;
209 typedef std::set<QuicStreamRequest*> RequestSet; 215 typedef std::set<QuicStreamRequest*> RequestSet;
210 typedef std::map<Job*, RequestSet> JobRequestsMap; 216 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap;
217
218 // Creates a job which doesn't wait for server config to be loaded from the
219 // disk cache. This job is started via a PostTask.
220 void CreateAuxilaryJob(const QuicServerId server_id,
221 bool is_post,
222 const BoundNetLog& net_log);
211 223
212 // Returns a newly created QuicHttpStream owned by the caller, if a 224 // Returns a newly created QuicHttpStream owned by the caller, if a
213 // matching session already exists. Returns NULL otherwise. 225 // matching session already exists. Returns NULL otherwise.
214 scoped_ptr<QuicHttpStream> CreateIfSessionExists(const QuicServerId& key, 226 scoped_ptr<QuicHttpStream> CreateIfSessionExists(const QuicServerId& key,
215 const BoundNetLog& net_log); 227 const BoundNetLog& net_log);
216 228
217 bool OnResolution(const QuicServerId& server_id, 229 bool OnResolution(const QuicServerId& server_id,
218 const AddressList& address_list); 230 const AddressList& address_list);
219 void OnJobComplete(Job* job, int rv); 231 void OnJobComplete(Job* job, int rv);
220 bool HasActiveSession(const QuicServerId& server_id) const; 232 bool HasActiveSession(const QuicServerId& server_id) const;
221 bool HasActiveJob(const QuicServerId& server_id) const; 233 bool HasActiveJob(const QuicServerId& server_id) const;
222 int CreateSession(const QuicServerId& server_id, 234 int CreateSession(const QuicServerId& server_id,
223 scoped_ptr<QuicServerInfo> quic_server_info, 235 scoped_ptr<QuicServerInfo> quic_server_info,
224 const AddressList& address_list, 236 const AddressList& address_list,
225 const BoundNetLog& net_log, 237 const BoundNetLog& net_log,
226 QuicClientSession** session); 238 QuicClientSession** session);
227 void ActivateSession(const QuicServerId& key, 239 void ActivateSession(const QuicServerId& key,
228 QuicClientSession* session); 240 QuicClientSession* session);
229 241
230 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there 242 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there
231 // is no |http_server_properties_| or if |http_server_properties_| doesn't 243 // is no |http_server_properties_| or if |http_server_properties_| doesn't
232 // have ServerNetworkStats for the given |server_id|. 244 // have ServerNetworkStats for the given |server_id|.
233 int64 GetServerNetworkStatsSmoothedRttInMicroseconds( 245 int64 GetServerNetworkStatsSmoothedRttInMicroseconds(
234 const QuicServerId& server_id) const; 246 const QuicServerId& server_id) const;
235 247
248 // Helped methods.
249 bool WasAlternateProtocolRecentlyBroken(const QuicServerId& server_id) const;
250 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id);
251
236 // Initializes the cached state associated with |server_id| in 252 // Initializes the cached state associated with |server_id| in
237 // |crypto_config_| with the information in |server_info|. 253 // |crypto_config_| with the information in |server_info|.
238 void InitializeCachedStateInCryptoConfig( 254 void InitializeCachedStateInCryptoConfig(
239 const QuicServerId& server_id, 255 const QuicServerId& server_id,
240 const scoped_ptr<QuicServerInfo>& server_info); 256 const scoped_ptr<QuicServerInfo>& server_info);
241 257
242 void ProcessGoingAwaySession(QuicClientSession* session, 258 void ProcessGoingAwaySession(QuicClientSession* session,
243 const QuicServerId& server_id, 259 const QuicServerId& server_id,
244 bool was_session_active); 260 bool was_session_active);
245 261
(...skipping 21 matching lines...) Expand all
267 // Map from IP address to sessions which are connected to this address. 283 // Map from IP address to sessions which are connected to this address.
268 IPAliasMap ip_aliases_; 284 IPAliasMap ip_aliases_;
269 285
270 // Origins which have gone away recently. 286 // Origins which have gone away recently.
271 AliasSet gone_away_aliases_; 287 AliasSet gone_away_aliases_;
272 288
273 const QuicConfig config_; 289 const QuicConfig config_;
274 QuicCryptoClientConfig crypto_config_; 290 QuicCryptoClientConfig crypto_config_;
275 291
276 JobMap active_jobs_; 292 JobMap active_jobs_;
277 JobRequestsMap job_requests_map_; 293 ServerIDRequestsMap job_requests_map_;
278 RequestMap active_requests_; 294 RequestMap active_requests_;
279 295
280 QuicVersionVector supported_versions_; 296 QuicVersionVector supported_versions_;
281 297
282 // Determine if we should consistently select a client UDP port. If false, 298 // Determine if we should consistently select a client UDP port. If false,
283 // then we will just let the OS select a random client port for each new 299 // then we will just let the OS select a random client port for each new
284 // connection. 300 // connection.
285 bool enable_port_selection_; 301 bool enable_port_selection_;
286 302
287 // Set if we always require handshake confirmation. If true, this will 303 // Set if we always require handshake confirmation. If true, this will
(...skipping 10 matching lines...) Expand all
298 314
299 // Specifies the ratio between time to load QUIC server information from disk 315 // Specifies the ratio between time to load QUIC server information from disk
300 // cache to 'smoothed RTT'. This ratio is used to calculate the timeout in 316 // cache to 'smoothed RTT'. This ratio is used to calculate the timeout in
301 // milliseconds to wait for loading of QUIC server information. If we don't 317 // milliseconds to wait for loading of QUIC server information. If we don't
302 // want to timeout, set |load_server_info_timeout_srtt_multiplier_| to 0. 318 // want to timeout, set |load_server_info_timeout_srtt_multiplier_| to 0.
303 float load_server_info_timeout_srtt_multiplier_; 319 float load_server_info_timeout_srtt_multiplier_;
304 320
305 // Set this for setting config's BytesForConnectionIdToSend (TCID param) to 0. 321 // Set this for setting config's BytesForConnectionIdToSend (TCID param) to 0.
306 bool enable_truncated_connection_ids_; 322 bool enable_truncated_connection_ids_;
307 323
324 // Set if we want to race connections - one connection that sends
325 // INCHOATE_HELLO and another connection that sends CHLO after loading server
326 // config from the disk cache.
327 bool enable_connection_racing_;
328
308 // Each profile will (probably) have a unique port_seed_ value. This value is 329 // Each profile will (probably) have a unique port_seed_ value. This value is
309 // used to help seed a pseudo-random number generator (PortSuggester) so that 330 // used to help seed a pseudo-random number generator (PortSuggester) so that
310 // we consistently (within this profile) suggest the same ephemeral port when 331 // we consistently (within this profile) suggest the same ephemeral port when
311 // we re-connect to any given server/port. The differences between profiles 332 // we re-connect to any given server/port. The differences between profiles
312 // (probablistically) prevent two profiles from colliding in their ephemeral 333 // (probablistically) prevent two profiles from colliding in their ephemeral
313 // port requests. 334 // port requests.
314 uint64 port_seed_; 335 uint64 port_seed_;
315 336
316 // Local address of socket that was created in CreateSession. 337 // Local address of socket that was created in CreateSession.
317 IPEndPoint local_address_; 338 IPEndPoint local_address_;
318 bool check_persisted_supports_quic_; 339 bool check_persisted_supports_quic_;
319 std::set<HostPortPair> quic_supported_servers_at_startup_; 340 std::set<HostPortPair> quic_supported_servers_at_startup_;
320 341
321 base::TaskRunner* task_runner_; 342 base::TaskRunner* task_runner_;
322 343
323 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; 344 base::WeakPtrFactory<QuicStreamFactory> weak_factory_;
324 345
325 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); 346 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory);
326 }; 347 };
327 348
328 } // namespace net 349 } // namespace net
329 350
330 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ 351 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698