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