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 #ifndef NET_QUIC_CORE_QUIC_VERSIONS_H_ | 5 #ifndef NET_QUIC_CORE_QUIC_VERSIONS_H_ |
6 #define NET_QUIC_CORE_QUIC_VERSIONS_H_ | 6 #define NET_QUIC_CORE_QUIC_VERSIONS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "net/quic/core/quic_tag.h" | 11 #include "net/quic/core/quic_tag.h" |
12 #include "net/quic/core/quic_types.h" | 12 #include "net/quic/core/quic_types.h" |
| 13 #include "net/quic/platform/api/quic_export.h" |
13 | 14 |
14 namespace net { | 15 namespace net { |
15 | 16 |
16 // The available versions of QUIC. Guaranteed that the integer value of the enum | 17 // The available versions of QUIC. Guaranteed that the integer value of the enum |
17 // will match the version number. | 18 // will match the version number. |
18 // When adding a new version to this enum you should add it to | 19 // When adding a new version to this enum you should add it to |
19 // kSupportedQuicVersions (if appropriate), and also add a new case to the | 20 // kSupportedQuicVersions (if appropriate), and also add a new case to the |
20 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and | 21 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and |
21 // QuicVersionToString. | 22 // QuicVersionToString. |
22 enum QuicVersion { | 23 enum QuicVersion { |
(...skipping 15 matching lines...) Expand all Loading... |
38 // skipped as necessary). | 39 // skipped as necessary). |
39 // | 40 // |
40 // IMPORTANT: if you are adding to this list, follow the instructions at | 41 // IMPORTANT: if you are adding to this list, follow the instructions at |
41 // http://sites/quic/adding-and-removing-versions | 42 // http://sites/quic/adding-and-removing-versions |
42 static const QuicVersion kSupportedQuicVersions[] = { | 43 static const QuicVersion kSupportedQuicVersions[] = { |
43 QUIC_VERSION_36, QUIC_VERSION_35, QUIC_VERSION_34}; | 44 QUIC_VERSION_36, QUIC_VERSION_35, QUIC_VERSION_34}; |
44 | 45 |
45 typedef std::vector<QuicVersion> QuicVersionVector; | 46 typedef std::vector<QuicVersion> QuicVersionVector; |
46 | 47 |
47 // Returns a vector of QUIC versions in kSupportedQuicVersions. | 48 // Returns a vector of QUIC versions in kSupportedQuicVersions. |
48 NET_EXPORT_PRIVATE QuicVersionVector AllSupportedVersions(); | 49 QUIC_EXPORT_PRIVATE QuicVersionVector AllSupportedVersions(); |
49 | 50 |
50 // Returns a vector of QUIC versions from kSupportedQuicVersions which exclude | 51 // Returns a vector of QUIC versions from kSupportedQuicVersions which exclude |
51 // any versions which are disabled by flags. | 52 // any versions which are disabled by flags. |
52 NET_EXPORT_PRIVATE QuicVersionVector CurrentSupportedVersions(); | 53 QUIC_EXPORT_PRIVATE QuicVersionVector CurrentSupportedVersions(); |
53 | 54 |
54 // Returns a vector of QUIC versions from |versions| which exclude any versions | 55 // Returns a vector of QUIC versions from |versions| which exclude any versions |
55 // which are disabled by flags. | 56 // which are disabled by flags. |
56 NET_EXPORT_PRIVATE QuicVersionVector | 57 QUIC_EXPORT_PRIVATE QuicVersionVector |
57 FilterSupportedVersions(QuicVersionVector versions); | 58 FilterSupportedVersions(QuicVersionVector versions); |
58 | 59 |
59 // Returns QUIC version of |index| in result of |versions|. Returns | 60 // Returns QUIC version of |index| in result of |versions|. Returns |
60 // QUIC_VERSION_UNSUPPORTED if |index| is out of bounds. | 61 // QUIC_VERSION_UNSUPPORTED if |index| is out of bounds. |
61 NET_EXPORT_PRIVATE QuicVersionVector | 62 QUIC_EXPORT_PRIVATE QuicVersionVector |
62 VersionOfIndex(const QuicVersionVector& versions, int index); | 63 VersionOfIndex(const QuicVersionVector& versions, int index); |
63 | 64 |
64 // QuicTag is written to and read from the wire, but we prefer to use | 65 // QuicTag is written to and read from the wire, but we prefer to use |
65 // the more readable QuicVersion at other levels. | 66 // the more readable QuicVersion at other levels. |
66 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 | 67 // Helper function which translates from a QuicVersion to a QuicTag. Returns 0 |
67 // if QuicVersion is unsupported. | 68 // if QuicVersion is unsupported. |
68 NET_EXPORT_PRIVATE QuicTag QuicVersionToQuicTag(const QuicVersion version); | 69 QUIC_EXPORT_PRIVATE QuicTag QuicVersionToQuicTag(const QuicVersion version); |
69 | 70 |
70 // Returns appropriate QuicVersion from a QuicTag. | 71 // Returns appropriate QuicVersion from a QuicTag. |
71 // Returns QUIC_VERSION_UNSUPPORTED if version_tag cannot be understood. | 72 // Returns QUIC_VERSION_UNSUPPORTED if version_tag cannot be understood. |
72 NET_EXPORT_PRIVATE QuicVersion QuicTagToQuicVersion(const QuicTag version_tag); | 73 QUIC_EXPORT_PRIVATE QuicVersion QuicTagToQuicVersion(const QuicTag version_tag); |
73 | 74 |
74 // Helper function which translates from a QuicVersion to a string. | 75 // Helper function which translates from a QuicVersion to a string. |
75 // Returns strings corresponding to enum names (e.g. QUIC_VERSION_6). | 76 // Returns strings corresponding to enum names (e.g. QUIC_VERSION_6). |
76 NET_EXPORT_PRIVATE std::string QuicVersionToString(const QuicVersion version); | 77 QUIC_EXPORT_PRIVATE std::string QuicVersionToString(const QuicVersion version); |
77 | 78 |
78 // Returns comma separated list of string representations of QuicVersion enum | 79 // Returns comma separated list of string representations of QuicVersion enum |
79 // values in the supplied |versions| vector. | 80 // values in the supplied |versions| vector. |
80 NET_EXPORT_PRIVATE std::string QuicVersionVectorToString( | 81 QUIC_EXPORT_PRIVATE std::string QuicVersionVectorToString( |
81 const QuicVersionVector& versions); | 82 const QuicVersionVector& versions); |
82 | 83 |
83 } // namespace net | 84 } // namespace net |
84 | 85 |
85 #endif // NET_QUIC_CORE_QUIC_VERSIONS_H_ | 86 #endif // NET_QUIC_CORE_QUIC_VERSIONS_H_ |
OLD | NEW |