Chromium Code Reviews| 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/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) | |
| 61 #include <openssl/aead.h> | |
| 62 #include "crypto/openssl_util.h" | |
| 63 #else | |
| 64 #include "base/cpu.h" | |
| 65 #endif | |
| 66 | |
| 67 using std::min; | 63 using std::min; |
| 68 using std::vector; | 64 using std::vector; |
| 69 using NetworkHandle = net::NetworkChangeNotifier::NetworkHandle; | 65 using NetworkHandle = net::NetworkChangeNotifier::NetworkHandle; |
| 70 | 66 |
| 71 namespace net { | 67 namespace net { |
| 72 | 68 |
| 73 namespace { | 69 namespace { |
| 74 | 70 |
| 75 enum CreateSessionFailure { | 71 enum CreateSessionFailure { |
| 76 CREATION_ERROR_CONNECTING_SOCKET, | 72 CREATION_ERROR_CONNECTING_SOCKET, |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 673 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); | 669 crypto_config_.AddCanonicalSuffix(".googlevideo.com"); |
| 674 crypto_config_.AddCanonicalSuffix(".googleusercontent.com"); | 670 crypto_config_.AddCanonicalSuffix(".googleusercontent.com"); |
| 675 // 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 |
| 676 // channel_id_service is supported in cronet. | 672 // channel_id_service is supported in cronet. |
| 677 if (channel_id_service) { | 673 if (channel_id_service) { |
| 678 crypto_config_.SetChannelIDSource( | 674 crypto_config_.SetChannelIDSource( |
| 679 new ChannelIDSourceChromium(channel_id_service)); | 675 new ChannelIDSourceChromium(channel_id_service)); |
| 680 } | 676 } |
| 681 if (enable_token_binding && channel_id_service && IsTokenBindingSupported()) | 677 if (enable_token_binding && channel_id_service && IsTokenBindingSupported()) |
| 682 crypto_config_.tb_key_params.push_back(kP256); | 678 crypto_config_.tb_key_params.push_back(kP256); |
| 683 #if defined(USE_OPENSSL) | |
| 684 crypto::EnsureOpenSSLInit(); | 679 crypto::EnsureOpenSSLInit(); |
| 685 bool has_aes_hardware_support = !!EVP_has_aes_hardware(); | 680 bool has_aes_hardware_support = !!EVP_has_aes_hardware(); |
| 686 #else | |
| 687 base::CPU cpu; | |
| 688 bool has_aes_hardware_support = cpu.has_aesni() && cpu.has_avx(); | |
|
davidben
2016/04/18 19:36:45
As follow-up: we can probably prune some stuff fro
svaldez
2016/04/18 20:21:40
Acknowledged.
| |
| 689 #endif | |
| 690 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.PreferAesGcm", | 681 UMA_HISTOGRAM_BOOLEAN("Net.QuicSession.PreferAesGcm", |
| 691 has_aes_hardware_support); | 682 has_aes_hardware_support); |
| 692 if (has_aes_hardware_support || prefer_aes_) | 683 if (has_aes_hardware_support || prefer_aes_) |
| 693 crypto_config_.PreferAesGcm(); | 684 crypto_config_.PreferAesGcm(); |
| 694 if (!IsEcdsaSupported()) | 685 if (!IsEcdsaSupported()) |
| 695 crypto_config_.DisableEcdsa(); | 686 crypto_config_.DisableEcdsa(); |
| 696 // 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 |
| 697 // |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 |
| 698 // created. | 689 // created. |
| 699 if (max_server_configs_stored_in_properties > 0) { | 690 if (max_server_configs_stored_in_properties > 0) { |
| (...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1767 // Since the session was active, there's no longer an | 1758 // Since the session was active, there's no longer an |
| 1768 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1759 // 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 | 1760 // 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 | 1761 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1771 // still race. | 1762 // still race. |
| 1772 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1763 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1773 alternative_service); | 1764 alternative_service); |
| 1774 } | 1765 } |
| 1775 | 1766 |
| 1776 } // namespace net | 1767 } // namespace net |
| OLD | NEW |