| 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/chromium/quic_stream_factory.h" | 5 #include "net/quic/chromium/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include <openssl/aead.h> | 7 #include <openssl/aead.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <tuple> | 10 #include <tuple> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/metrics/field_trial.h" | 15 #include "base/metrics/field_trial.h" |
| 16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 17 #include "base/metrics/sparse_histogram.h" | 17 #include "base/metrics/sparse_histogram.h" |
| 18 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
| 19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 20 #include "base/stl_util.h" | 20 #include "base/stl_util.h" |
| 21 #include "base/strings/string_number_conversions.h" | 21 #include "base/strings/string_number_conversions.h" |
| 22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 24 #include "base/threading/thread_task_runner_handle.h" | 24 #include "base/threading/thread_task_runner_handle.h" |
| 25 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
| 26 #include "base/values.h" | 26 #include "base/values.h" |
| 27 #include "crypto/openssl_util.h" | 27 #include "crypto/openssl_util.h" |
| 28 #include "net/base/ip_address.h" | 28 #include "net/base/ip_address.h" |
| 29 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
| 30 #include "net/base/proxy_delegate.h" |
| 30 #include "net/cert/cert_verifier.h" | 31 #include "net/cert/cert_verifier.h" |
| 31 #include "net/cert/ct_verifier.h" | 32 #include "net/cert/ct_verifier.h" |
| 32 #include "net/dns/host_resolver.h" | 33 #include "net/dns/host_resolver.h" |
| 33 #include "net/http/bidirectional_stream_impl.h" | 34 #include "net/http/bidirectional_stream_impl.h" |
| 34 #include "net/log/net_log_capture_mode.h" | 35 #include "net/log/net_log_capture_mode.h" |
| 35 #include "net/log/net_log_event_type.h" | 36 #include "net/log/net_log_event_type.h" |
| 36 #include "net/log/net_log_source_type.h" | 37 #include "net/log/net_log_source_type.h" |
| 37 #include "net/quic/chromium/bidirectional_stream_quic_impl.h" | 38 #include "net/quic/chromium/bidirectional_stream_quic_impl.h" |
| 38 #include "net/quic/chromium/crypto/channel_id_chromium.h" | 39 #include "net/quic/chromium/crypto/channel_id_chromium.h" |
| 39 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" | 40 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 return nullptr; | 699 return nullptr; |
| 699 return base::MakeUnique<BidirectionalStreamQuicImpl>(session_); | 700 return base::MakeUnique<BidirectionalStreamQuicImpl>(session_); |
| 700 } | 701 } |
| 701 | 702 |
| 702 QuicStreamFactory::QuicStreamFactory( | 703 QuicStreamFactory::QuicStreamFactory( |
| 703 NetLog* net_log, | 704 NetLog* net_log, |
| 704 HostResolver* host_resolver, | 705 HostResolver* host_resolver, |
| 705 SSLConfigService* ssl_config_service, | 706 SSLConfigService* ssl_config_service, |
| 706 ClientSocketFactory* client_socket_factory, | 707 ClientSocketFactory* client_socket_factory, |
| 707 HttpServerProperties* http_server_properties, | 708 HttpServerProperties* http_server_properties, |
| 709 ProxyDelegate* proxy_delegate, |
| 708 CertVerifier* cert_verifier, | 710 CertVerifier* cert_verifier, |
| 709 CTPolicyEnforcer* ct_policy_enforcer, | 711 CTPolicyEnforcer* ct_policy_enforcer, |
| 710 ChannelIDService* channel_id_service, | 712 ChannelIDService* channel_id_service, |
| 711 TransportSecurityState* transport_security_state, | 713 TransportSecurityState* transport_security_state, |
| 712 CTVerifier* cert_transparency_verifier, | 714 CTVerifier* cert_transparency_verifier, |
| 713 SocketPerformanceWatcherFactory* socket_performance_watcher_factory, | 715 SocketPerformanceWatcherFactory* socket_performance_watcher_factory, |
| 714 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, | 716 QuicCryptoClientStreamFactory* quic_crypto_client_stream_factory, |
| 715 QuicRandom* random_generator, | 717 QuicRandom* random_generator, |
| 716 QuicClock* clock, | 718 QuicClock* clock, |
| 717 size_t max_packet_length, | 719 size_t max_packet_length, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 739 bool force_hol_blocking, | 741 bool force_hol_blocking, |
| 740 bool race_cert_verification, | 742 bool race_cert_verification, |
| 741 bool quic_do_not_fragment, | 743 bool quic_do_not_fragment, |
| 742 const QuicTagVector& connection_options, | 744 const QuicTagVector& connection_options, |
| 743 bool enable_token_binding) | 745 bool enable_token_binding) |
| 744 : require_confirmation_(true), | 746 : require_confirmation_(true), |
| 745 net_log_(net_log), | 747 net_log_(net_log), |
| 746 host_resolver_(host_resolver), | 748 host_resolver_(host_resolver), |
| 747 client_socket_factory_(client_socket_factory), | 749 client_socket_factory_(client_socket_factory), |
| 748 http_server_properties_(http_server_properties), | 750 http_server_properties_(http_server_properties), |
| 751 proxy_delegate_(proxy_delegate), |
| 749 transport_security_state_(transport_security_state), | 752 transport_security_state_(transport_security_state), |
| 750 cert_transparency_verifier_(cert_transparency_verifier), | 753 cert_transparency_verifier_(cert_transparency_verifier), |
| 751 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), | 754 quic_crypto_client_stream_factory_(quic_crypto_client_stream_factory), |
| 752 random_generator_(random_generator), | 755 random_generator_(random_generator), |
| 753 clock_(clock), | 756 clock_(clock), |
| 754 max_packet_length_(max_packet_length), | 757 max_packet_length_(max_packet_length), |
| 755 socket_performance_watcher_factory_(socket_performance_watcher_factory), | 758 socket_performance_watcher_factory_(socket_performance_watcher_factory), |
| 756 config_(InitializeQuicConfig(connection_options, | 759 config_(InitializeQuicConfig(connection_options, |
| 757 idle_connection_timeout_seconds)), | 760 idle_connection_timeout_seconds)), |
| 758 crypto_config_(base::WrapUnique( | 761 crypto_config_(base::WrapUnique( |
| (...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1819 | 1822 |
| 1820 void QuicStreamFactory::MaybeInitialize() { | 1823 void QuicStreamFactory::MaybeInitialize() { |
| 1821 // We don't initialize data from HttpServerProperties in the constructor | 1824 // We don't initialize data from HttpServerProperties in the constructor |
| 1822 // because HttpServerProperties has not yet initialized. We're guaranteed | 1825 // because HttpServerProperties has not yet initialized. We're guaranteed |
| 1823 // HttpServerProperties has been initialized by the first time a request is | 1826 // HttpServerProperties has been initialized by the first time a request is |
| 1824 // made. | 1827 // made. |
| 1825 if (has_initialized_data_) | 1828 if (has_initialized_data_) |
| 1826 return; | 1829 return; |
| 1827 | 1830 |
| 1828 has_initialized_data_ = true; | 1831 has_initialized_data_ = true; |
| 1832 |
| 1833 // Query the proxy delegate for the default alternative proxy server. |
| 1834 ProxyServer default_alternative_proxy_server = |
| 1835 proxy_delegate_ ? proxy_delegate_->GetDefaultAlternativeProxy() |
| 1836 : ProxyServer(); |
| 1837 if (default_alternative_proxy_server.is_quic()) { |
| 1838 quic_supported_servers_at_startup_.insert( |
| 1839 default_alternative_proxy_server.host_port_pair()); |
| 1840 } |
| 1841 |
| 1829 for (const std::pair<const url::SchemeHostPort, AlternativeServiceInfoVector>& | 1842 for (const std::pair<const url::SchemeHostPort, AlternativeServiceInfoVector>& |
| 1830 key_value : http_server_properties_->alternative_service_map()) { | 1843 key_value : http_server_properties_->alternative_service_map()) { |
| 1831 HostPortPair host_port_pair(key_value.first.host(), key_value.first.port()); | 1844 HostPortPair host_port_pair(key_value.first.host(), key_value.first.port()); |
| 1832 for (const AlternativeServiceInfo& alternative_service_info : | 1845 for (const AlternativeServiceInfo& alternative_service_info : |
| 1833 key_value.second) { | 1846 key_value.second) { |
| 1834 if (alternative_service_info.alternative_service.protocol == QUIC) { | 1847 if (alternative_service_info.alternative_service.protocol == QUIC) { |
| 1835 quic_supported_servers_at_startup_.insert(host_port_pair); | 1848 quic_supported_servers_at_startup_.insert(host_port_pair); |
| 1836 break; | 1849 break; |
| 1837 } | 1850 } |
| 1838 } | 1851 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1907 void QuicStreamFactory::OpenFactory() { | 1920 void QuicStreamFactory::OpenFactory() { |
| 1908 status_ = OPEN; | 1921 status_ = OPEN; |
| 1909 } | 1922 } |
| 1910 | 1923 |
| 1911 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { | 1924 void QuicStreamFactory::MaybeClearConsecutiveDisabledCount() { |
| 1912 if (status_ == OPEN) | 1925 if (status_ == OPEN) |
| 1913 consecutive_disabled_count_ = 0; | 1926 consecutive_disabled_count_ = 0; |
| 1914 } | 1927 } |
| 1915 | 1928 |
| 1916 } // namespace net | 1929 } // namespace net |
| OLD | NEW |