| 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 |
| 11 #include <openssl/aead.h> |
| 12 |
| 11 #include "base/location.h" | 13 #include "base/location.h" |
| 12 #include "base/macros.h" | 14 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 14 #include "base/metrics/field_trial.h" | 16 #include "base/metrics/field_trial.h" |
| 15 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 16 #include "base/metrics/sparse_histogram.h" | 18 #include "base/metrics/sparse_histogram.h" |
| 17 #include "base/rand_util.h" | 19 #include "base/rand_util.h" |
| 18 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 19 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
| 20 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 21 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
| 22 #include "base/thread_task_runner_handle.h" | 24 #include "base/thread_task_runner_handle.h" |
| 23 #include "base/trace_event/trace_event.h" | 25 #include "base/trace_event/trace_event.h" |
| 24 #include "base/values.h" | 26 #include "base/values.h" |
| 27 #include "crypto/openssl_util.h" |
| 25 #include "net/base/ip_address.h" | 28 #include "net/base/ip_address.h" |
| 26 #include "net/base/net_errors.h" | 29 #include "net/base/net_errors.h" |
| 27 #include "net/base/socket_performance_watcher.h" | 30 #include "net/base/socket_performance_watcher.h" |
| 28 #include "net/base/socket_performance_watcher_factory.h" | 31 #include "net/base/socket_performance_watcher_factory.h" |
| 29 #include "net/cert/cert_verifier.h" | 32 #include "net/cert/cert_verifier.h" |
| 30 #include "net/cert/ct_verifier.h" | 33 #include "net/cert/ct_verifier.h" |
| 31 #include "net/dns/host_resolver.h" | 34 #include "net/dns/host_resolver.h" |
| 32 #include "net/dns/single_request_host_resolver.h" | 35 #include "net/dns/single_request_host_resolver.h" |
| 33 #include "net/http/bidirectional_stream_impl.h" | 36 #include "net/http/bidirectional_stream_impl.h" |
| 34 #include "net/quic/bidirectional_stream_quic_impl.h" | 37 #include "net/quic/bidirectional_stream_quic_impl.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 51 #include "net/quic/quic_protocol.h" | 54 #include "net/quic/quic_protocol.h" |
| 52 #include "net/quic/quic_server_id.h" | 55 #include "net/quic/quic_server_id.h" |
| 53 #include "net/socket/client_socket_factory.h" | 56 #include "net/socket/client_socket_factory.h" |
| 54 #include "net/ssl/token_binding.h" | 57 #include "net/ssl/token_binding.h" |
| 55 #include "net/udp/udp_client_socket.h" | 58 #include "net/udp/udp_client_socket.h" |
| 56 | 59 |
| 57 #if defined(OS_WIN) | 60 #if defined(OS_WIN) |
| 58 #include "base/win/windows_version.h" | 61 #include "base/win/windows_version.h" |
| 59 #endif | 62 #endif |
| 60 | 63 |
| 61 #if defined(USE_OPENSSL) | |
| 62 #include <openssl/aead.h> | |
| 63 #include "crypto/openssl_util.h" | |
| 64 #else | |
| 65 #include "base/cpu.h" | |
| 66 #endif | |
| 67 | |
| 68 using std::min; | 64 using std::min; |
| 69 using std::vector; | 65 using std::vector; |
| 70 using NetworkHandle = net::NetworkChangeNotifier::NetworkHandle; | 66 using NetworkHandle = net::NetworkChangeNotifier::NetworkHandle; |
| 71 | 67 |
| 72 namespace net { | 68 namespace net { |
| 73 | 69 |
| 74 namespace { | 70 namespace { |
| 75 | 71 |
| 76 enum CreateSessionFailure { | 72 enum CreateSessionFailure { |
| 77 CREATION_ERROR_CONNECTING_SOCKET, | 73 CREATION_ERROR_CONNECTING_SOCKET, |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 670 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
| 675 crypto_config_.AddCanonicalSuffix(".googleusercontent.com"); | 671 crypto_config_.AddCanonicalSuffix(".googleusercontent.com"); |
| 676 // TODO(rtenneti): http://crbug.com/487355. Temporary fix for b/20760730 until | 672 // TODO(rtenneti): http://crbug.com/487355. Temporary fix for b/20760730 until |
| 677 // channel_id_service is supported in cronet. | 673 // channel_id_service is supported in cronet. |
| 678 if (channel_id_service) { | 674 if (channel_id_service) { |
| 679 crypto_config_.SetChannelIDSource( | 675 crypto_config_.SetChannelIDSource( |
| 680 new ChannelIDSourceChromium(channel_id_service)); | 676 new ChannelIDSourceChromium(channel_id_service)); |
| 681 } | 677 } |
| 682 if (enable_token_binding && channel_id_service && IsTokenBindingSupported()) | 678 if (enable_token_binding && channel_id_service && IsTokenBindingSupported()) |
| 683 crypto_config_.tb_key_params.push_back(kP256); | 679 crypto_config_.tb_key_params.push_back(kP256); |
| 684 #if defined(USE_OPENSSL) | |
| 685 crypto::EnsureOpenSSLInit(); | 680 crypto::EnsureOpenSSLInit(); |
| 686 bool has_aes_hardware_support = !!EVP_has_aes_hardware(); | 681 bool has_aes_hardware_support = !!EVP_has_aes_hardware(); |
| 687 #else | |
| 688 base::CPU cpu; | |
| 689 bool has_aes_hardware_support = cpu.has_aesni() && cpu.has_avx(); | |
| 690 #endif | |
| 691 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.PreferAesGcm", | 682 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.PreferAesGcm", |
| 692 has_aes_hardware_support); | 683 has_aes_hardware_support); |
| 693 if (has_aes_hardware_support || prefer_aes_) | 684 if (has_aes_hardware_support || prefer_aes_) |
| 694 crypto_config_.PreferAesGcm(); | 685 crypto_config_.PreferAesGcm(); |
| 695 if (!IsEcdsaSupported()) | 686 if (!IsEcdsaSupported()) |
| 696 crypto_config_.DisableEcdsa(); | 687 crypto_config_.DisableEcdsa(); |
| 697 // When disk cache is used to store the server configs, HttpCache code calls | 688 // When disk cache is used to store the server configs, HttpCache code calls |
| 698 // |set_quic_server_info_factory| if |quic_server_info_factory_| wasn't | 689 // |set_quic_server_info_factory| if |quic_server_info_factory_| wasn't |
| 699 // created. | 690 // created. |
| 700 if (max_server_configs_stored_in_properties > 0) { | 691 if (max_server_configs_stored_in_properties > 0) { |
| (...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 // Since the session was active, there's no longer an | 1762 // Since the session was active, there's no longer an |
| 1772 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1763 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
| 1773 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1764 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
| 1774 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1765 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1775 // still race. | 1766 // still race. |
| 1776 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1767 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1777 alternative_service); | 1768 alternative_service); |
| 1778 } | 1769 } |
| 1779 | 1770 |
| 1780 } // namespace net | 1771 } // namespace net |
| OLD | NEW |