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 #include "net/quic/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
563 bool enable_non_blocking_io, | 563 bool enable_non_blocking_io, |
564 bool disable_disk_cache, | 564 bool disable_disk_cache, |
565 bool prefer_aes, | 565 bool prefer_aes, |
566 int max_number_of_lossy_connections, | 566 int max_number_of_lossy_connections, |
567 float packet_loss_threshold, | 567 float packet_loss_threshold, |
568 int max_disabled_reasons, | 568 int max_disabled_reasons, |
569 int threshold_public_resets_post_handshake, | 569 int threshold_public_resets_post_handshake, |
570 int threshold_timeouts_with_open_streams, | 570 int threshold_timeouts_with_open_streams, |
571 int socket_receive_buffer_size, | 571 int socket_receive_buffer_size, |
572 bool delay_tcp_race, | 572 bool delay_tcp_race, |
573 bool store_server_configs_in_properties, | 573 int number_of_server_configs_stored_in_properties, |
574 bool close_sessions_on_ip_change, | 574 bool close_sessions_on_ip_change, |
575 int idle_connection_timeout_seconds, | 575 int idle_connection_timeout_seconds, |
576 const QuicTagVector& connection_options) | 576 const QuicTagVector& connection_options) |
577 : require_confirmation_(true), | 577 : require_confirmation_(true), |
578 host_resolver_(host_resolver), | 578 host_resolver_(host_resolver), |
579 client_socket_factory_(client_socket_factory), | 579 client_socket_factory_(client_socket_factory), |
580 http_server_properties_(http_server_properties), | 580 http_server_properties_(http_server_properties), |
581 transport_security_state_(transport_security_state), | 581 transport_security_state_(transport_security_state), |
582 cert_transparency_verifier_(cert_transparency_verifier), | 582 cert_transparency_verifier_(cert_transparency_verifier), |
583 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 583 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
(...skipping 27 matching lines...) Expand all Loading... | |
611 max_timeouts_with_open_streams_(0), | 611 max_timeouts_with_open_streams_(0), |
612 threshold_timeouts_with_open_streams_( | 612 threshold_timeouts_with_open_streams_( |
613 threshold_timeouts_with_open_streams), | 613 threshold_timeouts_with_open_streams), |
614 threshold_public_resets_post_handshake_( | 614 threshold_public_resets_post_handshake_( |
615 threshold_public_resets_post_handshake), | 615 threshold_public_resets_post_handshake), |
616 socket_receive_buffer_size_(socket_receive_buffer_size), | 616 socket_receive_buffer_size_(socket_receive_buffer_size), |
617 delay_tcp_race_(delay_tcp_race), | 617 delay_tcp_race_(delay_tcp_race), |
618 yield_after_packets_(kQuicYieldAfterPacketsRead), | 618 yield_after_packets_(kQuicYieldAfterPacketsRead), |
619 yield_after_duration_(QuicTime::Delta::FromMilliseconds( | 619 yield_after_duration_(QuicTime::Delta::FromMilliseconds( |
620 kQuicYieldAfterDurationMilliseconds)), | 620 kQuicYieldAfterDurationMilliseconds)), |
621 store_server_configs_in_properties_(store_server_configs_in_properties), | 621 number_of_server_configs_stored_in_properties_( |
622 number_of_server_configs_stored_in_properties), | |
622 close_sessions_on_ip_change_(close_sessions_on_ip_change), | 623 close_sessions_on_ip_change_(close_sessions_on_ip_change), |
623 port_seed_(random_generator_->RandUint64()), | 624 port_seed_(random_generator_->RandUint64()), |
624 check_persisted_supports_quic_(true), | 625 check_persisted_supports_quic_(true), |
625 has_initialized_data_(false), | 626 has_initialized_data_(false), |
626 task_runner_(nullptr), | 627 task_runner_(nullptr), |
627 weak_factory_(this) { | 628 weak_factory_(this) { |
628 DCHECK(transport_security_state_); | 629 DCHECK(transport_security_state_); |
629 DCHECK(http_server_properties_); | 630 DCHECK(http_server_properties_); |
630 crypto_config_.set_user_agent_id(user_agent_id); | 631 crypto_config_.set_user_agent_id(user_agent_id); |
631 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); | 632 crypto_config_.AddCanonicalSuffix(".c.youtube.com"); |
(...skipping 14 matching lines...) Expand all Loading... | |
646 #endif | 647 #endif |
647 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.PreferAesGcm", | 648 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.PreferAesGcm", |
648 has_aes_hardware_support); | 649 has_aes_hardware_support); |
649 if (has_aes_hardware_support || prefer_aes_) | 650 if (has_aes_hardware_support || prefer_aes_) |
650 crypto_config_.PreferAesGcm(); | 651 crypto_config_.PreferAesGcm(); |
651 if (!IsEcdsaSupported()) | 652 if (!IsEcdsaSupported()) |
652 crypto_config_.DisableEcdsa(); | 653 crypto_config_.DisableEcdsa(); |
653 // When disk cache is used to store the server configs, HttpCache code calls | 654 // When disk cache is used to store the server configs, HttpCache code calls |
654 // |set_quic_server_info_factory| if |quic_server_info_factory_| wasn't | 655 // |set_quic_server_info_factory| if |quic_server_info_factory_| wasn't |
655 // created. | 656 // created. |
656 if (store_server_configs_in_properties_) { | 657 if (number_of_server_configs_stored_in_properties_ > 0) { |
657 quic_server_info_factory_.reset( | 658 quic_server_info_factory_.reset( |
658 new PropertiesBasedQuicServerInfoFactory(http_server_properties_)); | 659 new PropertiesBasedQuicServerInfoFactory(http_server_properties_)); |
660 http_server_properties_->set_number_of_server_configs_stored_in_properties( | |
661 number_of_server_configs_stored_in_properties_); | |
Ryan Hamilton
2016/01/12 19:54:56
I'm a bit surprised to see this code living in Qui
ramant (doing other things)
2016/01/14 00:14:01
Done.
| |
659 } | 662 } |
660 | 663 |
661 if (close_sessions_on_ip_change_) { | 664 if (close_sessions_on_ip_change_) { |
662 NetworkChangeNotifier::AddIPAddressObserver(this); | 665 NetworkChangeNotifier::AddIPAddressObserver(this); |
663 } | 666 } |
664 } | 667 } |
665 | 668 |
666 QuicStreamFactory::~QuicStreamFactory() { | 669 QuicStreamFactory::~QuicStreamFactory() { |
667 CloseAllSessions(ERR_ABORTED); | 670 CloseAllSessions(ERR_ABORTED); |
668 while (!all_sessions_.empty()) { | 671 while (!all_sessions_.empty()) { |
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1396 key_value : http_server_properties_->alternative_service_map()) { | 1399 key_value : http_server_properties_->alternative_service_map()) { |
1397 for (const AlternativeServiceInfo& alternative_service_info : | 1400 for (const AlternativeServiceInfo& alternative_service_info : |
1398 key_value.second) { | 1401 key_value.second) { |
1399 if (alternative_service_info.alternative_service.protocol == QUIC) { | 1402 if (alternative_service_info.alternative_service.protocol == QUIC) { |
1400 quic_supported_servers_at_startup_.insert(key_value.first); | 1403 quic_supported_servers_at_startup_.insert(key_value.first); |
1401 break; | 1404 break; |
1402 } | 1405 } |
1403 } | 1406 } |
1404 } | 1407 } |
1405 | 1408 |
1406 if (!store_server_configs_in_properties_) | 1409 if (number_of_server_configs_stored_in_properties_ == 0) |
1407 return; | 1410 return; |
1408 // Create a temporary QuicServerInfo object to deserialize and to populate the | 1411 // Create a temporary QuicServerInfo object to deserialize and to populate the |
1409 // in-memory crypto server config cache. | 1412 // in-memory crypto server config cache. |
1410 scoped_ptr<QuicServerInfo> server_info; | 1413 scoped_ptr<QuicServerInfo> server_info; |
1411 CompletionCallback callback; | 1414 CompletionCallback callback; |
1412 for (const auto& key_value : | 1415 for (const auto& key_value : |
1413 http_server_properties_->quic_server_info_map()) { | 1416 http_server_properties_->quic_server_info_map()) { |
1414 const QuicServerId& server_id = key_value.first; | 1417 const QuicServerId& server_id = key_value.first; |
1415 server_info.reset(quic_server_info_factory_->GetForServer(server_id)); | 1418 server_info.reset(quic_server_info_factory_->GetForServer(server_id)); |
1416 if (server_info->WaitForDataReady(callback) == OK) { | 1419 if (server_info->WaitForDataReady(callback) == OK) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1456 // Since the session was active, there's no longer an | 1459 // Since the session was active, there's no longer an |
1457 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1460 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
1458 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1461 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
1459 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1462 // it as recently broken, which means that 0-RTT will be disabled but we'll |
1460 // still race. | 1463 // still race. |
1461 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1464 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
1462 alternative_service); | 1465 alternative_service); |
1463 } | 1466 } |
1464 | 1467 |
1465 } // namespace net | 1468 } // namespace net |
OLD | NEW |