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

Unified Diff: net/quic/core/quic_protocol.cc

Issue 2507953002: Move definitions and methods related to QUIC versions, into quic_versions.{h,cc}. No behavior chang… (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/core/quic_protocol.h ('k') | net/quic/core/quic_versions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/quic_protocol.cc
diff --git a/net/quic/core/quic_protocol.cc b/net/quic/core/quic_protocol.cc
index 690e5a2c7c277fb7b6bafa5acd6d6c8f4e0a6189..d9ca3eba0031a20254b23c15bce961a98b8d29be 100644
--- a/net/quic/core/quic_protocol.cc
+++ b/net/quic/core/quic_protocol.cc
@@ -8,6 +8,7 @@
#include "base/strings/string_number_conversions.h"
#include "net/quic/core/quic_flags.h"
#include "net/quic/core/quic_utils.h"
+#include "net/quic/core/quic_versions.h"
using base::StringPiece;
using std::map;
@@ -169,111 +170,6 @@ bool ContainsQuicTag(const QuicTagVector& tag_vector, QuicTag tag) {
tag_vector.end();
}
-QuicVersionVector AllSupportedVersions() {
- QuicVersionVector supported_versions;
- for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) {
- supported_versions.push_back(kSupportedQuicVersions[i]);
- }
- return supported_versions;
-}
-
-QuicVersionVector CurrentSupportedVersions() {
- return FilterSupportedVersions(AllSupportedVersions());
-}
-
-QuicVersionVector FilterSupportedVersions(QuicVersionVector versions) {
- QuicVersionVector filtered_versions(versions.size());
- filtered_versions.clear(); // Guaranteed by spec not to change capacity.
- for (QuicVersion version : versions) {
- if (version < QUIC_VERSION_34) {
- if (!FLAGS_quic_disable_pre_34) {
- filtered_versions.push_back(version);
- }
- } else if (version == QUIC_VERSION_35) {
- if (FLAGS_quic_enable_version_35) {
- filtered_versions.push_back(version);
- }
- } else if (version == QUIC_VERSION_36) {
- if (FLAGS_quic_enable_version_35 && FLAGS_quic_enable_version_36_v2) {
- filtered_versions.push_back(version);
- }
- } else {
- filtered_versions.push_back(version);
- }
- }
- return filtered_versions;
-}
-
-QuicVersionVector VersionOfIndex(const QuicVersionVector& versions, int index) {
- QuicVersionVector version;
- int version_count = versions.size();
- if (index >= 0 && index < version_count) {
- version.push_back(versions[index]);
- } else {
- version.push_back(QUIC_VERSION_UNSUPPORTED);
- }
- return version;
-}
-
-QuicTag QuicVersionToQuicTag(const QuicVersion version) {
- switch (version) {
- case QUIC_VERSION_32:
- return MakeQuicTag('Q', '0', '3', '2');
- case QUIC_VERSION_33:
- return MakeQuicTag('Q', '0', '3', '3');
- case QUIC_VERSION_34:
- return MakeQuicTag('Q', '0', '3', '4');
- case QUIC_VERSION_35:
- return MakeQuicTag('Q', '0', '3', '5');
- case QUIC_VERSION_36:
- return MakeQuicTag('Q', '0', '3', '6');
- default:
- // This shold be an ERROR because we should never attempt to convert an
- // invalid QuicVersion to be written to the wire.
- LOG(ERROR) << "Unsupported QuicVersion: " << version;
- return 0;
- }
-}
-
-QuicVersion QuicTagToQuicVersion(const QuicTag version_tag) {
- for (size_t i = 0; i < arraysize(kSupportedQuicVersions); ++i) {
- if (version_tag == QuicVersionToQuicTag(kSupportedQuicVersions[i])) {
- return kSupportedQuicVersions[i];
- }
- }
- // Reading from the client so this should not be considered an ERROR.
- DVLOG(1) << "Unsupported QuicTag version: "
- << QuicUtils::TagToString(version_tag);
- return QUIC_VERSION_UNSUPPORTED;
-}
-
-#define RETURN_STRING_LITERAL(x) \
- case x: \
- return #x
-
-string QuicVersionToString(const QuicVersion version) {
- switch (version) {
- RETURN_STRING_LITERAL(QUIC_VERSION_32);
- RETURN_STRING_LITERAL(QUIC_VERSION_33);
- RETURN_STRING_LITERAL(QUIC_VERSION_34);
- RETURN_STRING_LITERAL(QUIC_VERSION_35);
- RETURN_STRING_LITERAL(QUIC_VERSION_36);
- default:
- return "QUIC_VERSION_UNSUPPORTED";
- }
-}
-
-string QuicVersionVectorToString(const QuicVersionVector& versions) {
- string result = "";
- for (size_t i = 0; i < versions.size(); ++i) {
- if (i != 0) {
- result.append(",");
- }
- result.append(QuicVersionToString(versions[i]));
- }
- return result;
-}
-
ostream& operator<<(ostream& os, const Perspective& s) {
if (s == Perspective::IS_SERVER) {
os << "IS_SERVER";
« no previous file with comments | « net/quic/core/quic_protocol.h ('k') | net/quic/core/quic_versions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698