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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 allow_server_migration, | 195 bool allow_server_migration, |
196 bool force_hol_blocking, | 196 bool force_hol_blocking, |
197 bool race_cert_verification, | |
198 const QuicTagVector& connection_options, | 197 const QuicTagVector& connection_options, |
199 bool enable_token_binding); | 198 bool enable_token_binding); |
200 ~QuicStreamFactory() override; | 199 ~QuicStreamFactory() override; |
201 | 200 |
202 // Returns true if there is an existing session for |server_id| or if the | 201 // Returns true if there is an existing session for |server_id| or if the |
203 // request can be pooled to an existing session to the IP address of | 202 // request can be pooled to an existing session to the IP address of |
204 // |destination|. | 203 // |destination|. |
205 bool CanUseExistingSession(const QuicServerId& server_id, | 204 bool CanUseExistingSession(const QuicServerId& server_id, |
206 const HostPortPair& destination); | 205 const HostPortPair& destination); |
207 | 206 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 void set_enable_connection_racing(bool enable_connection_racing) { | 368 void set_enable_connection_racing(bool enable_connection_racing) { |
370 enable_connection_racing_ = enable_connection_racing; | 369 enable_connection_racing_ = enable_connection_racing; |
371 } | 370 } |
372 | 371 |
373 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; } | 372 int socket_receive_buffer_size() const { return socket_receive_buffer_size_; } |
374 | 373 |
375 bool delay_tcp_race() const { return delay_tcp_race_; } | 374 bool delay_tcp_race() const { return delay_tcp_race_; } |
376 | 375 |
377 private: | 376 private: |
378 class Job; | 377 class Job; |
379 class CertVerifierJob; | |
380 friend class test::QuicStreamFactoryPeer; | 378 friend class test::QuicStreamFactoryPeer; |
381 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad); | 379 FRIEND_TEST_ALL_PREFIXES(HttpStreamFactoryTest, QuicLossyProxyMarkedAsBad); |
382 | 380 |
383 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap; | 381 typedef std::map<QuicServerId, QuicChromiumClientSession*> SessionMap; |
384 typedef std::map<QuicChromiumClientSession*, QuicSessionKey> SessionIdMap; | 382 typedef std::map<QuicChromiumClientSession*, QuicSessionKey> SessionIdMap; |
385 typedef std::set<QuicSessionKey> AliasSet; | 383 typedef std::set<QuicSessionKey> AliasSet; |
386 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap; | 384 typedef std::map<QuicChromiumClientSession*, AliasSet> SessionAliasMap; |
387 typedef std::set<QuicChromiumClientSession*> SessionSet; | 385 typedef std::set<QuicChromiumClientSession*> SessionSet; |
388 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; | 386 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; |
389 typedef std::set<Job*> JobSet; | 387 typedef std::set<Job*> JobSet; |
390 typedef std::map<QuicServerId, JobSet> JobMap; | 388 typedef std::map<QuicServerId, JobSet> JobMap; |
391 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; | 389 typedef std::map<QuicStreamRequest*, QuicServerId> RequestMap; |
392 typedef std::set<QuicStreamRequest*> RequestSet; | 390 typedef std::set<QuicStreamRequest*> RequestSet; |
393 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; | 391 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; |
394 typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason> | 392 typedef std::deque<enum QuicChromiumClientSession::QuicDisabledReason> |
395 DisabledReasonsQueue; | 393 DisabledReasonsQueue; |
396 typedef std::map<QuicServerId, std::unique_ptr<CertVerifierJob>> | |
397 CertVerifierJobMap; | |
398 | 394 |
399 enum FactoryStatus { | 395 enum FactoryStatus { |
400 OPEN, // New streams may be created. | 396 OPEN, // New streams may be created. |
401 CLOSED, // No new streams may be created temporarily. | 397 CLOSED, // No new streams may be created temporarily. |
402 DISABLED // No more streams may be created until the network changes. | 398 DISABLED // No more streams may be created until the network changes. |
403 }; | 399 }; |
404 | 400 |
405 // Creates a job which doesn't wait for server config to be loaded from the | 401 // Creates a job which doesn't wait for server config to be loaded from the |
406 // disk cache. This job is started via a PostTask. | 402 // disk cache. This job is started via a PostTask. |
407 void CreateAuxilaryJob(const QuicSessionKey& key, | 403 void CreateAuxilaryJob(const QuicSessionKey& key, |
408 int cert_verify_flags, | 404 int cert_verify_flags, |
409 const BoundNetLog& net_log); | 405 const BoundNetLog& net_log); |
410 | 406 |
411 // Returns a newly created QuicHttpStream owned by the caller. | 407 // Returns a newly created QuicHttpStream owned by the caller. |
412 std::unique_ptr<QuicHttpStream> CreateFromSession( | 408 std::unique_ptr<QuicHttpStream> CreateFromSession( |
413 QuicChromiumClientSession* session); | 409 QuicChromiumClientSession* session); |
414 | 410 |
415 bool OnResolution(const QuicSessionKey& key, const AddressList& address_list); | 411 bool OnResolution(const QuicSessionKey& key, const AddressList& address_list); |
416 void OnJobComplete(Job* job, int rv); | 412 void OnJobComplete(Job* job, int rv); |
417 void OnCertVerifyJobComplete(CertVerifierJob* job, int rv); | |
418 bool HasActiveSession(const QuicServerId& server_id) const; | 413 bool HasActiveSession(const QuicServerId& server_id) const; |
419 bool HasActiveJob(const QuicServerId& server_id) const; | 414 bool HasActiveJob(const QuicServerId& server_id) const; |
420 bool HasActiveCertVerifierJob(const QuicServerId& server_id) const; | |
421 int CreateSession(const QuicSessionKey& key, | 415 int CreateSession(const QuicSessionKey& key, |
422 int cert_verify_flags, | 416 int cert_verify_flags, |
423 std::unique_ptr<QuicServerInfo> quic_server_info, | 417 std::unique_ptr<QuicServerInfo> quic_server_info, |
424 const AddressList& address_list, | 418 const AddressList& address_list, |
425 base::TimeTicks dns_resolution_end_time, | 419 base::TimeTicks dns_resolution_end_time, |
426 const BoundNetLog& net_log, | 420 const BoundNetLog& net_log, |
427 QuicChromiumClientSession** session); | 421 QuicChromiumClientSession** session); |
428 void ActivateSession(const QuicSessionKey& key, | 422 void ActivateSession(const QuicSessionKey& key, |
429 QuicChromiumClientSession* session); | 423 QuicChromiumClientSession* session); |
430 | 424 |
431 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there | 425 // Returns |srtt| in micro seconds from ServerNetworkStats. Returns 0 if there |
432 // is no |http_server_properties_| or if |http_server_properties_| doesn't | 426 // is no |http_server_properties_| or if |http_server_properties_| doesn't |
433 // have ServerNetworkStats for the given |server_id|. | 427 // have ServerNetworkStats for the given |server_id|. |
434 int64_t GetServerNetworkStatsSmoothedRttInMicroseconds( | 428 int64_t GetServerNetworkStatsSmoothedRttInMicroseconds( |
435 const QuicServerId& server_id) const; | 429 const QuicServerId& server_id) const; |
436 | 430 |
437 // Helper methods. | 431 // Helper methods. |
438 bool WasQuicRecentlyBroken(const QuicServerId& server_id) const; | 432 bool WasQuicRecentlyBroken(const QuicServerId& server_id) const; |
439 | 433 |
440 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id); | 434 bool CryptoConfigCacheIsEmpty(const QuicServerId& server_id); |
441 | 435 |
442 // Starts an asynchronous job for cert verification if | |
443 // |race_cert_verification_| is enabled and if there are cached certs for the | |
444 // given |server_id|. | |
445 QuicAsyncStatus StartCertVerifyJob(const QuicServerId& server_id, | |
446 int cert_verify_flags, | |
447 const BoundNetLog& net_log); | |
448 | |
449 // Initializes the cached state associated with |server_id| in | 436 // Initializes the cached state associated with |server_id| in |
450 // |crypto_config_| with the information in |server_info|. Populates | 437 // |crypto_config_| with the information in |server_info|. Populates |
451 // |connection_id| with the next server designated connection id, | 438 // |connection_id| with the next server designated connection id, |
452 // if any, and otherwise leaves it unchanged. | 439 // if any, and otherwise leaves it unchanged. |
453 void InitializeCachedStateInCryptoConfig( | 440 void InitializeCachedStateInCryptoConfig( |
454 const QuicServerId& server_id, | 441 const QuicServerId& server_id, |
455 const std::unique_ptr<QuicServerInfo>& server_info, | 442 const std::unique_ptr<QuicServerInfo>& server_info, |
456 QuicConnectionId* connection_id); | 443 QuicConnectionId* connection_id); |
457 | 444 |
458 // Initialize |quic_supported_servers_at_startup_| with the list of servers | 445 // Initialize |quic_supported_servers_at_startup_| with the list of servers |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 // Origins which have gone away recently. | 503 // Origins which have gone away recently. |
517 AliasSet gone_away_aliases_; | 504 AliasSet gone_away_aliases_; |
518 | 505 |
519 const QuicConfig config_; | 506 const QuicConfig config_; |
520 QuicCryptoClientConfig crypto_config_; | 507 QuicCryptoClientConfig crypto_config_; |
521 | 508 |
522 JobMap active_jobs_; | 509 JobMap active_jobs_; |
523 ServerIDRequestsMap job_requests_map_; | 510 ServerIDRequestsMap job_requests_map_; |
524 RequestMap active_requests_; | 511 RequestMap active_requests_; |
525 | 512 |
526 CertVerifierJobMap active_cert_verifier_jobs_; | |
527 | |
528 QuicVersionVector supported_versions_; | 513 QuicVersionVector supported_versions_; |
529 | 514 |
530 // Determine if we should consistently select a client UDP port. If false, | 515 // Determine if we should consistently select a client UDP port. If false, |
531 // then we will just let the OS select a random client port for each new | 516 // then we will just let the OS select a random client port for each new |
532 // connection. | 517 // connection. |
533 bool enable_port_selection_; | 518 bool enable_port_selection_; |
534 | 519 |
535 // Set if we always require handshake confirmation. If true, this will | 520 // Set if we always require handshake confirmation. If true, this will |
536 // introduce at least one RTT for the handshake before the client sends data. | 521 // introduce at least one RTT for the handshake before the client sends data. |
537 bool always_require_handshake_confirmation_; | 522 bool always_require_handshake_confirmation_; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 // experiences poor connectivity. | 592 // experiences poor connectivity. |
608 const bool migrate_sessions_early_; | 593 const bool migrate_sessions_early_; |
609 | 594 |
610 // If set, allows migration of connection to server-specified alternate | 595 // If set, allows migration of connection to server-specified alternate |
611 // server address. | 596 // server address. |
612 const bool allow_server_migration_; | 597 const bool allow_server_migration_; |
613 | 598 |
614 // If set, force HOL blocking. For measurement purposes. | 599 // If set, force HOL blocking. For measurement purposes. |
615 const bool force_hol_blocking_; | 600 const bool force_hol_blocking_; |
616 | 601 |
617 // Set if cert verification is to be raced with host resolution. | |
618 bool race_cert_verification_; | |
619 | |
620 // Each profile will (probably) have a unique port_seed_ value. This value | 602 // Each profile will (probably) have a unique port_seed_ value. This value |
621 // is used to help seed a pseudo-random number generator (PortSuggester) so | 603 // is used to help seed a pseudo-random number generator (PortSuggester) so |
622 // that we consistently (within this profile) suggest the same ephemeral | 604 // that we consistently (within this profile) suggest the same ephemeral |
623 // port when we re-connect to any given server/port. The differences between | 605 // port when we re-connect to any given server/port. The differences between |
624 // profiles (probablistically) prevent two profiles from colliding in their | 606 // profiles (probablistically) prevent two profiles from colliding in their |
625 // ephemeral port requests. | 607 // ephemeral port requests. |
626 uint64_t port_seed_; | 608 uint64_t port_seed_; |
627 | 609 |
628 // Local address of socket that was created in CreateSession. | 610 // Local address of socket that was created in CreateSession. |
629 IPEndPoint local_address_; | 611 IPEndPoint local_address_; |
(...skipping 15 matching lines...) Expand all Loading... |
645 const scoped_refptr<SSLConfigService> ssl_config_service_; | 627 const scoped_refptr<SSLConfigService> ssl_config_service_; |
646 | 628 |
647 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 629 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
648 | 630 |
649 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 631 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
650 }; | 632 }; |
651 | 633 |
652 } // namespace net | 634 } // namespace net |
653 | 635 |
654 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ | 636 #endif // NET_QUIC_QUIC_STREAM_FACTORY_H_ |
OLD | NEW |