| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 int threshold_timeouts_with_streams_open, | 185 int threshold_timeouts_with_streams_open, |
| 186 int threshold_public_resets_post_handshake, | 186 int threshold_public_resets_post_handshake, |
| 187 int socket_receive_buffer_size, | 187 int socket_receive_buffer_size, |
| 188 bool delay_tcp_race, | 188 bool delay_tcp_race, |
| 189 int max_server_configs_stored_in_properties, | 189 int max_server_configs_stored_in_properties, |
| 190 bool close_sessions_on_ip_change, | 190 bool close_sessions_on_ip_change, |
| 191 bool disable_quic_on_timeout_with_open_streams, | 191 bool disable_quic_on_timeout_with_open_streams, |
| 192 int idle_connection_timeout_seconds, | 192 int idle_connection_timeout_seconds, |
| 193 bool migrate_sessions_on_network_change, | 193 bool migrate_sessions_on_network_change, |
| 194 bool migrate_sessions_early, | 194 bool migrate_sessions_early, |
| 195 bool race_cert_verification, |
| 195 const QuicTagVector& connection_options, | 196 const QuicTagVector& connection_options, |
| 196 bool enable_token_binding); | 197 bool enable_token_binding); |
| 197 ~QuicStreamFactory() override; | 198 ~QuicStreamFactory() override; |
| 198 | 199 |
| 199 // Returns true if there is an existing session for |server_id| or if the | 200 // Returns true if there is an existing session for |server_id| or if the |
| 200 // request can be pooled to an existing session to the IP address of | 201 // request can be pooled to an existing session to the IP address of |
| 201 // |destination|. | 202 // |destination|. |
| 202 bool CanUseExistingSession(const QuicServerId& server_id, | 203 bool CanUseExistingSession(const QuicServerId& server_id, |
| 203 const HostPortPair& destination); | 204 const HostPortPair& destination); |
| 204 | 205 |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 void set_enable_connection_racing(bool enable_connection_racing) { | 358 void set_enable_connection_racing(bool enable_connection_racing) { |
| 358 enable_connection_racing_ = enable_connection_racing; | 359 enable_connection_racing_ = enable_connection_racing; |
| 359 } | 360 } |
| 360 | 361 |
| 361 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; } | 362 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; } |
| 362 | 363 |
| 363 bool delay_tcp_race() const { return delay_tcp_race_; } | 364 bool delay_tcp_race() const { return delay_tcp_race_; } |
| 364 | 365 |
| 365 private: | 366 private: |
| 366 class Job; | 367 class Job; |
| 368 class CertVerifierJob; |
| 367 friend class test::QuicStreamFactoryPeer; | 369 friend class test::QuicStreamFactoryPeer; |
| 368 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad); | 370 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad); |
| 369 | 371 |
| 370 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap; | 372 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap; |
| 371 typedef std::map<QuicChromiumClientSession*, QuicSessionKey> SessionIdMap; | 373 typedef std::map<QuicChromiumClientSession*, QuicSessionKey> SessionIdMap; |
| 372 typedef std::set<QuicSessionKey> AliasSet; | 374 typedef std::set<QuicSessionKey> AliasSet; |
| 373 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap; | 375 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap; |
| 374 typedef std::set<QuicChromiumClientSession*> SessionSet; | 376 typedef std::set<QuicChromiumClientSession*> SessionSet; |
| 375 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; | 377 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; |
| 376 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap; | 378 typedef std::map<QuicServerId, QuicCryptoClientConfig*> CryptoConfigMap; |
| 377 typedef std::set<Job*> JobSet; | 379 typedef std::set<Job*> JobSet; |
| 378 typedef std::map<QuicServerId, JobSet> JobMap; | 380 typedef std::map<QuicServerId, JobSet> JobMap; |
| 379 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; | 381 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; |
| 380 typedef std::set<QuicStreamRequest*> RequestSet; | 382 typedef std::set<QuicStreamRequest*> RequestSet; |
| 381 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; | 383 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; |
| 382 typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason> | 384 typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason> |
| 383 DisabledReasonsQueue; | 385 DisabledReasonsQueue; |
| 386 typedef std::map<QuicServerId, std::unique_ptr<CertVerifierJob>> |
| 387 CertVerifierJobMap; |
| 384 | 388 |
| 385 enum FactoryStatus { | 389 enum FactoryStatus { |
| 386 OPEN, // New streams may be created. | 390 OPEN, // New streams may be created. |
| 387 CLOSED, // No new streams may be created temporarily. | 391 CLOSED, // No new streams may be created temporarily. |
| 388 DISABLED // No more streams may be created until the network changes. | 392 DISABLED // No more streams may be created until the network changes. |
| 389 }; | 393 }; |
| 390 | 394 |
| 391 // Creates a job which doesn't wait for server config to be loaded from the | 395 // Creates a job which doesn't wait for server config to be loaded from the |
| 392 // disk cache. This job is started via a PostTask. | 396 // disk cache. This job is started via a PostTask. |
| 393 void CreateAuxilaryJob(const QuicSessionKey& key, | 397 void CreateAuxilaryJob(const QuicSessionKey& key, |
| 394 int cert_verify_flags, | 398 int cert_verify_flags, |
| 395 const BoundNetLog& net_log); | 399 const BoundNetLog& net_log); |
| 396 | 400 |
| 397 // Returns a newly created QuicHttpStream owned by the caller. | 401 // Returns a newly created QuicHttpStream owned by the caller. |
| 398 std::unique_ptr<QuicHttpStream> CreateFromSession( | 402 std::unique_ptr<QuicHttpStream> CreateFromSession( |
| 399 QuicChromiumClientSession* session); | 403 QuicChromiumClientSession* session); |
| 400 | 404 |
| 401 bool OnResolution(const QuicSessionKey& key, const AddressList& address_list); | 405 bool OnResolution(const QuicSessionKey& key, const AddressList& address_list); |
| 402 void OnJobComplete(Job* job, int rv); | 406 void OnJobComplete(Job* job, int rv); |
| 407 void OnCertVerifyJobComplete(CertVerifierJob* job, int rv); |
| 403 bool HasActiveSession(const QuicServerId& server_id) const; | 408 bool HasActiveSession(const QuicServerId& server_id) const; |
| 404 bool HasActiveJob(const QuicServerId& server_id) const; | 409 bool HasActiveJob(const QuicServerId& server_id) const; |
| 410 bool HasActiveCertVerifierJob(const QuicServerId& server_id) const; |
| 405 int CreateSession(const QuicSessionKey& key, | 411 int CreateSession(const QuicSessionKey& key, |
| 406 int cert_verify_flags, | 412 int cert_verify_flags, |
| 407 std::unique_ptr<QuicServerInfo> quic_server_info, | 413 std::unique_ptr<QuicServerInfo> quic_server_info, |
| 408 const AddressList& address_list, | 414 const AddressList& address_list, |
| 409 base::TimeTicks dns_resolution_end_time, | 415 base::TimeTicks dns_resolution_end_time, |
| 410 const BoundNetLog& net_log, | 416 const BoundNetLog& net_log, |
| 411 QuicChromiumClientSession** session); | 417 QuicChromiumClientSession** session); |
| 412 void ActivateSession(const QuicSessionKey& key, | 418 void ActivateSession(const QuicSessionKey& key, |
| 413 QuicChromiumClientSession* session); | 419 QuicChromiumClientSession* session); |
| 414 | 420 |
| 415 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there | 421 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there |
| 416 // is no |http_server_properties_| or if |http_server_properties_| doesn't | 422 // is no |http_server_properties_| or if |http_server_properties_| doesn't |
| 417 // have ServerNetworkStats for the given |server_id|. | 423 // have ServerNetworkStats for the given |server_id|. |
| 418 int64_t GetServerNetworkStatsSmoothedRttInMicroseconds( | 424 int64_t GetServerNetworkStatsSmoothedRttInMicroseconds( |
| 419 const QuicServerId& server_id) const; | 425 const QuicServerId& server_id) const; |
| 420 | 426 |
| 421 // Helper methods. | 427 // Helper methods. |
| 422 bool WasQuicRecentlyBroken(const QuicServerId& server_id) const; | 428 bool WasQuicRecentlyBroken(const QuicServerId& server_id) const; |
| 423 | 429 |
| 424 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id); | 430 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id); |
| 425 | 431 |
| 432 // Starts an asynchronous job for cert verification if |
| 433 // |race_cert_verification_| is enabled and if there are cached certs for the |
| 434 // given |server_id|. |
| 435 QuicAsyncStatus StartCertVerifyJob(const QuicServerId& server_id, |
| 436 int cert_verify_flags, |
| 437 const BoundNetLog& net_log); |
| 438 |
| 426 // Initializes the cached state associated with |server_id| in | 439 // Initializes the cached state associated with |server_id| in |
| 427 // |crypto_config_| with the information in |server_info|. Populates | 440 // |crypto_config_| with the information in |server_info|. Populates |
| 428 // |connection_id| with the next server designated connection id, | 441 // |connection_id| with the next server designated connection id, |
| 429 // if any, and otherwise leaves it unchanged. | 442 // if any, and otherwise leaves it unchanged. |
| 430 void InitializeCachedStateInCryptoConfig( | 443 void InitializeCachedStateInCryptoConfig( |
| 431 const QuicServerId& server_id, | 444 const QuicServerId& server_id, |
| 432 const std::unique_ptr<QuicServerInfo>& server_info, | 445 const std::unique_ptr<QuicServerInfo>& server_info, |
| 433 QuicConnectionId* connection_id); | 446 QuicConnectionId* connection_id); |
| 434 | 447 |
| 435 // Initialize |quic_supported_servers_at_startup_| with the list of servers | 448 // Initialize |quic_supported_servers_at_startup_| with the list of servers |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 // Origins which have gone away recently. | 496 // Origins which have gone away recently. |
| 484 AliasSet gone_away_aliases_; | 497 AliasSet gone_away_aliases_; |
| 485 | 498 |
| 486 const QuicConfig config_; | 499 const QuicConfig config_; |
| 487 QuicCryptoClientConfig crypto_config_; | 500 QuicCryptoClientConfig crypto_config_; |
| 488 | 501 |
| 489 JobMap active_jobs_; | 502 JobMap active_jobs_; |
| 490 ServerIDRequestsMap job_requests_map_; | 503 ServerIDRequestsMap job_requests_map_; |
| 491 RequestMap active_requests_; | 504 RequestMap active_requests_; |
| 492 | 505 |
| 506 CertVerifierJobMap active_cert_verifier_jobs_; |
| 507 |
| 493 QuicVersionVector supported_versions_; | 508 QuicVersionVector supported_versions_; |
| 494 | 509 |
| 495 // Determine if we should consistently select a client UDP port. If false, | 510 // Determine if we should consistently select a client UDP port. If false, |
| 496 // then we will just let the OS select a random client port for each new | 511 // then we will just let the OS select a random client port for each new |
| 497 // connection. | 512 // connection. |
| 498 bool enable_port_selection_; | 513 bool enable_port_selection_; |
| 499 | 514 |
| 500 // Set if we always require handshake confirmation. If true, this will | 515 // Set if we always require handshake confirmation. If true, this will |
| 501 // introduce at least one RTT for the handshake before the client sends data. | 516 // introduce at least one RTT for the handshake before the client sends data. |
| 502 bool always_require_handshake_confirmation_; | 517 bool always_require_handshake_confirmation_; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 const bool close_sessions_on_ip_change_; | 580 const bool close_sessions_on_ip_change_; |
| 566 | 581 |
| 567 // Set if migration should be attempted on active sessions when primary | 582 // Set if migration should be attempted on active sessions when primary |
| 568 // interface changes. | 583 // interface changes. |
| 569 const bool migrate_sessions_on_network_change_; | 584 const bool migrate_sessions_on_network_change_; |
| 570 | 585 |
| 571 // Set if early migration should be attempted when the connection | 586 // Set if early migration should be attempted when the connection |
| 572 // experiences poor connectivity. | 587 // experiences poor connectivity. |
| 573 const bool migrate_sessions_early_; | 588 const bool migrate_sessions_early_; |
| 574 | 589 |
| 590 // Set if cert verification is to be raced with host resolution. |
| 591 bool race_cert_verification_; |
| 592 |
| 575 // Each profile will (probably) have a unique port_seed_ value. This value | 593 // Each profile will (probably) have a unique port_seed_ value. This value |
| 576 // is used to help seed a pseudo-random number generator (PortSuggester) so | 594 // is used to help seed a pseudo-random number generator (PortSuggester) so |
| 577 // that we consistently (within this profile) suggest the same ephemeral | 595 // that we consistently (within this profile) suggest the same ephemeral |
| 578 // port when we re-connect to any given server/port. The differences between | 596 // port when we re-connect to any given server/port. The differences between |
| 579 // profiles (probablistically) prevent two profiles from colliding in their | 597 // profiles (probablistically) prevent two profiles from colliding in their |
| 580 // ephemeral port requests. | 598 // ephemeral port requests. |
| 581 uint64_t port_seed_; | 599 uint64_t port_seed_; |
| 582 | 600 |
| 583 // Local address of socket that was created in CreateSession. | 601 // Local address of socket that was created in CreateSession. |
| 584 IPEndPoint local_address_; | 602 IPEndPoint local_address_; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 600 const scoped_refptr<SSLConfigService> ssl_config_service_; | 618 const scoped_refptr<SSLConfigService> ssl_config_service_; |
| 601 | 619 |
| 602 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 620 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
| 603 | 621 |
| 604 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 622 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
| 605 }; | 623 }; |
| 606 | 624 |
| 607 } // namespace net | 625 } // namespace net |
| 608 | 626 |
| 609 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 627 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
| OLD | NEW |