| 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> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 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/cert/cert_verifier.h" | 30 #include "net/cert/cert_verifier.h" |
| 31 #include "net/cert/ct_verifier.h" | 31 #include "net/cert/ct_verifier.h" |
| 32 #include "net/dns/host_resolver.h" | 32 #include "net/dns/host_resolver.h" |
| 33 #include "net/http/bidirectional_stream_impl.h" | 33 #include "net/http/bidirectional_stream_impl.h" |
| 34 #include "net/log/net_log_event_type.h" |
| 35 #include "net/log/net_log_source_type.h" |
| 34 #include "net/quic/chromium/bidirectional_stream_quic_impl.h" | 36 #include "net/quic/chromium/bidirectional_stream_quic_impl.h" |
| 35 #include "net/quic/chromium/crypto/channel_id_chromium.h" | 37 #include "net/quic/chromium/crypto/channel_id_chromium.h" |
| 36 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" | 38 #include "net/quic/chromium/crypto/proof_verifier_chromium.h" |
| 37 #include "net/quic/chromium/port_suggester.h" | 39 #include "net/quic/chromium/port_suggester.h" |
| 38 #include "net/quic/chromium/quic_chromium_alarm_factory.h" | 40 #include "net/quic/chromium/quic_chromium_alarm_factory.h" |
| 39 #include "net/quic/chromium/quic_chromium_connection_helper.h" | 41 #include "net/quic/chromium/quic_chromium_connection_helper.h" |
| 40 #include "net/quic/chromium/quic_chromium_packet_reader.h" | 42 #include "net/quic/chromium/quic_chromium_packet_reader.h" |
| 41 #include "net/quic/chromium/quic_chromium_packet_writer.h" | 43 #include "net/quic/chromium/quic_chromium_packet_writer.h" |
| 42 #include "net/quic/core/crypto/proof_verifier.h" | 44 #include "net/quic/core/crypto/proof_verifier.h" |
| 43 #include "net/quic/core/crypto/properties_based_quic_server_info.h" | 45 #include "net/quic/core/crypto/properties_based_quic_server_info.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 116 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 115 dict->SetString("connection_id", base::Uint64ToString(connection_id)); | 117 dict->SetString("connection_id", base::Uint64ToString(connection_id)); |
| 116 return std::move(dict); | 118 return std::move(dict); |
| 117 } | 119 } |
| 118 | 120 |
| 119 // Helper class that is used to log a connection migration event. | 121 // Helper class that is used to log a connection migration event. |
| 120 class ScopedConnectionMigrationEventLog { | 122 class ScopedConnectionMigrationEventLog { |
| 121 public: | 123 public: |
| 122 ScopedConnectionMigrationEventLog(NetLog* net_log, std::string trigger) | 124 ScopedConnectionMigrationEventLog(NetLog* net_log, std::string trigger) |
| 123 : net_log_(BoundNetLog::Make(net_log, | 125 : net_log_(BoundNetLog::Make(net_log, |
| 124 NetLog::SOURCE_QUIC_CONNECTION_MIGRATION)) { | 126 NetLogSourceType::QUIC_CONNECTION_MIGRATION)) { |
| 125 net_log_.BeginEvent( | 127 net_log_.BeginEvent( |
| 126 NetLog::TYPE_QUIC_CONNECTION_MIGRATION_TRIGGERED, | 128 NetLogEventType::QUIC_CONNECTION_MIGRATION_TRIGGERED, |
| 127 base::Bind(&NetLogQuicConnectionMigrationTriggerCallback, trigger)); | 129 base::Bind(&NetLogQuicConnectionMigrationTriggerCallback, trigger)); |
| 128 } | 130 } |
| 129 | 131 |
| 130 ~ScopedConnectionMigrationEventLog() { | 132 ~ScopedConnectionMigrationEventLog() { |
| 131 net_log_.EndEvent(NetLog::TYPE_QUIC_CONNECTION_MIGRATION_TRIGGERED); | 133 net_log_.EndEvent(NetLogEventType::QUIC_CONNECTION_MIGRATION_TRIGGERED); |
| 132 } | 134 } |
| 133 | 135 |
| 134 const BoundNetLog& net_log() { return net_log_; } | 136 const BoundNetLog& net_log() { return net_log_; } |
| 135 | 137 |
| 136 private: | 138 private: |
| 137 const BoundNetLog net_log_; | 139 const BoundNetLog net_log_; |
| 138 }; | 140 }; |
| 139 | 141 |
| 140 void HistogramCreateSessionFailure(enum CreateSessionFailure error) { | 142 void HistogramCreateSessionFailure(enum CreateSessionFailure error) { |
| 141 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error, | 143 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error, |
| 142 CREATION_ERROR_MAX); | 144 CREATION_ERROR_MAX); |
| 143 } | 145 } |
| 144 | 146 |
| 145 void HistogramAndLogMigrationFailure(const BoundNetLog& net_log, | 147 void HistogramAndLogMigrationFailure(const BoundNetLog& net_log, |
| 146 enum QuicConnectionMigrationStatus status, | 148 enum QuicConnectionMigrationStatus status, |
| 147 QuicConnectionId connection_id, | 149 QuicConnectionId connection_id, |
| 148 std::string reason) { | 150 std::string reason) { |
| 149 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.ConnectionMigration", status, | 151 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.ConnectionMigration", status, |
| 150 MIGRATION_STATUS_MAX); | 152 MIGRATION_STATUS_MAX); |
| 151 net_log.AddEvent(NetLog::TYPE_QUIC_CONNECTION_MIGRATION_FAILURE, | 153 net_log.AddEvent(NetLogEventType::QUIC_CONNECTION_MIGRATION_FAILURE, |
| 152 base::Bind(&NetLogQuicConnectionMigrationFailureCallback, | 154 base::Bind(&NetLogQuicConnectionMigrationFailureCallback, |
| 153 connection_id, reason)); | 155 connection_id, reason)); |
| 154 } | 156 } |
| 155 | 157 |
| 156 void HistogramMigrationStatus(enum QuicConnectionMigrationStatus status) { | 158 void HistogramMigrationStatus(enum QuicConnectionMigrationStatus status) { |
| 157 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.ConnectionMigration", status, | 159 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.ConnectionMigration", status, |
| 158 MIGRATION_STATUS_MAX); | 160 MIGRATION_STATUS_MAX); |
| 159 } | 161 } |
| 160 | 162 |
| 161 QuicConfig InitializeQuicConfig(const QuicTagVector& connection_options, | 163 QuicConfig InitializeQuicConfig(const QuicTagVector& connection_options, |
| (...skipping 1488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1650 bound_net_log, MIGRATION_STATUS_TOO_MANY_CHANGES, | 1652 bound_net_log, MIGRATION_STATUS_TOO_MANY_CHANGES, |
| 1651 session->connection_id(), "Too many migrations"); | 1653 session->connection_id(), "Too many migrations"); |
| 1652 if (close_session_on_error) { | 1654 if (close_session_on_error) { |
| 1653 session->CloseSessionOnError(ERR_NETWORK_CHANGED, | 1655 session->CloseSessionOnError(ERR_NETWORK_CHANGED, |
| 1654 QUIC_CONNECTION_MIGRATION_TOO_MANY_CHANGES); | 1656 QUIC_CONNECTION_MIGRATION_TOO_MANY_CHANGES); |
| 1655 } | 1657 } |
| 1656 return; | 1658 return; |
| 1657 } | 1659 } |
| 1658 HistogramMigrationStatus(MIGRATION_STATUS_SUCCESS); | 1660 HistogramMigrationStatus(MIGRATION_STATUS_SUCCESS); |
| 1659 bound_net_log.AddEvent( | 1661 bound_net_log.AddEvent( |
| 1660 NetLog::TYPE_QUIC_CONNECTION_MIGRATION_SUCCESS, | 1662 NetLogEventType::QUIC_CONNECTION_MIGRATION_SUCCESS, |
| 1661 base::Bind(&NetLogQuicConnectionMigrationSuccessCallback, | 1663 base::Bind(&NetLogQuicConnectionMigrationSuccessCallback, |
| 1662 session->connection_id())); | 1664 session->connection_id())); |
| 1663 } | 1665 } |
| 1664 | 1666 |
| 1665 void QuicStreamFactory::OnSSLConfigChanged() { | 1667 void QuicStreamFactory::OnSSLConfigChanged() { |
| 1666 CloseAllSessions(ERR_CERT_DATABASE_CHANGED, QUIC_CONNECTION_CANCELLED); | 1668 CloseAllSessions(ERR_CERT_DATABASE_CHANGED, QUIC_CONNECTION_CANCELLED); |
| 1667 } | 1669 } |
| 1668 | 1670 |
| 1669 void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) { | 1671 void QuicStreamFactory::OnCertAdded(const X509Certificate* cert) { |
| 1670 CloseAllSessions(ERR_CERT_DATABASE_CHANGED, QUIC_CONNECTION_CANCELLED); | 1672 CloseAllSessions(ERR_CERT_DATABASE_CHANGED, QUIC_CONNECTION_CANCELLED); |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2053 // Since the session was active, there's no longer an | 2055 // Since the session was active, there's no longer an |
| 2054 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 2056 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
| 2055 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 2057 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
| 2056 // it as recently broken, which means that 0-RTT will be disabled but we'll | 2058 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 2057 // still race. | 2059 // still race. |
| 2058 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 2060 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 2059 alternative_service); | 2061 alternative_service); |
| 2060 } | 2062 } |
| 2061 | 2063 |
| 2062 } // namespace net | 2064 } // namespace net |
| OLD | NEW |