blob: 0851464b857a16b8b3fa799cc84eba49952e77cc [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
29 protected:
zhongyif1e3e4a2019-09-27 16:02:03 -070030 // If the value of any reloadable flag is different from the cached value,
31 // re-filter |filtered_supported_versions_| and update the cached flag values.
32 // Otherwise, does nothing.
QUICHE teama6ef0a62019-03-07 20:34:33 -050033 void MaybeRefilterSupportedVersions();
34
35 // Refilters filtered_supported_versions_.
36 virtual void RefilterSupportedVersions();
37
rchd17a7402019-08-22 15:08:04 -070038 const QuicTransportVersionVector& filtered_transport_versions() const {
QUICHE teama6ef0a62019-03-07 20:34:33 -050039 return filtered_transport_versions_;
40 }
41
42 private:
zhongyif1e3e4a2019-09-27 16:02:03 -070043 // Cached value of reloadable flags.
QUICHE teama6ef0a62019-03-07 20:34:33 -050044 // quic_enable_version_99 flag
45 bool enable_version_99_;
nharperc32d8ab2019-10-09 11:09:06 -070046 // quic_enable_version_50 flag
47 bool enable_version_50_;
nharperf5e68452019-05-29 17:24:18 -070048 // quic_supports_tls_handshake flag
49 bool enable_tls_;
zhongyif1e3e4a2019-09-27 16:02:03 -070050
QUICHE teama6ef0a62019-03-07 20:34:33 -050051 // The list of versions that may be supported.
52 ParsedQuicVersionVector allowed_supported_versions_;
53 // This vector contains QUIC versions which are currently supported based on
54 // flags.
55 ParsedQuicVersionVector filtered_supported_versions_;
56 // This vector contains the transport versions from
57 // |filtered_supported_versions_|. No guarantees are made that the same
58 // transport version isn't repeated.
59 QuicTransportVersionVector filtered_transport_versions_;
60};
61
62} // namespace quic
63
64#endif // QUICHE_QUIC_CORE_QUIC_VERSION_MANAGER_H_