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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 const std::string& user_agent_id, | 172 const std::string& user_agent_id, |
173 const QuicVersionVector& supported_versions, | 173 const QuicVersionVector& supported_versions, |
174 bool enable_port_selection, | 174 bool enable_port_selection, |
175 bool always_require_handshake_confirmation, | 175 bool always_require_handshake_confirmation, |
176 bool disable_connection_pooling, | 176 bool disable_connection_pooling, |
177 float load_server_info_timeout_srtt_multiplier, | 177 float load_server_info_timeout_srtt_multiplier, |
178 bool enable_connection_racing, | 178 bool enable_connection_racing, |
179 bool enable_non_blocking_io, | 179 bool enable_non_blocking_io, |
180 bool disable_disk_cache, | 180 bool disable_disk_cache, |
181 bool prefer_aes, | 181 bool prefer_aes, |
| 182 int max_number_of_lossy_connections, |
| 183 float packet_loss_threshold, |
| 184 int max_recent_disabled_reasons, |
| 185 int threshold_timeouts_with_streams_open, |
| 186 int threshold_public_resets_post_handshake, |
182 int socket_receive_buffer_size, | 187 int socket_receive_buffer_size, |
183 bool delay_tcp_race, | 188 bool delay_tcp_race, |
184 int max_server_configs_stored_in_properties, | 189 int max_server_configs_stored_in_properties, |
185 bool close_sessions_on_ip_change, | 190 bool close_sessions_on_ip_change, |
186 bool disable_quic_on_timeout_with_open_streams, | 191 bool disable_quic_on_timeout_with_open_streams, |
187 int idle_connection_timeout_seconds, | 192 int idle_connection_timeout_seconds, |
188 int reduced_ping_timeout_seconds, | 193 int reduced_ping_timeout_seconds, |
189 int packet_reader_yield_after_duration_milliseconds, | 194 int packet_reader_yield_after_duration_milliseconds, |
190 bool migrate_sessions_on_network_change, | 195 bool migrate_sessions_on_network_change, |
191 bool migrate_sessions_early, | 196 bool migrate_sessions_early, |
(...skipping 17 matching lines...) Expand all Loading... |
209 // matching session exists, this will return ERR_IO_PENDING and will invoke | 214 // matching session exists, this will return ERR_IO_PENDING and will invoke |
210 // OnRequestComplete asynchronously. | 215 // OnRequestComplete asynchronously. |
211 int Create(const QuicServerId& server_id, | 216 int Create(const QuicServerId& server_id, |
212 const HostPortPair& destination, | 217 const HostPortPair& destination, |
213 int cert_verify_flags, | 218 int cert_verify_flags, |
214 const GURL& url, | 219 const GURL& url, |
215 base::StringPiece method, | 220 base::StringPiece method, |
216 const BoundNetLog& net_log, | 221 const BoundNetLog& net_log, |
217 QuicStreamRequest* request); | 222 QuicStreamRequest* request); |
218 | 223 |
219 // Called when the handshake for |session| is confirmed. If QUIC is disabled | 224 // If |packet_loss_rate| is greater than or equal to |packet_loss_threshold_| |
220 // currently disabled, then it closes the connection and returns true. | 225 // it marks QUIC as recently broken for the port of the session. Increments |
221 bool OnHandshakeConfirmed(QuicChromiumClientSession* session); | 226 // |number_of_lossy_connections_| by port. If |number_of_lossy_connections_| |
| 227 // is greater than or equal to |max_number_of_lossy_connections_| then it |
| 228 // disables QUIC. If QUIC is disabled then it closes the connection. |
| 229 // |
| 230 // Returns true if QUIC is disabled for the port of the session. |
| 231 bool OnHandshakeConfirmed(QuicChromiumClientSession* session, |
| 232 float packet_loss_rate); |
222 | 233 |
223 // Called when a TCP job completes for an origin that QUIC potentially | 234 // Called when a TCP job completes for an origin that QUIC potentially |
224 // could be used for. | 235 // could be used for. |
225 void OnTcpJobCompleted(bool succeeded); | 236 void OnTcpJobCompleted(bool succeeded); |
226 | 237 |
227 // Returns true if QUIC is disabled. | 238 // Returns true if QUIC is disabled for this port. |
228 bool IsQuicDisabled() const; | 239 bool IsQuicDisabled(uint16_t port) const; |
| 240 |
| 241 // Returns reason QUIC is disabled for this port, or QUIC_DISABLED_NOT if not. |
| 242 QuicChromiumClientSession::QuicDisabledReason QuicDisabledReason( |
| 243 uint16_t port) const; |
| 244 |
| 245 // Returns reason QUIC is disabled as string for net-internals, or |
| 246 // returns empty string if QUIC is not disabled. |
| 247 const char* QuicDisabledReasonString() const; |
229 | 248 |
230 // Called by a session when it becomes idle. | 249 // Called by a session when it becomes idle. |
231 void OnIdleSession(QuicChromiumClientSession* session); | 250 void OnIdleSession(QuicChromiumClientSession* session); |
232 | 251 |
233 // 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 |
234 // created on it. | 253 // created on it. |
235 void OnSessionGoingAway(QuicChromiumClientSession* session); | 254 void OnSessionGoingAway(QuicChromiumClientSession* session); |
236 | 255 |
237 // Called by a session after it shuts down. | 256 // Called by a session after it shuts down. |
238 void OnSessionClosed(QuicChromiumClientSession* session); | 257 void OnSessionClosed(QuicChromiumClientSession* session); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 } | 380 } |
362 | 381 |
363 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; } | 382 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; } |
364 | 383 |
365 bool delay_tcp_race() const { return delay_tcp_race_; } | 384 bool delay_tcp_race() const { return delay_tcp_race_; } |
366 | 385 |
367 private: | 386 private: |
368 class Job; | 387 class Job; |
369 class CertVerifierJob; | 388 class CertVerifierJob; |
370 friend class test::QuicStreamFactoryPeer; | 389 friend class test::QuicStreamFactoryPeer; |
| 390 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad); |
371 | 391 |
372 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap; | 392 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap; |
373 typedef std::map<QuicChromiumClientSession*, QuicSessionKey> SessionIdMap; | 393 typedef std::map<QuicChromiumClientSession*, QuicSessionKey> SessionIdMap; |
374 typedef std::set<QuicSessionKey> AliasSet; | 394 typedef std::set<QuicSessionKey> AliasSet; |
375 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap; | 395 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap; |
376 typedef std::set<QuicChromiumClientSession*> SessionSet; | 396 typedef std::set<QuicChromiumClientSession*> SessionSet; |
377 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; | 397 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; |
378 typedef std::map<QuicChromiumClientSession*, IPEndPoint> SessionPeerIPMap; | 398 typedef std::map<QuicChromiumClientSession*, IPEndPoint> SessionPeerIPMap; |
379 typedef std::set<Job*> JobSet; | 399 typedef std::set<Job*> JobSet; |
380 typedef std::map<QuicServerId, JobSet> JobMap; | 400 typedef std::map<QuicServerId, JobSet> JobMap; |
381 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; | 401 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; |
382 typedef std::set<QuicStreamRequest*> RequestSet; | 402 typedef std::set<QuicStreamRequest*> RequestSet; |
383 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; | 403 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; |
| 404 typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason> |
| 405 DisabledReasonsQueue; |
384 typedef std::map<QuicServerId, std::unique_ptr<CertVerifierJob>> | 406 typedef std::map<QuicServerId, std::unique_ptr<CertVerifierJob>> |
385 CertVerifierJobMap; | 407 CertVerifierJobMap; |
386 | 408 |
387 enum FactoryStatus { | 409 enum FactoryStatus { |
388 OPEN, // New streams may be created. | 410 OPEN, // New streams may be created. |
389 CLOSED, // No new streams may be created temporarily. | 411 CLOSED, // No new streams may be created temporarily. |
390 DISABLED // No more streams may be created until the network changes. | 412 DISABLED // No more streams may be created until the network changes. |
391 }; | 413 }; |
392 | 414 |
393 // Creates a job which doesn't wait for server config to be loaded from the | 415 // 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... |
445 | 467 |
446 // Initialize |quic_supported_servers_at_startup_| with the list of servers | 468 // Initialize |quic_supported_servers_at_startup_| with the list of servers |
447 // that supported QUIC at start up and also initialize in-memory cache of | 469 // that supported QUIC at start up and also initialize in-memory cache of |
448 // QuicServerInfo objects from HttpServerProperties. | 470 // QuicServerInfo objects from HttpServerProperties. |
449 void MaybeInitialize(); | 471 void MaybeInitialize(); |
450 | 472 |
451 void ProcessGoingAwaySession(QuicChromiumClientSession* session, | 473 void ProcessGoingAwaySession(QuicChromiumClientSession* session, |
452 const QuicServerId& server_id, | 474 const QuicServerId& server_id, |
453 bool was_session_active); | 475 bool was_session_active); |
454 | 476 |
| 477 // Collect stats from recent connections, possibly disabling Quic. |
| 478 void MaybeDisableQuic(QuicChromiumClientSession* session); |
| 479 |
| 480 void MaybeDisableQuic(uint16_t port); |
| 481 |
455 // Internal method that migrates |session| over to using | 482 // Internal method that migrates |session| over to using |
456 // |peer_address| and |network|. If |network| is kInvalidNetworkHandle, | 483 // |peer_address| and |network|. If |network| is kInvalidNetworkHandle, |
457 // default network is used. If |packet| is not null, it is sent | 484 // default network is used. If |packet| is not null, it is sent |
458 // on the new network, else a PING frame is sent. | 485 // on the new network, else a PING frame is sent. |
459 void MigrateSession(QuicChromiumClientSession* session, | 486 void MigrateSession(QuicChromiumClientSession* session, |
460 IPEndPoint peer_address, | 487 IPEndPoint peer_address, |
461 NetworkChangeNotifier::NetworkHandle network, | 488 NetworkChangeNotifier::NetworkHandle network, |
462 bool close_session_on_error, | 489 bool close_session_on_error, |
463 const BoundNetLog& bound_net_log, | 490 const BoundNetLog& bound_net_log, |
464 scoped_refptr<StringIOBuffer> packet); | 491 scoped_refptr<StringIOBuffer> packet); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 | 565 |
539 // Set if experimental non-blocking IO should be used on windows sockets. | 566 // Set if experimental non-blocking IO should be used on windows sockets. |
540 bool enable_non_blocking_io_; | 567 bool enable_non_blocking_io_; |
541 | 568 |
542 // Set if we do not want to load server config from the disk cache. | 569 // Set if we do not want to load server config from the disk cache. |
543 bool disable_disk_cache_; | 570 bool disable_disk_cache_; |
544 | 571 |
545 // Set if AES-GCM should be preferred, even if there is no hardware support. | 572 // Set if AES-GCM should be preferred, even if there is no hardware support. |
546 bool prefer_aes_; | 573 bool prefer_aes_; |
547 | 574 |
548 // True if QUIC should be disabled when there are timeouts with open | 575 // Set if we want to disable QUIC when there is high packet loss rate. |
549 // streams. | 576 // Specifies the maximum number of connections with high packet loss in a row |
550 bool disable_quic_on_timeout_with_open_streams_; | 577 // after which QUIC will be disabled. |
| 578 int max_number_of_lossy_connections_; |
| 579 // Specifies packet loss rate in fraction after which a connection is closed |
| 580 // and is considered as a lossy connection. |
| 581 float packet_loss_threshold_; |
| 582 // Count number of lossy connections by port. |
| 583 std::map<uint16_t, int> number_of_lossy_connections_; |
| 584 |
| 585 // Keep track of stats for recently closed connections, using a |
| 586 // bounded queue. |
| 587 int max_disabled_reasons_; |
| 588 DisabledReasonsQueue disabled_reasons_; |
| 589 // Events that can trigger disabling QUIC |
| 590 int num_public_resets_post_handshake_; |
| 591 int num_timeouts_with_open_streams_; |
| 592 // Keep track the largest values for UMA histograms, that will help |
| 593 // determine good threshold values. |
| 594 int max_public_resets_post_handshake_; |
| 595 int max_timeouts_with_open_streams_; |
| 596 // Thresholds if greater than zero, determine when to |
| 597 int threshold_timeouts_with_open_streams_; |
| 598 int threshold_public_resets_post_handshake_; |
551 | 599 |
552 // Size of the UDP receive buffer. | 600 // Size of the UDP receive buffer. |
553 int socket_receive_buffer_size_; | 601 int socket_receive_buffer_size_; |
554 | 602 |
555 // Set if we do want to delay TCP connection when it is racing with QUIC. | 603 // Set if we do want to delay TCP connection when it is racing with QUIC. |
556 bool delay_tcp_race_; | 604 bool delay_tcp_race_; |
557 | 605 |
558 // PING timeout for connections. | 606 // PING timeout for connections. |
559 QuicTime::Delta ping_timeout_; | 607 QuicTime::Delta ping_timeout_; |
560 QuicTime::Delta reduced_ping_timeout_; | 608 QuicTime::Delta reduced_ping_timeout_; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 const scoped_refptr<SSLConfigService> ssl_config_service_; | 665 const scoped_refptr<SSLConfigService> ssl_config_service_; |
618 | 666 |
619 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 667 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
620 | 668 |
621 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 669 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
622 }; | 670 }; |
623 | 671 |
624 } // namespace net | 672 } // namespace net |
625 | 673 |
626 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 674 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
OLD | NEW |