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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 const std::string& user_agent_id, | 191 const std::string& user_agent_id, |
192 const QuicVersionVector& supported_versions, | 192 const QuicVersionVector& supported_versions, |
193 bool enable_port_selection, | 193 bool enable_port_selection, |
194 bool always_require_handshake_confirmation, | 194 bool always_require_handshake_confirmation, |
195 bool disable_connection_pooling, | 195 bool disable_connection_pooling, |
196 float load_server_info_timeout_srtt_multiplier, | 196 float load_server_info_timeout_srtt_multiplier, |
197 bool enable_connection_racing, | 197 bool enable_connection_racing, |
198 bool enable_non_blocking_io, | 198 bool enable_non_blocking_io, |
199 bool disable_disk_cache, | 199 bool disable_disk_cache, |
200 bool prefer_aes, | 200 bool prefer_aes, |
201 int max_number_of_lossy_connections, | |
202 float packet_loss_threshold, | |
203 int max_recent_disabled_reasons, | |
204 int threshold_timeouts_with_streams_open, | |
205 int threshold_public_resets_post_handshake, | |
206 int socket_receive_buffer_size, | 201 int socket_receive_buffer_size, |
207 bool delay_tcp_race, | 202 bool delay_tcp_race, |
208 int max_server_configs_stored_in_properties, | 203 int max_server_configs_stored_in_properties, |
209 bool close_sessions_on_ip_change, | 204 bool close_sessions_on_ip_change, |
210 bool disable_quic_on_timeout_with_open_streams, | 205 bool disable_quic_on_timeout_with_open_streams, |
211 int idle_connection_timeout_seconds, | 206 int idle_connection_timeout_seconds, |
212 int reduced_ping_timeout_seconds, | 207 int reduced_ping_timeout_seconds, |
213 int packet_reader_yield_after_duration_milliseconds, | 208 int packet_reader_yield_after_duration_milliseconds, |
214 bool migrate_sessions_on_network_change, | 209 bool migrate_sessions_on_network_change, |
215 bool migrate_sessions_early, | 210 bool migrate_sessions_early, |
(...skipping 17 matching lines...) Expand all Loading... |
233 // matching session exists, this will return ERR_IO_PENDING and will invoke | 228 // matching session exists, this will return ERR_IO_PENDING and will invoke |
234 // OnRequestComplete asynchronously. | 229 // OnRequestComplete asynchronously. |
235 int Create(const QuicServerId& server_id, | 230 int Create(const QuicServerId& server_id, |
236 const HostPortPair& destination, | 231 const HostPortPair& destination, |
237 int cert_verify_flags, | 232 int cert_verify_flags, |
238 const GURL& url, | 233 const GURL& url, |
239 base::StringPiece method, | 234 base::StringPiece method, |
240 const BoundNetLog& net_log, | 235 const BoundNetLog& net_log, |
241 QuicStreamRequest* request); | 236 QuicStreamRequest* request); |
242 | 237 |
243 // If |packet_loss_rate| is greater than or equal to |packet_loss_threshold_| | 238 // Called when the handshake for |session| is confirmed. If QUIC is disabled |
244 // it marks QUIC as recently broken for the port of the session. Increments | 239 // currently disabled, then it closes the connection and returns true. |
245 // |number_of_lossy_connections_| by port. If |number_of_lossy_connections_| | 240 bool OnHandshakeConfirmed(QuicChromiumClientSession* session); |
246 // is greater than or equal to |max_number_of_lossy_connections_| then it | |
247 // disables QUIC. If QUIC is disabled then it closes the connection. | |
248 // | |
249 // Returns true if QUIC is disabled for the port of the session. | |
250 bool OnHandshakeConfirmed(QuicChromiumClientSession* session, | |
251 float packet_loss_rate); | |
252 | 241 |
253 // Called when a TCP job completes for an origin that QUIC potentially | 242 // Called when a TCP job completes for an origin that QUIC potentially |
254 // could be used for. | 243 // could be used for. |
255 void OnTcpJobCompleted(bool succeeded); | 244 void OnTcpJobCompleted(bool succeeded); |
256 | 245 |
257 // Returns true if QUIC is disabled for this port. | 246 // Returns true if QUIC is disabled. |
258 bool IsQuicDisabled(uint16_t port) const; | 247 bool IsQuicDisabled() const; |
259 | |
260 // Returns reason QUIC is disabled for this port, or QUIC_DISABLED_NOT if not. | |
261 QuicChromiumClientSession::QuicDisabledReason QuicDisabledReason( | |
262 uint16_t port) const; | |
263 | |
264 // Returns reason QUIC is disabled as string for net-internals, or | |
265 // returns empty string if QUIC is not disabled. | |
266 const char* QuicDisabledReasonString() const; | |
267 | 248 |
268 // Called by a session when it becomes idle. | 249 // Called by a session when it becomes idle. |
269 void OnIdleSession(QuicChromiumClientSession* session); | 250 void OnIdleSession(QuicChromiumClientSession* session); |
270 | 251 |
271 // Called by a session when it is going away and no more streams should be | 252 // Called by a session when it is going away and no more streams should be |
272 // created on it. | 253 // created on it. |
273 void OnSessionGoingAway(QuicChromiumClientSession* session); | 254 void OnSessionGoingAway(QuicChromiumClientSession* session); |
274 | 255 |
275 // Called by a session after it shuts down. | 256 // Called by a session after it shuts down. |
276 void OnSessionClosed(QuicChromiumClientSession* session); | 257 void OnSessionClosed(QuicChromiumClientSession* session); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 bool delay_tcp_race() const { return delay_tcp_race_; } | 380 bool delay_tcp_race() const { return delay_tcp_race_; } |
400 | 381 |
401 bool migrate_sessions_on_network_change() const { | 382 bool migrate_sessions_on_network_change() const { |
402 return migrate_sessions_on_network_change_; | 383 return migrate_sessions_on_network_change_; |
403 } | 384 } |
404 | 385 |
405 private: | 386 private: |
406 class Job; | 387 class Job; |
407 class CertVerifierJob; | 388 class CertVerifierJob; |
408 friend class test::QuicStreamFactoryPeer; | 389 friend class test::QuicStreamFactoryPeer; |
409 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad); | |
410 | 390 |
411 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap; | 391 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap; |
412 typedef std::map<QuicChromiumClientSession*, QuicSessionKey> SessionIdMap; | 392 typedef std::map<QuicChromiumClientSession*, QuicSessionKey> SessionIdMap; |
413 typedef std::set<QuicSessionKey> AliasSet; | 393 typedef std::set<QuicSessionKey> AliasSet; |
414 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap; | 394 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap; |
415 typedef std::set<QuicChromiumClientSession*> SessionSet; | 395 typedef std::set<QuicChromiumClientSession*> SessionSet; |
416 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; | 396 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; |
417 typedef std::map<QuicChromiumClientSession*, IPEndPoint> SessionPeerIPMap; | 397 typedef std::map<QuicChromiumClientSession*, IPEndPoint> SessionPeerIPMap; |
418 typedef std::set<Job*> JobSet; | 398 typedef std::set<Job*> JobSet; |
419 typedef std::map<QuicServerId, JobSet> JobMap; | 399 typedef std::map<QuicServerId, JobSet> JobMap; |
420 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; | 400 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; |
421 typedef std::set<QuicStreamRequest*> RequestSet; | 401 typedef std::set<QuicStreamRequest*> RequestSet; |
422 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; | 402 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; |
423 typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason> | |
424 DisabledReasonsQueue; | |
425 typedef std::map<QuicServerId, std::unique_ptr<CertVerifierJob>> | 403 typedef std::map<QuicServerId, std::unique_ptr<CertVerifierJob>> |
426 CertVerifierJobMap; | 404 CertVerifierJobMap; |
427 | 405 |
428 enum FactoryStatus { | 406 enum FactoryStatus { |
429 OPEN, // New streams may be created. | 407 OPEN, // New streams may be created. |
430 CLOSED, // No new streams may be created temporarily. | 408 CLOSED, // No new streams may be created temporarily. |
431 DISABLED // No more streams may be created until the network changes. | 409 DISABLED // No more streams may be created until the network changes. |
432 }; | 410 }; |
433 | 411 |
434 // Creates a job which doesn't wait for server config to be loaded from the | 412 // Creates a job which doesn't wait for server config to be loaded from the |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 464 |
487 // Initialize |quic_supported_servers_at_startup_| with the list of servers | 465 // Initialize |quic_supported_servers_at_startup_| with the list of servers |
488 // that supported QUIC at start up and also initialize in-memory cache of | 466 // that supported QUIC at start up and also initialize in-memory cache of |
489 // QuicServerInfo objects from HttpServerProperties. | 467 // QuicServerInfo objects from HttpServerProperties. |
490 void MaybeInitialize(); | 468 void MaybeInitialize(); |
491 | 469 |
492 void ProcessGoingAwaySession(QuicChromiumClientSession* session, | 470 void ProcessGoingAwaySession(QuicChromiumClientSession* session, |
493 const QuicServerId& server_id, | 471 const QuicServerId& server_id, |
494 bool was_session_active); | 472 bool was_session_active); |
495 | 473 |
496 // Collect stats from recent connections, possibly disabling Quic. | |
497 void MaybeDisableQuic(QuicChromiumClientSession* session); | |
498 | |
499 void MaybeDisableQuic(uint16_t port); | |
500 | |
501 // Internal method that migrates |session| over to using | 474 // Internal method that migrates |session| over to using |
502 // |peer_address| and |network|. If |network| is | 475 // |peer_address| and |network|. If |network| is |
503 // kInvalidNetworkHandle, default network is used. If the migration | 476 // kInvalidNetworkHandle, default network is used. If the migration |
504 // fails and |close_session_on_error| is true, connection is closed. | 477 // fails and |close_session_on_error| is true, connection is closed. |
505 MigrationResult MigrateSessionInner( | 478 MigrationResult MigrateSessionInner( |
506 QuicChromiumClientSession* session, | 479 QuicChromiumClientSession* session, |
507 IPEndPoint peer_address, | 480 IPEndPoint peer_address, |
508 NetworkChangeNotifier::NetworkHandle network, | 481 NetworkChangeNotifier::NetworkHandle network, |
509 bool close_session_on_error, | 482 bool close_session_on_error, |
510 const BoundNetLog& bound_net_log); | 483 const BoundNetLog& bound_net_log); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 | 557 |
585 // Set if experimental non-blocking IO should be used on windows sockets. | 558 // Set if experimental non-blocking IO should be used on windows sockets. |
586 bool enable_non_blocking_io_; | 559 bool enable_non_blocking_io_; |
587 | 560 |
588 // Set if we do not want to load server config from the disk cache. | 561 // Set if we do not want to load server config from the disk cache. |
589 bool disable_disk_cache_; | 562 bool disable_disk_cache_; |
590 | 563 |
591 // Set if AES-GCM should be preferred, even if there is no hardware support. | 564 // Set if AES-GCM should be preferred, even if there is no hardware support. |
592 bool prefer_aes_; | 565 bool prefer_aes_; |
593 | 566 |
594 // Set if we want to disable QUIC when there is high packet loss rate. | 567 // True if QUIC should be disabled when there are timeouts with open |
595 // Specifies the maximum number of connections with high packet loss in a row | 568 // streams. |
596 // after which QUIC will be disabled. | 569 bool disable_quic_on_timeout_with_open_streams_; |
597 int max_number_of_lossy_connections_; | |
598 // Specifies packet loss rate in fraction after which a connection is closed | |
599 // and is considered as a lossy connection. | |
600 float packet_loss_threshold_; | |
601 // Count number of lossy connections by port. | |
602 std::map<uint16_t, int> number_of_lossy_connections_; | |
603 | |
604 // Keep track of stats for recently closed connections, using a | |
605 // bounded queue. | |
606 int max_disabled_reasons_; | |
607 DisabledReasonsQueue disabled_reasons_; | |
608 // Events that can trigger disabling QUIC | |
609 int num_public_resets_post_handshake_; | |
610 int num_timeouts_with_open_streams_; | |
611 // Keep track the largest values for UMA histograms, that will help | |
612 // determine good threshold values. | |
613 int max_public_resets_post_handshake_; | |
614 int max_timeouts_with_open_streams_; | |
615 // Thresholds if greater than zero, determine when to | |
616 int threshold_timeouts_with_open_streams_; | |
617 int threshold_public_resets_post_handshake_; | |
618 | 570 |
619 // Size of the UDP receive buffer. | 571 // Size of the UDP receive buffer. |
620 int socket_receive_buffer_size_; | 572 int socket_receive_buffer_size_; |
621 | 573 |
622 // Set if we do want to delay TCP connection when it is racing with QUIC. | 574 // Set if we do want to delay TCP connection when it is racing with QUIC. |
623 bool delay_tcp_race_; | 575 bool delay_tcp_race_; |
624 | 576 |
625 // PING timeout for connections. | 577 // PING timeout for connections. |
626 QuicTime::Delta ping_timeout_; | 578 QuicTime::Delta ping_timeout_; |
627 QuicTime::Delta reduced_ping_timeout_; | 579 QuicTime::Delta reduced_ping_timeout_; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 const scoped_refptr<SSLConfigService> ssl_config_service_; | 636 const scoped_refptr<SSLConfigService> ssl_config_service_; |
685 | 637 |
686 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 638 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
687 | 639 |
688 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 640 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
689 }; | 641 }; |
690 | 642 |
691 } // namespace net | 643 } // namespace net |
692 | 644 |
693 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 645 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
OLD | NEW |