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