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