blob: 9c742f5eece71302bc7ef484bfbe08e219f0f4c9 [file] [log] [blame]
QUICHE teama6ef0a62019-03-07 20:34:33 -05001// 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
11namespace quic {
12
13// Used to generate filtered supported versions based on flags.
14class 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
fayange4524052020-04-03 09:09:20 -070029 // Returns currently supported versions using QUIC crypto.
30 const ParsedQuicVersionVector& GetSupportedVersionsWithQuicCrypto();
31
dschinazi71116fd2020-04-22 16:07:04 -070032 // 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 teama6ef0a62019-03-07 20:34:33 -050036 protected:
zhongyif1e3e4a2019-09-27 16:02:03 -070037 // 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 teama6ef0a62019-03-07 20:34:33 -050040 void MaybeRefilterSupportedVersions();
41
42 // Refilters filtered_supported_versions_.
43 virtual void RefilterSupportedVersions();
44
rchd17a7402019-08-22 15:08:04 -070045 const QuicTransportVersionVector& filtered_transport_versions() const {
QUICHE teama6ef0a62019-03-07 20:34:33 -050046 return filtered_transport_versions_;
47 }
48
dschinazi71116fd2020-04-22 16:07:04 -070049 // 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
fayang5d0d6812020-08-24 18:21:21 -070053 bool disable_version_q050() const { return disable_version_q050_; }
54
QUICHE teama6ef0a62019-03-07 20:34:33 -050055 private:
zhongyif1e3e4a2019-09-27 16:02:03 -070056 // Cached value of reloadable flags.
dschinazi30326412020-07-28 04:32:35 -070057 // quic_disable_version_draft_29 flag
58 bool disable_version_draft_29_;
dschinazi531bdc92020-06-16 06:20:10 -070059 // quic_disable_version_draft_27 flag
60 bool disable_version_draft_27_;
dschinazie2896c82020-09-14 11:04:13 -070061 // quic_disable_version_t051 flag
62 bool disable_version_t051_;
dschinazib41e6092020-06-01 16:13:14 -070063 // quic_disable_version_t050 flag
64 bool disable_version_t050_;
dschinazi47692202020-07-30 11:09:42 -070065 // quic_disable_version_q050 flag
66 bool disable_version_q050_;
dschinazi76881f02019-12-09 14:56:14 -080067 // quic_disable_version_q046 flag
68 bool disable_version_q046_;
69 // quic_disable_version_q043 flag
70 bool disable_version_q043_;
zhongyif1e3e4a2019-09-27 16:02:03 -070071
QUICHE teama6ef0a62019-03-07 20:34:33 -050072 // 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_;
fayange4524052020-04-03 09:09:20 -070077 // Currently supported versions using QUIC crypto.
78 ParsedQuicVersionVector filtered_supported_versions_with_quic_crypto_;
QUICHE teama6ef0a62019-03-07 20:34:33 -050079 // 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_;
dschinazi71116fd2020-04-22 16:07:04 -070083 // Contains the list of ALPNs corresponding to filtered_supported_versions_
84 // with custom ALPNs added.
85 std::vector<std::string> filtered_supported_alpns_;
QUICHE teama6ef0a62019-03-07 20:34:33 -050086};
87
88} // namespace quic
89
90#endif // QUICHE_QUIC_CORE_QUIC_VERSION_MANAGER_H_