Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(762)

Side by Side Diff: net/quic/core/quic_versions.cc

Issue 2825083003: Landing Recent QUIC changes until Mon Apr 17 2017 (Closed)
Patch Set: Format Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/core/quic_versions.h ('k') | net/quic/core/quic_versions_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "net/quic/core/quic_versions.h" 5 #include "net/quic/core/quic_versions.h"
6 6
7 #include "net/quic/core/quic_error_codes.h" 7 #include "net/quic/core/quic_error_codes.h"
8 #include "net/quic/core/quic_flags.h"
9 #include "net/quic/core/quic_tag.h" 8 #include "net/quic/core/quic_tag.h"
10 #include "net/quic/core/quic_types.h" 9 #include "net/quic/core/quic_types.h"
10 #include "net/quic/platform/api/quic_flags.h"
11 #include "net/quic/platform/api/quic_logging.h" 11 #include "net/quic/platform/api/quic_logging.h"
12 12
13 using std::string; 13 using std::string;
14 14
15 namespace net { 15 namespace net {
16 16
17 QuicVersionVector AllSupportedVersions() { 17 QuicVersionVector AllSupportedVersions() {
18 QuicVersionVector supported_versions; 18 QuicVersionVector supported_versions;
19 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) { 19 for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) {
20 supported_versions.push_back(kSupportedQuicVersions[i]); 20 supported_versions.push_back(kSupportedQuicVersions[i]);
21 } 21 }
22 return supported_versions; 22 return supported_versions;
23 } 23 }
24 24
25 QuicVersionVector CurrentSupportedVersions() { 25 QuicVersionVector CurrentSupportedVersions() {
26 return FilterSupportedVersions(AllSupportedVersions()); 26 return FilterSupportedVersions(AllSupportedVersions());
27 } 27 }
28 28
29 QuicVersionVector FilterSupportedVersions(QuicVersionVector versions) { 29 QuicVersionVector FilterSupportedVersions(QuicVersionVector versions) {
30 QuicVersionVector filtered_versions(versions.size()); 30 QuicVersionVector filtered_versions(versions.size());
31 filtered_versions.clear(); // Guaranteed by spec not to change capacity. 31 filtered_versions.clear(); // Guaranteed by spec not to change capacity.
32 for (QuicVersion version : versions) { 32 for (QuicVersion version : versions) {
33 if (version == QUIC_VERSION_39) { 33 if (version == QUIC_VERSION_39) {
34 if (base::GetFlag(FLAGS_quic_enable_version_39) && 34 if (GetQuicFlag(FLAGS_quic_enable_version_39) &&
35 FLAGS_quic_reloadable_flag_quic_enable_version_38 && 35 FLAGS_quic_reloadable_flag_quic_enable_version_38) {
36 FLAGS_quic_reloadable_flag_quic_enable_version_37 &&
37 FLAGS_quic_reloadable_flag_quic_enable_version_36_v3) {
38 filtered_versions.push_back(version); 36 filtered_versions.push_back(version);
39 } 37 }
40 } else if (version == QUIC_VERSION_38) { 38 } else if (version == QUIC_VERSION_38) {
41 if (FLAGS_quic_reloadable_flag_quic_enable_version_38 && 39 if (FLAGS_quic_reloadable_flag_quic_enable_version_38) {
42 FLAGS_quic_reloadable_flag_quic_enable_version_37 &&
43 FLAGS_quic_reloadable_flag_quic_enable_version_36_v3) {
44 filtered_versions.push_back(version);
45 }
46 } else if (version == QUIC_VERSION_37) {
47 if (FLAGS_quic_reloadable_flag_quic_enable_version_37 &&
48 FLAGS_quic_reloadable_flag_quic_enable_version_36_v3) {
49 filtered_versions.push_back(version);
50 }
51 } else if (version == QUIC_VERSION_36) {
52 if (FLAGS_quic_reloadable_flag_quic_enable_version_36_v3) {
53 filtered_versions.push_back(version);
54 }
55 } else if (version == QUIC_VERSION_34) {
56 if (!FLAGS_quic_reloadable_flag_quic_disable_version_34) {
57 filtered_versions.push_back(version); 40 filtered_versions.push_back(version);
58 } 41 }
59 } else { 42 } else {
60 filtered_versions.push_back(version); 43 filtered_versions.push_back(version);
61 } 44 }
62 } 45 }
63 return filtered_versions; 46 return filtered_versions;
64 } 47 }
65 48
66 QuicVersionVector VersionOfIndex(const QuicVersionVector& versions, int index) { 49 QuicVersionVector VersionOfIndex(const QuicVersionVector& versions, int index) {
67 QuicVersionVector version; 50 QuicVersionVector version;
68 int version_count = versions.size(); 51 int version_count = versions.size();
69 if (index >= 0 && index < version_count) { 52 if (index >= 0 && index < version_count) {
70 version.push_back(versions[index]); 53 version.push_back(versions[index]);
71 } else { 54 } else {
72 version.push_back(QUIC_VERSION_UNSUPPORTED); 55 version.push_back(QUIC_VERSION_UNSUPPORTED);
73 } 56 }
74 return version; 57 return version;
75 } 58 }
76 59
77 QuicTag QuicVersionToQuicTag(const QuicVersion version) { 60 QuicTag QuicVersionToQuicTag(const QuicVersion version) {
78 switch (version) { 61 switch (version) {
79 case QUIC_VERSION_34:
80 return MakeQuicTag('Q', '0', '3', '4');
81 case QUIC_VERSION_35: 62 case QUIC_VERSION_35:
82 return MakeQuicTag('Q', '0', '3', '5'); 63 return MakeQuicTag('Q', '0', '3', '5');
83 case QUIC_VERSION_36: 64 case QUIC_VERSION_36:
84 return MakeQuicTag('Q', '0', '3', '6'); 65 return MakeQuicTag('Q', '0', '3', '6');
85 case QUIC_VERSION_37: 66 case QUIC_VERSION_37:
86 return MakeQuicTag('Q', '0', '3', '7'); 67 return MakeQuicTag('Q', '0', '3', '7');
87 case QUIC_VERSION_38: 68 case QUIC_VERSION_38:
88 return MakeQuicTag('Q', '0', '3', '8'); 69 return MakeQuicTag('Q', '0', '3', '8');
89 case QUIC_VERSION_39: 70 case QUIC_VERSION_39:
90 return MakeQuicTag('Q', '0', '3', '9'); 71 return MakeQuicTag('Q', '0', '3', '9');
(...skipping 16 matching lines...) Expand all
107 << QuicTagToString(version_tag); 88 << QuicTagToString(version_tag);
108 return QUIC_VERSION_UNSUPPORTED; 89 return QUIC_VERSION_UNSUPPORTED;
109 } 90 }
110 91
111 #define RETURN_STRING_LITERAL(x) \ 92 #define RETURN_STRING_LITERAL(x) \
112 case x: \ 93 case x: \
113 return #x 94 return #x
114 95
115 string QuicVersionToString(const QuicVersion version) { 96 string QuicVersionToString(const QuicVersion version) {
116 switch (version) { 97 switch (version) {
117 RETURN_STRING_LITERAL(QUIC_VERSION_34);
118 RETURN_STRING_LITERAL(QUIC_VERSION_35); 98 RETURN_STRING_LITERAL(QUIC_VERSION_35);
119 RETURN_STRING_LITERAL(QUIC_VERSION_36); 99 RETURN_STRING_LITERAL(QUIC_VERSION_36);
120 RETURN_STRING_LITERAL(QUIC_VERSION_37); 100 RETURN_STRING_LITERAL(QUIC_VERSION_37);
121 RETURN_STRING_LITERAL(QUIC_VERSION_38); 101 RETURN_STRING_LITERAL(QUIC_VERSION_38);
122 RETURN_STRING_LITERAL(QUIC_VERSION_39); 102 RETURN_STRING_LITERAL(QUIC_VERSION_39);
123 default: 103 default:
124 return "QUIC_VERSION_UNSUPPORTED"; 104 return "QUIC_VERSION_UNSUPPORTED";
125 } 105 }
126 } 106 }
127 107
128 string QuicVersionVectorToString(const QuicVersionVector& versions) { 108 string QuicVersionVectorToString(const QuicVersionVector& versions) {
129 string result = ""; 109 string result = "";
130 for (size_t i = 0; i < versions.size(); ++i) { 110 for (size_t i = 0; i < versions.size(); ++i) {
131 if (i != 0) { 111 if (i != 0) {
132 result.append(","); 112 result.append(",");
133 } 113 }
134 result.append(QuicVersionToString(versions[i])); 114 result.append(QuicVersionToString(versions[i]));
135 } 115 }
136 return result; 116 return result;
137 } 117 }
138 118
139 } // namespace net 119 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_versions.h ('k') | net/quic/core/quic_versions_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698