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_CHROMIUM_QUIC_STREAM_FACTORY_H_ | 5 #ifndef NET_QUIC_CHROMIUM_QUIC_STREAM_FACTORY_H_ |
6 #define NET_QUIC_CHROMIUM_QUIC_STREAM_FACTORY_H_ | 6 #define NET_QUIC_CHROMIUM_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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 class HostResolver; | 59 class HostResolver; |
60 class HttpServerProperties; | 60 class HttpServerProperties; |
61 class NetLog; | 61 class NetLog; |
62 class ProxyDelegate; | 62 class ProxyDelegate; |
63 class QuicClock; | 63 class QuicClock; |
64 class QuicAlarmFactory; | 64 class QuicAlarmFactory; |
65 class QuicChromiumConnectionHelper; | 65 class QuicChromiumConnectionHelper; |
66 class QuicCryptoClientStreamFactory; | 66 class QuicCryptoClientStreamFactory; |
67 class QuicRandom; | 67 class QuicRandom; |
68 class QuicServerInfo; | 68 class QuicServerInfo; |
| 69 class QuicServerInfoFactory; |
69 class QuicStreamFactory; | 70 class QuicStreamFactory; |
70 class SocketPerformanceWatcherFactory; | 71 class SocketPerformanceWatcherFactory; |
71 class TransportSecurityState; | 72 class TransportSecurityState; |
72 class BidirectionalStreamImpl; | 73 class BidirectionalStreamImpl; |
73 | 74 |
74 namespace test { | 75 namespace test { |
75 class QuicStreamFactoryPeer; | 76 class QuicStreamFactoryPeer; |
76 } // namespace test | 77 } // namespace test |
77 | 78 |
78 // When a connection is idle for 30 seconds it will be closed. | 79 // When a connection is idle for 30 seconds it will be closed. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 ChannelIDService* channel_id_service, | 201 ChannelIDService* channel_id_service, |
201 TransportSecurityState* transport_security_state, | 202 TransportSecurityState* transport_security_state, |
202 CTVerifier* cert_transparency_verifier, | 203 CTVerifier* cert_transparency_verifier, |
203 SocketPerformanceWatcherFactory* socket_performance_watcher_factory, | 204 SocketPerformanceWatcherFactory* socket_performance_watcher_factory, |
204 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, | 205 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, |
205 QuicRandom* random_generator, | 206 QuicRandom* random_generator, |
206 QuicClock* clock, | 207 QuicClock* clock, |
207 size_t max_packet_length, | 208 size_t max_packet_length, |
208 const std::string& user_agent_id, | 209 const std::string& user_agent_id, |
209 const QuicVersionVector& supported_versions, | 210 const QuicVersionVector& supported_versions, |
| 211 float load_server_info_timeout_srtt_multiplier, |
| 212 bool enable_connection_racing, |
210 bool enable_non_blocking_io, | 213 bool enable_non_blocking_io, |
211 bool store_server_configs_in_properties, | 214 bool disable_disk_cache, |
| 215 int max_server_configs_stored_in_properties, |
212 bool close_sessions_on_ip_change, | 216 bool close_sessions_on_ip_change, |
213 bool mark_quic_broken_when_network_blackholes, | 217 bool mark_quic_broken_when_network_blackholes, |
214 int idle_connection_timeout_seconds, | 218 int idle_connection_timeout_seconds, |
215 int reduced_ping_timeout_seconds, | 219 int reduced_ping_timeout_seconds, |
216 int packet_reader_yield_after_duration_milliseconds, | 220 int packet_reader_yield_after_duration_milliseconds, |
217 bool migrate_sessions_on_network_change, | 221 bool migrate_sessions_on_network_change, |
218 bool migrate_sessions_early, | 222 bool migrate_sessions_early, |
219 bool allow_server_migration, | 223 bool allow_server_migration, |
220 bool force_hol_blocking, | 224 bool force_hol_blocking, |
221 bool race_cert_verification, | 225 bool race_cert_verification, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 | 361 |
358 void set_require_confirmation(bool require_confirmation); | 362 void set_require_confirmation(bool require_confirmation); |
359 | 363 |
360 // It returns the amount of time waiting job should be delayed. | 364 // It returns the amount of time waiting job should be delayed. |
361 base::TimeDelta GetTimeDelayForWaitingJob(const QuicServerId& server_id); | 365 base::TimeDelta GetTimeDelayForWaitingJob(const QuicServerId& server_id); |
362 | 366 |
363 QuicChromiumConnectionHelper* helper() { return helper_.get(); } | 367 QuicChromiumConnectionHelper* helper() { return helper_.get(); } |
364 | 368 |
365 QuicAlarmFactory* alarm_factory() { return alarm_factory_.get(); } | 369 QuicAlarmFactory* alarm_factory() { return alarm_factory_.get(); } |
366 | 370 |
| 371 bool has_quic_server_info_factory() const { |
| 372 return quic_server_info_factory_.get() != nullptr; |
| 373 } |
| 374 |
| 375 QuicServerInfoFactory* quic_server_info_factory() const { |
| 376 return quic_server_info_factory_.get(); |
| 377 } |
| 378 |
| 379 void set_quic_server_info_factory( |
| 380 QuicServerInfoFactory* quic_server_info_factory); |
| 381 |
367 void set_server_push_delegate(ServerPushDelegate* push_delegate) { | 382 void set_server_push_delegate(ServerPushDelegate* push_delegate) { |
368 push_delegate_ = push_delegate; | 383 push_delegate_ = push_delegate; |
369 } | 384 } |
370 | 385 |
| 386 bool enable_connection_racing() const { return enable_connection_racing_; } |
| 387 void set_enable_connection_racing(bool enable_connection_racing) { |
| 388 enable_connection_racing_ = enable_connection_racing; |
| 389 } |
| 390 |
371 bool migrate_sessions_on_network_change() const { | 391 bool migrate_sessions_on_network_change() const { |
372 return migrate_sessions_on_network_change_; | 392 return migrate_sessions_on_network_change_; |
373 } | 393 } |
374 | 394 |
375 bool mark_quic_broken_when_network_blackholes() const { | 395 bool mark_quic_broken_when_network_blackholes() const { |
376 return mark_quic_broken_when_network_blackholes_; | 396 return mark_quic_broken_when_network_blackholes_; |
377 } | 397 } |
378 | 398 |
379 // Dumps memory allocation stats. |parent_dump_absolute_name| is the name | 399 // Dumps memory allocation stats. |parent_dump_absolute_name| is the name |
380 // used by the parent MemoryAllocatorDump in the memory dump hierarchy. | 400 // used by the parent MemoryAllocatorDump in the memory dump hierarchy. |
(...skipping 12 matching lines...) Expand all Loading... |
393 typedef std::set<QuicChromiumClientSession*> SessionSet; | 413 typedef std::set<QuicChromiumClientSession*> SessionSet; |
394 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; | 414 typedef std::map<IPEndPoint, SessionSet> IPAliasMap; |
395 typedef std::map<QuicChromiumClientSession*, IPEndPoint> SessionPeerIPMap; | 415 typedef std::map<QuicChromiumClientSession*, IPEndPoint> SessionPeerIPMap; |
396 typedef std::map<Job*, std::unique_ptr<Job>> JobSet; | 416 typedef std::map<Job*, std::unique_ptr<Job>> JobSet; |
397 typedef std::map<QuicServerId, JobSet> JobMap; | 417 typedef std::map<QuicServerId, JobSet> JobMap; |
398 typedef std::set<QuicStreamRequest*> RequestSet; | 418 typedef std::set<QuicStreamRequest*> RequestSet; |
399 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; | 419 typedef std::map<QuicServerId, RequestSet> ServerIDRequestsMap; |
400 typedef std::map<QuicServerId, std::unique_ptr<CertVerifierJob>> | 420 typedef std::map<QuicServerId, std::unique_ptr<CertVerifierJob>> |
401 CertVerifierJobMap; | 421 CertVerifierJobMap; |
402 | 422 |
| 423 // Creates a job which doesn't wait for server config to be loaded from the |
| 424 // disk cache. This job is started via a PostTask. |
| 425 void CreateAuxilaryJob(const QuicSessionKey& key, |
| 426 int cert_verify_flags, |
| 427 const NetLogWithSource& net_log); |
| 428 |
403 // Returns a newly created QuicHttpStream owned by the caller. | 429 // Returns a newly created QuicHttpStream owned by the caller. |
404 std::unique_ptr<QuicHttpStream> CreateFromSession( | 430 std::unique_ptr<QuicHttpStream> CreateFromSession( |
405 QuicChromiumClientSession* session); | 431 QuicChromiumClientSession* session); |
406 | 432 |
407 bool OnResolution(const QuicSessionKey& key, const AddressList& address_list); | 433 bool OnResolution(const QuicSessionKey& key, const AddressList& address_list); |
408 void OnJobComplete(Job* job, int rv); | 434 void OnJobComplete(Job* job, int rv); |
409 void OnCertVerifyJobComplete(CertVerifierJob* job, int rv); | 435 void OnCertVerifyJobComplete(CertVerifierJob* job, int rv); |
410 bool HasActiveSession(const QuicServerId& server_id) const; | 436 bool HasActiveSession(const QuicServerId& server_id) const; |
411 bool HasActiveJob(const QuicServerId& server_id) const; | 437 bool HasActiveJob(const QuicServerId& server_id) const; |
412 bool HasActiveCertVerifierJob(const QuicServerId& server_id) const; | 438 bool HasActiveCertVerifierJob(const QuicServerId& server_id) const; |
413 int CreateSession(const QuicSessionKey& key, | 439 int CreateSession(const QuicSessionKey& key, |
414 int cert_verify_flags, | 440 int cert_verify_flags, |
| 441 std::unique_ptr<QuicServerInfo> quic_server_info, |
415 bool require_confirmation, | 442 bool require_confirmation, |
416 const AddressList& address_list, | 443 const AddressList& address_list, |
417 base::TimeTicks dns_resolution_start_time, | 444 base::TimeTicks dns_resolution_start_time, |
418 base::TimeTicks dns_resolution_end_time, | 445 base::TimeTicks dns_resolution_end_time, |
419 const NetLogWithSource& net_log, | 446 const NetLogWithSource& net_log, |
420 QuicChromiumClientSession** session); | 447 QuicChromiumClientSession** session); |
421 void ActivateSession(const QuicSessionKey& key, | 448 void ActivateSession(const QuicSessionKey& key, |
422 QuicChromiumClientSession* session); | 449 QuicChromiumClientSession* session); |
423 | 450 |
424 void ConfigureInitialRttEstimate(const QuicServerId& server_id, | 451 void ConfigureInitialRttEstimate(const QuicServerId& server_id, |
(...skipping 25 matching lines...) Expand all Loading... |
450 | 477 |
451 // Initializes the cached state associated with |server_id| in | 478 // Initializes the cached state associated with |server_id| in |
452 // |crypto_config_| with the information in |server_info|. Populates | 479 // |crypto_config_| with the information in |server_info|. Populates |
453 // |connection_id| with the next server designated connection id, | 480 // |connection_id| with the next server designated connection id, |
454 // if any, and otherwise leaves it unchanged. | 481 // if any, and otherwise leaves it unchanged. |
455 void InitializeCachedStateInCryptoConfig( | 482 void InitializeCachedStateInCryptoConfig( |
456 const QuicServerId& server_id, | 483 const QuicServerId& server_id, |
457 const std::unique_ptr<QuicServerInfo>& server_info, | 484 const std::unique_ptr<QuicServerInfo>& server_info, |
458 QuicConnectionId* connection_id); | 485 QuicConnectionId* connection_id); |
459 | 486 |
| 487 // Initialize |quic_supported_servers_at_startup_| with the list of servers |
| 488 // that supported QUIC at start up and also initialize in-memory cache of |
| 489 // QuicServerInfo objects from HttpServerProperties. |
| 490 void MaybeInitialize(); |
| 491 |
460 void ProcessGoingAwaySession(QuicChromiumClientSession* session, | 492 void ProcessGoingAwaySession(QuicChromiumClientSession* session, |
461 const QuicServerId& server_id, | 493 const QuicServerId& server_id, |
462 bool was_session_active); | 494 bool was_session_active); |
463 | 495 |
464 // Internal method that migrates |session| over to using | 496 // Internal method that migrates |session| over to using |
465 // |peer_address| and |network|. If |network| is | 497 // |peer_address| and |network|. If |network| is |
466 // kInvalidNetworkHandle, default network is used. If the migration | 498 // kInvalidNetworkHandle, default network is used. If the migration |
467 // fails and |close_session_on_error| is true, connection is closed. | 499 // fails and |close_session_on_error| is true, connection is closed. |
468 MigrationResult MigrateSessionInner( | 500 MigrationResult MigrateSessionInner( |
469 QuicChromiumClientSession* session, | 501 QuicChromiumClientSession* session, |
470 IPEndPoint peer_address, | 502 IPEndPoint peer_address, |
471 NetworkChangeNotifier::NetworkHandle network, | 503 NetworkChangeNotifier::NetworkHandle network, |
472 bool close_session_on_error, | 504 bool close_session_on_error, |
473 const NetLogWithSource& net_log); | 505 const NetLogWithSource& net_log); |
474 | 506 |
475 bool require_confirmation_; | 507 bool require_confirmation_; |
476 NetLog* net_log_; | 508 NetLog* net_log_; |
477 HostResolver* host_resolver_; | 509 HostResolver* host_resolver_; |
478 ClientSocketFactory* client_socket_factory_; | 510 ClientSocketFactory* client_socket_factory_; |
479 HttpServerProperties* http_server_properties_; | 511 HttpServerProperties* http_server_properties_; |
480 ServerPushDelegate* push_delegate_; | 512 ServerPushDelegate* push_delegate_; |
481 ProxyDelegate* proxy_delegate_; | 513 ProxyDelegate* proxy_delegate_; |
482 TransportSecurityState* transport_security_state_; | 514 TransportSecurityState* transport_security_state_; |
483 CTVerifier* cert_transparency_verifier_; | 515 CTVerifier* cert_transparency_verifier_; |
| 516 std::unique_ptr<QuicServerInfoFactory> quic_server_info_factory_; |
484 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_; | 517 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory_; |
485 QuicRandom* random_generator_; // Unowned. | 518 QuicRandom* random_generator_; // Unowned. |
486 QuicClock* clock_; // Unowned. | 519 QuicClock* clock_; // Unowned. |
487 const size_t max_packet_length_; | 520 const size_t max_packet_length_; |
488 QuicClockSkewDetector clock_skew_detector_; | 521 QuicClockSkewDetector clock_skew_detector_; |
489 | 522 |
490 // Factory which is used to create socket performance watcher. A new watcher | 523 // Factory which is used to create socket performance watcher. A new watcher |
491 // is created for every QUIC connection. | 524 // is created for every QUIC connection. |
492 // |socket_performance_watcher_factory_| may be null. | 525 // |socket_performance_watcher_factory_| may be null. |
493 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; | 526 SocketPerformanceWatcherFactory* socket_performance_watcher_factory_; |
(...skipping 24 matching lines...) Expand all Loading... |
518 | 551 |
519 JobMap active_jobs_; | 552 JobMap active_jobs_; |
520 // Map from QuicServerId to a set of non-owning QuicStreamRequest pointers. | 553 // Map from QuicServerId to a set of non-owning QuicStreamRequest pointers. |
521 ServerIDRequestsMap job_requests_map_; | 554 ServerIDRequestsMap job_requests_map_; |
522 | 555 |
523 // Map of QuicServerId to owning CertVerifierJob. | 556 // Map of QuicServerId to owning CertVerifierJob. |
524 CertVerifierJobMap active_cert_verifier_jobs_; | 557 CertVerifierJobMap active_cert_verifier_jobs_; |
525 | 558 |
526 const QuicVersionVector supported_versions_; | 559 const QuicVersionVector supported_versions_; |
527 | 560 |
| 561 // Specifies the ratio between time to load QUIC server information from disk |
| 562 // cache to 'smoothed RTT'. This ratio is used to calculate the timeout in |
| 563 // milliseconds to wait for loading of QUIC server information. If we don't |
| 564 // want to timeout, set |load_server_info_timeout_srtt_multiplier_| to 0. |
| 565 float load_server_info_timeout_srtt_multiplier_; |
| 566 |
| 567 // Set if we want to race connections - one connection that sends |
| 568 // INCHOATE_HELLO and another connection that sends CHLO after loading server |
| 569 // config from the disk cache. |
| 570 bool enable_connection_racing_; |
| 571 |
528 // Set if experimental non-blocking IO should be used on windows sockets. | 572 // Set if experimental non-blocking IO should be used on windows sockets. |
529 bool enable_non_blocking_io_; | 573 bool enable_non_blocking_io_; |
530 | 574 |
| 575 // Set if we do not want to load server config from the disk cache. |
| 576 bool disable_disk_cache_; |
| 577 |
531 // True if QUIC should be marked as broken when a connection blackholes after | 578 // True if QUIC should be marked as broken when a connection blackholes after |
532 // the handshake is confirmed. | 579 // the handshake is confirmed. |
533 bool mark_quic_broken_when_network_blackholes_; | 580 bool mark_quic_broken_when_network_blackholes_; |
534 | 581 |
535 // Set if QUIC server configs should be stored in HttpServerProperties. | |
536 bool store_server_configs_in_properties_; | |
537 | |
538 // PING timeout for connections. | 582 // PING timeout for connections. |
539 QuicTime::Delta ping_timeout_; | 583 QuicTime::Delta ping_timeout_; |
540 QuicTime::Delta reduced_ping_timeout_; | 584 QuicTime::Delta reduced_ping_timeout_; |
541 | 585 |
542 // If more than |yield_after_packets_| packets have been read or more than | 586 // If more than |yield_after_packets_| packets have been read or more than |
543 // |yield_after_duration_| time has passed, then | 587 // |yield_after_duration_| time has passed, then |
544 // QuicChromiumPacketReader::StartReading() yields by doing a PostTask(). | 588 // QuicChromiumPacketReader::StartReading() yields by doing a PostTask(). |
545 int yield_after_packets_; | 589 int yield_after_packets_; |
546 QuicTime::Delta yield_after_duration_; | 590 QuicTime::Delta yield_after_duration_; |
547 | 591 |
(...skipping 20 matching lines...) Expand all Loading... |
568 | 612 |
569 // If set, configure QUIC sockets to not fragment packets. | 613 // If set, configure QUIC sockets to not fragment packets. |
570 bool do_not_fragment_; | 614 bool do_not_fragment_; |
571 | 615 |
572 // If true, estimate the initial RTT based on network type. | 616 // If true, estimate the initial RTT based on network type. |
573 bool estimate_initial_rtt; | 617 bool estimate_initial_rtt; |
574 | 618 |
575 // Local address of socket that was created in CreateSession. | 619 // Local address of socket that was created in CreateSession. |
576 IPEndPoint local_address_; | 620 IPEndPoint local_address_; |
577 bool check_persisted_supports_quic_; | 621 bool check_persisted_supports_quic_; |
| 622 bool has_initialized_data_; |
| 623 std::set<HostPortPair> quic_supported_servers_at_startup_; |
578 | 624 |
579 NetworkConnection network_connection_; | 625 NetworkConnection network_connection_; |
580 | 626 |
581 int num_push_streams_created_; | 627 int num_push_streams_created_; |
582 | 628 |
583 QuicClientPushPromiseIndex push_promise_index_; | 629 QuicClientPushPromiseIndex push_promise_index_; |
584 | 630 |
585 base::TaskRunner* task_runner_; | 631 base::TaskRunner* task_runner_; |
586 | 632 |
587 const scoped_refptr<SSLConfigService> ssl_config_service_; | 633 const scoped_refptr<SSLConfigService> ssl_config_service_; |
588 | 634 |
589 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; | 635 base::WeakPtrFactory<QuicStreamFactory> weak_factory_; |
590 | 636 |
591 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); | 637 DISALLOW_COPY_AND_ASSIGN(QuicStreamFactory); |
592 }; | 638 }; |
593 | 639 |
594 } // namespace net | 640 } // namespace net |
595 | 641 |
596 #endif // NET_QUIC_CHROMIUM_QUIC_STREAM_FACTORY_H_ | 642 #endif // NET_QUIC_CHROMIUM_QUIC_STREAM_FACTORY_H_ |
OLD | NEW |