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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 // When a connection is idle for 30 seconds it will be closed. | 67 // When a connection is idle for 30 seconds it will be closed. |
68 const int kIdleConnectionTimeoutSeconds = 30; | 68 const int kIdleConnectionTimeoutSeconds = 30; |
69 | 69 |
70 // Indicates cause when connection migration is triggered. | 70 // Indicates cause when connection migration is triggered. |
71 enum MigrationCause { | 71 enum MigrationCause { |
72 EARLY_MIGRATION, // Migration due to path degradation. | 72 EARLY_MIGRATION, // Migration due to path degradation. |
73 WRITE_ERROR // Migration due to socket write error. | 73 WRITE_ERROR // Migration due to socket write error. |
74 }; | 74 }; |
75 | 75 |
| 76 // Result of a session migration attempt. |
| 77 enum class MigrationResult { |
| 78 SUCCESS, // Migration succeeded. |
| 79 NO_NEW_NETWORK, // Migration failed since no new network was found. |
| 80 FAILURE // Migration failed for other reasons. |
| 81 }; |
| 82 |
76 // Encapsulates a pending request for a QuicHttpStream. | 83 // Encapsulates a pending request for a QuicHttpStream. |
77 // If the request is still pending when it is destroyed, it will | 84 // If the request is still pending when it is destroyed, it will |
78 // cancel the request with the factory. | 85 // cancel the request with the factory. |
79 class NET_EXPORT_PRIVATE QuicStreamRequest { | 86 class NET_EXPORT_PRIVATE QuicStreamRequest { |
80 public: | 87 public: |
81 explicit QuicStreamRequest(QuicStreamFactory* factory); | 88 explicit QuicStreamRequest(QuicStreamFactory* factory); |
82 ~QuicStreamRequest(); | 89 ~QuicStreamRequest(); |
83 | 90 |
84 // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is | 91 // |cert_verify_flags| is bitwise OR'd of CertVerifier::VerifyFlags and it is |
85 // passed to CertVerifier::Verify. | 92 // passed to CertVerifier::Verify. |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 // If |new_network| is NetworkChangeNotifier::kInvalidNetworkHandle, | 303 // If |new_network| is NetworkChangeNotifier::kInvalidNetworkHandle, |
297 // there is no new network to migrate sessions onto, and all sessions are | 304 // there is no new network to migrate sessions onto, and all sessions are |
298 // closed. | 305 // closed. |
299 void MaybeMigrateOrCloseSessions( | 306 void MaybeMigrateOrCloseSessions( |
300 NetworkChangeNotifier::NetworkHandle new_network, | 307 NetworkChangeNotifier::NetworkHandle new_network, |
301 bool close_if_cannot_migrate, | 308 bool close_if_cannot_migrate, |
302 const BoundNetLog& bound_net_log); | 309 const BoundNetLog& bound_net_log); |
303 | 310 |
304 // Method that initiates migration of |session| if |session| is | 311 // Method that initiates migration of |session| if |session| is |
305 // active and if there is an alternate network than the one to which | 312 // active and if there is an alternate network than the one to which |
306 // |session| is currently bound. If not null, |packet| is sent on | 313 // |session| is currently bound. |
307 // the new network, else a PING frame is sent. | 314 MigrationResult MaybeMigrateSingleSession(QuicChromiumClientSession* session, |
308 void MaybeMigrateSingleSession(QuicChromiumClientSession* session, | 315 MigrationCause migration_cause); |
309 MigrationCause migration_cause, | |
310 scoped_refptr<StringIOBuffer> packet); | |
311 | 316 |
312 // Migrates |session| over to using |network|. If |network| is | 317 // Migrates |session| over to using |network|. If |network| is |
313 // kInvalidNetworkHandle, default network is used. If |packet| is | 318 // kInvalidNetworkHandle, default network is used. |
314 // not null, it is sent on the new network, else a PING frame is | 319 MigrationResult MigrateSessionToNewNetwork( |
315 // sent. | 320 QuicChromiumClientSession* session, |
316 void MigrateSessionToNewNetwork(QuicChromiumClientSession* session, | 321 NetworkChangeNotifier::NetworkHandle network, |
317 NetworkChangeNotifier::NetworkHandle network, | 322 bool close_session_on_error, |
318 bool close_session_on_error, | 323 const BoundNetLog& bound_net_log); |
319 const BoundNetLog& bound_net_log, | |
320 scoped_refptr<StringIOBuffer> packet); | |
321 | 324 |
322 // Migrates |session| over to using |peer_address|. Causes a PING frame | 325 // Migrates |session| over to using |peer_address|. Causes a PING frame |
323 // to be sent to the new peer address. | 326 // to be sent to the new peer address. |
324 void MigrateSessionToNewPeerAddress(QuicChromiumClientSession* session, | 327 void MigrateSessionToNewPeerAddress(QuicChromiumClientSession* session, |
325 IPEndPoint peer_address, | 328 IPEndPoint peer_address, |
326 const BoundNetLog& bound_net_log); | 329 const BoundNetLog& bound_net_log); |
327 | 330 |
328 // NetworkChangeNotifier::IPAddressObserver methods: | 331 // NetworkChangeNotifier::IPAddressObserver methods: |
329 | 332 |
330 // Until the servers support roaming, close all connections when the local | 333 // Until the servers support roaming, close all connections when the local |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 | 379 |
377 bool enable_connection_racing() const { return enable_connection_racing_; } | 380 bool enable_connection_racing() const { return enable_connection_racing_; } |
378 void set_enable_connection_racing(bool enable_connection_racing) { | 381 void set_enable_connection_racing(bool enable_connection_racing) { |
379 enable_connection_racing_ = enable_connection_racing; | 382 enable_connection_racing_ = enable_connection_racing; |
380 } | 383 } |
381 | 384 |
382 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; } | 385 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; } |
383 | 386 |
384 bool delay_tcp_race() const { return delay_tcp_race_; } | 387 bool delay_tcp_race() const { return delay_tcp_race_; } |
385 | 388 |
| 389 bool migrate_sessions_on_network_change() const { |
| 390 return migrate_sessions_on_network_change_; |
| 391 } |
| 392 |
386 private: | 393 private: |
387 class Job; | 394 class Job; |
388 class CertVerifierJob; | 395 class CertVerifierJob; |
389 friend class test::QuicStreamFactoryPeer; | 396 friend class test::QuicStreamFactoryPeer; |
390 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad); | 397 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad); |
391 | 398 |
392 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap; | 399 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap; |
393 typedef std::map<QuicChromiumClientSession*, QuicSessionKey> SessionIdMap; | 400 typedef std::map<QuicChromiumClientSession*, QuicSessionKey> SessionIdMap; |
394 typedef std::set<QuicSessionKey> AliasSet; | 401 typedef std::set<QuicSessionKey> AliasSet; |
395 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap; | 402 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 void ProcessGoingAwaySession(QuicChromiumClientSession* session, | 480 void ProcessGoingAwaySession(QuicChromiumClientSession* session, |
474 const QuicServerId& server_id, | 481 const QuicServerId& server_id, |
475 bool was_session_active); | 482 bool was_session_active); |
476 | 483 |
477 // Collect stats from recent connections, possibly disabling Quic. | 484 // Collect stats from recent connections, possibly disabling Quic. |
478 void MaybeDisableQuic(QuicChromiumClientSession* session); | 485 void MaybeDisableQuic(QuicChromiumClientSession* session); |
479 | 486 |
480 void MaybeDisableQuic(uint16_t port); | 487 void MaybeDisableQuic(uint16_t port); |
481 | 488 |
482 // Internal method that migrates |session| over to using | 489 // Internal method that migrates |session| over to using |
483 // |peer_address| and |network|. If |network| is kInvalidNetworkHandle, | 490 // |peer_address| and |network|. If |network| is |
484 // default network is used. If |packet| is not null, it is sent | 491 // kInvalidNetworkHandle, default network is used. If the migration |
485 // on the new network, else a PING frame is sent. | 492 // fails and |close_session_on_error| is true, connection is closed. |
486 void MigrateSession(QuicChromiumClientSession* session, | 493 MigrationResult MigrateSessionInner( |
487 IPEndPoint peer_address, | 494 QuicChromiumClientSession* session, |
488 NetworkChangeNotifier::NetworkHandle network, | 495 IPEndPoint peer_address, |
489 bool close_session_on_error, | 496 NetworkChangeNotifier::NetworkHandle network, |
490 const BoundNetLog& bound_net_log, | 497 bool close_session_on_error, |
491 scoped_refptr<StringIOBuffer> packet); | 498 const BoundNetLog& bound_net_log); |
492 | 499 |
493 bool require_confirmation_; | 500 bool require_confirmation_; |
494 NetLog* net_log_; | 501 NetLog* net_log_; |
495 HostResolver* host_resolver_; | 502 HostResolver* host_resolver_; |
496 ClientSocketFactory* client_socket_factory_; | 503 ClientSocketFactory* client_socket_factory_; |
497 HttpServerProperties* http_server_properties_; | 504 HttpServerProperties* http_server_properties_; |
498 TransportSecurityState* transport_security_state_; | 505 TransportSecurityState* transport_security_state_; |
499 CTVerifier* cert_transparency_verifier_; | 506 CTVerifier* cert_transparency_verifier_; |
500 std::unique_ptr<QuicServerInfoFactory> quic_server_info_factory_; | 507 std::unique_ptr<QuicServerInfoFactory> quic_server_info_factory_; |
501 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_; | 508 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 const scoped_refptr<SSLConfigService> ssl_config_service_; | 672 const scoped_refptr<SSLConfigService> ssl_config_service_; |
666 | 673 |
667 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 674 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
668 | 675 |
669 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 676 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
670 }; | 677 }; |
671 | 678 |
672 } // namespace net | 679 } // namespace net |
673 | 680 |
674 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 681 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
OLD | NEW |