| 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/core/quic_protocol.h" | 5 #include "net/quic/core/quic_protocol.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "net/quic/core/quic_flags.h" | 9 #include "net/quic/core/quic_flags.h" |
| 10 #include "net/quic/core/quic_utils.h" | 10 #include "net/quic/core/quic_utils.h" |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 uint32_t MakeQuicTag(char a, char b, char c, char d) { | 164 uint32_t MakeQuicTag(char a, char b, char c, char d) { |
| 165 return static_cast<uint32_t>(a) | static_cast<uint32_t>(b) << 8 | | 165 return static_cast<uint32_t>(a) | static_cast<uint32_t>(b) << 8 | |
| 166 static_cast<uint32_t>(c) << 16 | static_cast<uint32_t>(d) << 24; | 166 static_cast<uint32_t>(c) << 16 | static_cast<uint32_t>(d) << 24; |
| 167 } | 167 } |
| 168 | 168 |
| 169 bool ContainsQuicTag(const QuicTagVector& tag_vector, QuicTag tag) { | 169 bool ContainsQuicTag(const QuicTagVector& tag_vector, QuicTag tag) { |
| 170 return std::find(tag_vector.begin(), tag_vector.end(), tag) != | 170 return std::find(tag_vector.begin(), tag_vector.end(), tag) != |
| 171 tag_vector.end(); | 171 tag_vector.end(); |
| 172 } | 172 } |
| 173 | 173 |
| 174 QuicVersionVector QuicSupportedVersions() { | 174 QuicVersionVector AllSupportedVersions() { |
| 175 QuicVersionVector supported_versions; | 175 QuicVersionVector supported_versions; |
| 176 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { | 176 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { |
| 177 supported_versions.push_back(kSupportedQuicVersions[i]); | 177 supported_versions.push_back(kSupportedQuicVersions[i]); |
| 178 } | 178 } |
| 179 return supported_versions; | 179 return supported_versions; |
| 180 } | 180 } |
| 181 | 181 |
| 182 QuicVersionVector CurrentSupportedVersions() { |
| 183 return FilterSupportedVersions(AllSupportedVersions()); |
| 184 } |
| 185 |
| 182 QuicVersionVector FilterSupportedVersions(QuicVersionVector versions) { | 186 QuicVersionVector FilterSupportedVersions(QuicVersionVector versions) { |
| 183 QuicVersionVector filtered_versions(versions.size()); | 187 QuicVersionVector filtered_versions(versions.size()); |
| 184 filtered_versions.clear(); // Guaranteed by spec not to change capacity. | 188 filtered_versions.clear(); // Guaranteed by spec not to change capacity. |
| 185 for (QuicVersion version : versions) { | 189 for (QuicVersion version : versions) { |
| 186 if (version == QUIC_VERSION_35) { | 190 if (version == QUIC_VERSION_35) { |
| 187 if (FLAGS_quic_enable_version_35) { | 191 if (FLAGS_quic_enable_version_35) { |
| 188 filtered_versions.push_back(version); | 192 filtered_versions.push_back(version); |
| 189 } | 193 } |
| 190 } else if (version == QUIC_VERSION_36) { | 194 } else if (version == QUIC_VERSION_36) { |
| 191 if (FLAGS_quic_enable_version_35 && FLAGS_quic_enable_version_36) { | 195 if (FLAGS_quic_enable_version_35 && FLAGS_quic_enable_version_36) { |
| (...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 } | 841 } |
| 838 | 842 |
| 839 StringPiece QuicPacket::Plaintext(QuicVersion version) const { | 843 StringPiece QuicPacket::Plaintext(QuicVersion version) const { |
| 840 const size_t start_of_encrypted_data = GetStartOfEncryptedData( | 844 const size_t start_of_encrypted_data = GetStartOfEncryptedData( |
| 841 version, connection_id_length_, includes_version_, includes_path_id_, | 845 version, connection_id_length_, includes_version_, includes_path_id_, |
| 842 includes_diversification_nonce_, packet_number_length_); | 846 includes_diversification_nonce_, packet_number_length_); |
| 843 return StringPiece(data() + start_of_encrypted_data, | 847 return StringPiece(data() + start_of_encrypted_data, |
| 844 length() - start_of_encrypted_data); | 848 length() - start_of_encrypted_data); |
| 845 } | 849 } |
| 846 | 850 |
| 847 QuicVersionManager::QuicVersionManager(QuicVersionVector supported_versions) { | 851 QuicVersionManager::QuicVersionManager(QuicVersionVector supported_versions) |
| 848 enable_quic_version_35_ = FLAGS_quic_enable_version_35; | 852 : enable_quic_version_35_(FLAGS_quic_enable_version_35), |
| 849 enable_quic_version_36_ = FLAGS_quic_enable_version_36; | 853 enable_quic_version_36_(FLAGS_quic_enable_version_36), |
| 850 allowed_supported_versions_ = supported_versions; | 854 allowed_supported_versions_(supported_versions), |
| 851 filtered_supported_versions_ = FilterSupportedVersions(supported_versions); | 855 filtered_supported_versions_( |
| 852 } | 856 FilterSupportedVersions(supported_versions)) {} |
| 853 | 857 |
| 854 const QuicVersionVector& QuicVersionManager::GetSupportedVersions() { | 858 const QuicVersionVector& QuicVersionManager::GetSupportedVersions() { |
| 855 if (enable_quic_version_35_ != FLAGS_quic_enable_version_35 || | 859 if (enable_quic_version_35_ != FLAGS_quic_enable_version_35 || |
| 856 enable_quic_version_36_ != FLAGS_quic_enable_version_36) { | 860 enable_quic_version_36_ != FLAGS_quic_enable_version_36) { |
| 857 enable_quic_version_35_ = FLAGS_quic_enable_version_35; | 861 enable_quic_version_35_ = FLAGS_quic_enable_version_35; |
| 858 enable_quic_version_36_ = FLAGS_quic_enable_version_36; | 862 enable_quic_version_36_ = FLAGS_quic_enable_version_36; |
| 859 filtered_supported_versions_ = | 863 filtered_supported_versions_ = |
| 860 FilterSupportedVersions(allowed_supported_versions_); | 864 FilterSupportedVersions(allowed_supported_versions_); |
| 861 } | 865 } |
| 862 return filtered_supported_versions_; | 866 return filtered_supported_versions_; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 930 is_unackable(false), | 934 is_unackable(false), |
| 931 has_crypto_handshake(has_crypto_handshake), | 935 has_crypto_handshake(has_crypto_handshake), |
| 932 num_padding_bytes(num_padding_bytes), | 936 num_padding_bytes(num_padding_bytes), |
| 933 retransmission(0) {} | 937 retransmission(0) {} |
| 934 | 938 |
| 935 TransmissionInfo::TransmissionInfo(const TransmissionInfo& other) = default; | 939 TransmissionInfo::TransmissionInfo(const TransmissionInfo& other) = default; |
| 936 | 940 |
| 937 TransmissionInfo::~TransmissionInfo() {} | 941 TransmissionInfo::~TransmissionInfo() {} |
| 938 | 942 |
| 939 } // namespace net | 943 } // namespace net |
| OLD | NEW |