QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 1 | // Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "net/third_party/quiche/src/quic/core/quic_version_manager.h" |
| 6 | |
bnc | 4e9283d | 2019-12-17 07:08:57 -0800 | [diff] [blame] | 7 | #include <algorithm> |
| 8 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 9 | #include "net/third_party/quiche/src/quic/core/quic_versions.h" |
| 10 | #include "net/third_party/quiche/src/quic/platform/api/quic_flag_utils.h" |
| 11 | #include "net/third_party/quiche/src/quic/platform/api/quic_flags.h" |
bnc | 4e9283d | 2019-12-17 07:08:57 -0800 | [diff] [blame] | 12 | #include "net/third_party/quiche/src/common/platform/api/quiche_arraysize.h" |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 13 | |
| 14 | namespace quic { |
| 15 | |
| 16 | QuicVersionManager::QuicVersionManager( |
| 17 | ParsedQuicVersionVector supported_versions) |
dschinazi | 76881f0 | 2019-12-09 14:56:14 -0800 | [diff] [blame] | 18 | : enable_version_q099_(GetQuicReloadableFlag(quic_enable_version_q099)), |
| 19 | enable_version_t099_(GetQuicReloadableFlag(quic_enable_version_t099)), |
| 20 | disable_version_q050_(GetQuicReloadableFlag(quic_disable_version_q050)), |
| 21 | enable_version_t050_(GetQuicReloadableFlag(quic_enable_version_t050)), |
| 22 | disable_version_q049_(GetQuicReloadableFlag(quic_disable_version_q049)), |
| 23 | disable_version_q048_(GetQuicReloadableFlag(quic_disable_version_q048)), |
| 24 | disable_version_q046_(GetQuicReloadableFlag(quic_disable_version_q046)), |
| 25 | disable_version_q043_(GetQuicReloadableFlag(quic_disable_version_q043)), |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 26 | allowed_supported_versions_(std::move(supported_versions)) { |
bnc | 4e9283d | 2019-12-17 07:08:57 -0800 | [diff] [blame] | 27 | static_assert(QUICHE_ARRAYSIZE(kSupportedTransportVersions) == 6u, |
dschinazi | c73506e | 2019-09-20 13:26:46 -0700 | [diff] [blame] | 28 | "Supported versions out of sync"); |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 29 | RefilterSupportedVersions(); |
| 30 | } |
| 31 | |
| 32 | QuicVersionManager::~QuicVersionManager() {} |
| 33 | |
| 34 | const QuicTransportVersionVector& |
| 35 | QuicVersionManager::GetSupportedTransportVersions() { |
| 36 | MaybeRefilterSupportedVersions(); |
| 37 | return filtered_transport_versions_; |
| 38 | } |
| 39 | |
| 40 | const ParsedQuicVersionVector& QuicVersionManager::GetSupportedVersions() { |
| 41 | MaybeRefilterSupportedVersions(); |
| 42 | return filtered_supported_versions_; |
| 43 | } |
| 44 | |
| 45 | void QuicVersionManager::MaybeRefilterSupportedVersions() { |
bnc | 4e9283d | 2019-12-17 07:08:57 -0800 | [diff] [blame] | 46 | static_assert(QUICHE_ARRAYSIZE(kSupportedTransportVersions) == 6u, |
dschinazi | c73506e | 2019-09-20 13:26:46 -0700 | [diff] [blame] | 47 | "Supported versions out of sync"); |
dschinazi | 76881f0 | 2019-12-09 14:56:14 -0800 | [diff] [blame] | 48 | if (enable_version_q099_ != GetQuicReloadableFlag(quic_enable_version_q099) || |
| 49 | enable_version_t099_ != GetQuicReloadableFlag(quic_enable_version_t099) || |
| 50 | disable_version_q050_ != |
| 51 | GetQuicReloadableFlag(quic_disable_version_q050) || |
| 52 | enable_version_t050_ != GetQuicReloadableFlag(quic_enable_version_t050) || |
| 53 | disable_version_q049_ != |
| 54 | GetQuicReloadableFlag(quic_disable_version_q049) || |
| 55 | disable_version_q048_ != |
| 56 | GetQuicReloadableFlag(quic_disable_version_q048) || |
| 57 | disable_version_q046_ != |
| 58 | GetQuicReloadableFlag(quic_disable_version_q046) || |
| 59 | disable_version_q043_ != |
| 60 | GetQuicReloadableFlag(quic_disable_version_q043)) { |
| 61 | enable_version_q099_ = GetQuicReloadableFlag(quic_enable_version_q099); |
| 62 | enable_version_t099_ = GetQuicReloadableFlag(quic_enable_version_t099); |
| 63 | disable_version_q050_ = GetQuicReloadableFlag(quic_disable_version_q050); |
| 64 | enable_version_t050_ = GetQuicReloadableFlag(quic_enable_version_t050); |
| 65 | disable_version_q049_ = GetQuicReloadableFlag(quic_disable_version_q049); |
| 66 | disable_version_q048_ = GetQuicReloadableFlag(quic_disable_version_q048); |
| 67 | disable_version_q046_ = GetQuicReloadableFlag(quic_disable_version_q046); |
| 68 | disable_version_q043_ = GetQuicReloadableFlag(quic_disable_version_q043); |
| 69 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 70 | RefilterSupportedVersions(); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | void QuicVersionManager::RefilterSupportedVersions() { |
| 75 | filtered_supported_versions_ = |
| 76 | FilterSupportedVersions(allowed_supported_versions_); |
| 77 | filtered_transport_versions_.clear(); |
| 78 | for (ParsedQuicVersion version : filtered_supported_versions_) { |
| 79 | auto transport_version = version.transport_version; |
| 80 | if (std::find(filtered_transport_versions_.begin(), |
| 81 | filtered_transport_versions_.end(), |
| 82 | transport_version) == filtered_transport_versions_.end()) { |
| 83 | filtered_transport_versions_.push_back(transport_version); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | } // namespace quic |