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 | #ifndef QUICHE_QUIC_CORE_QUIC_VERSION_MANAGER_H_ |
| 6 | #define QUICHE_QUIC_CORE_QUIC_VERSION_MANAGER_H_ |
| 7 | |
| 8 | #include "net/third_party/quiche/src/quic/core/quic_versions.h" |
| 9 | #include "net/third_party/quiche/src/quic/platform/api/quic_export.h" |
| 10 | |
| 11 | namespace quic { |
| 12 | |
| 13 | // Used to generate filtered supported versions based on flags. |
| 14 | class QUIC_EXPORT_PRIVATE QuicVersionManager { |
| 15 | public: |
| 16 | // |supported_versions| should be sorted in the order of preference (typically |
| 17 | // highest supported version to the lowest supported version). |
| 18 | explicit QuicVersionManager(ParsedQuicVersionVector supported_versions); |
| 19 | virtual ~QuicVersionManager(); |
| 20 | |
| 21 | // Returns currently supported QUIC versions. |
| 22 | // TODO(nharper): Remove this method once it is unused. |
| 23 | const QuicTransportVersionVector& GetSupportedTransportVersions(); |
| 24 | |
| 25 | // Returns currently supported QUIC versions. This vector has the same order |
| 26 | // as the versions passed to the constructor. |
| 27 | const ParsedQuicVersionVector& GetSupportedVersions(); |
| 28 | |
fayang | e452405 | 2020-04-03 09:09:20 -0700 | [diff] [blame] | 29 | // Returns currently supported versions using QUIC crypto. |
| 30 | const ParsedQuicVersionVector& GetSupportedVersionsWithQuicCrypto(); |
| 31 | |
dschinazi | 71116fd | 2020-04-22 16:07:04 -0700 | [diff] [blame] | 32 | // Returns the list of supported ALPNs, based on the current supported |
| 33 | // versions and any custom additions by subclasses. |
| 34 | const std::vector<std::string>& GetSupportedAlpns(); |
| 35 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 36 | protected: |
zhongyi | f1e3e4a | 2019-09-27 16:02:03 -0700 | [diff] [blame] | 37 | // If the value of any reloadable flag is different from the cached value, |
| 38 | // re-filter |filtered_supported_versions_| and update the cached flag values. |
| 39 | // Otherwise, does nothing. |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 40 | void MaybeRefilterSupportedVersions(); |
| 41 | |
| 42 | // Refilters filtered_supported_versions_. |
| 43 | virtual void RefilterSupportedVersions(); |
| 44 | |
rch | d17a740 | 2019-08-22 15:08:04 -0700 | [diff] [blame] | 45 | const QuicTransportVersionVector& filtered_transport_versions() const { |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 46 | return filtered_transport_versions_; |
| 47 | } |
| 48 | |
dschinazi | 71116fd | 2020-04-22 16:07:04 -0700 | [diff] [blame] | 49 | // Mechanism for subclasses to add custom ALPNs to the supported list. |
| 50 | // Should be called in constructor and RefilterSupportedVersions. |
| 51 | void AddCustomAlpn(const std::string& alpn); |
| 52 | |
fayang | 5d0d681 | 2020-08-24 18:21:21 -0700 | [diff] [blame] | 53 | bool disable_version_q050() const { return disable_version_q050_; } |
| 54 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 55 | private: |
zhongyi | f1e3e4a | 2019-09-27 16:02:03 -0700 | [diff] [blame] | 56 | // Cached value of reloadable flags. |
dschinazi | 3032641 | 2020-07-28 04:32:35 -0700 | [diff] [blame] | 57 | // quic_disable_version_draft_29 flag |
| 58 | bool disable_version_draft_29_; |
dschinazi | 531bdc9 | 2020-06-16 06:20:10 -0700 | [diff] [blame] | 59 | // quic_disable_version_draft_27 flag |
| 60 | bool disable_version_draft_27_; |
dschinazi | e2896c8 | 2020-09-14 11:04:13 -0700 | [diff] [blame] | 61 | // quic_disable_version_t051 flag |
| 62 | bool disable_version_t051_; |
dschinazi | b41e609 | 2020-06-01 16:13:14 -0700 | [diff] [blame] | 63 | // quic_disable_version_t050 flag |
| 64 | bool disable_version_t050_; |
dschinazi | 4769220 | 2020-07-30 11:09:42 -0700 | [diff] [blame] | 65 | // quic_disable_version_q050 flag |
| 66 | bool disable_version_q050_; |
dschinazi | 76881f0 | 2019-12-09 14:56:14 -0800 | [diff] [blame] | 67 | // quic_disable_version_q046 flag |
| 68 | bool disable_version_q046_; |
| 69 | // quic_disable_version_q043 flag |
| 70 | bool disable_version_q043_; |
zhongyi | f1e3e4a | 2019-09-27 16:02:03 -0700 | [diff] [blame] | 71 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 72 | // The list of versions that may be supported. |
| 73 | ParsedQuicVersionVector allowed_supported_versions_; |
| 74 | // This vector contains QUIC versions which are currently supported based on |
| 75 | // flags. |
| 76 | ParsedQuicVersionVector filtered_supported_versions_; |
fayang | e452405 | 2020-04-03 09:09:20 -0700 | [diff] [blame] | 77 | // Currently supported versions using QUIC crypto. |
| 78 | ParsedQuicVersionVector filtered_supported_versions_with_quic_crypto_; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 79 | // This vector contains the transport versions from |
| 80 | // |filtered_supported_versions_|. No guarantees are made that the same |
| 81 | // transport version isn't repeated. |
| 82 | QuicTransportVersionVector filtered_transport_versions_; |
dschinazi | 71116fd | 2020-04-22 16:07:04 -0700 | [diff] [blame] | 83 | // Contains the list of ALPNs corresponding to filtered_supported_versions_ |
| 84 | // with custom ALPNs added. |
| 85 | std::vector<std::string> filtered_supported_alpns_; |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | } // namespace quic |
| 89 | |
| 90 | #endif // QUICHE_QUIC_CORE_QUIC_VERSION_MANAGER_H_ |