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