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

Unified Diff: net/quic/quic_framer.cc

Issue 19858003: * Removed QuicTag kQuicVersion1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compiler errors Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: net/quic/quic_framer.cc
diff --git a/net/quic/quic_framer.cc b/net/quic/quic_framer.cc
index 1df3590585027850c8652c008a43bc09dcaba7f1..e1bf71a99960a5cd758c3f3afc05fb27611cc327 100644
--- a/net/quic/quic_framer.cc
+++ b/net/quic/quic_framer.cc
@@ -53,7 +53,7 @@ QuicPacketSequenceNumber ClosestTo(QuicPacketSequenceNumber target,
} // namespace
-QuicFramer::QuicFramer(QuicTag version,
+QuicFramer::QuicFramer(QuicVersion version,
QuicTime creation_time,
bool is_server)
: visitor_(NULL),
@@ -142,8 +142,13 @@ size_t QuicFramer::GetStreamOffsetSize(QuicStreamOffset offset) {
return 8;
}
-bool QuicFramer::IsSupportedVersion(QuicTag version) {
- return version == kQuicVersion1;
+bool QuicFramer::IsSupportedVersion(const QuicVersion version) const {
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kSupportedQuicVersions); ++i) {
Ryan Hamilton 2013/07/23 03:40:18 ARRAYSIZE_UNSAFE() vs arraysize()?
ramant (doing other things) 2013/07/23 05:05:22 Used arraysize() everywhere. Done.
+ if (version == kSupportedQuicVersions[i]) {
+ return true;
+ }
+ }
+ return false;
}
size_t QuicFramer::GetVersionNegotiationPacketSize(size_t number_versions) {
@@ -342,7 +347,7 @@ QuicEncryptedPacket* QuicFramer::ConstructPublicResetPacket(
QuicEncryptedPacket* QuicFramer::ConstructVersionNegotiationPacket(
const QuicPacketPublicHeader& header,
- const QuicTagVector& supported_versions) {
+ const QuicVersionVector& supported_versions) {
DCHECK(header.version_flag);
size_t len = GetVersionNegotiationPacketSize(supported_versions.size());
QuicDataWriter writer(len);
@@ -359,7 +364,7 @@ QuicEncryptedPacket* QuicFramer::ConstructVersionNegotiationPacket(
}
for (size_t i = 0; i < supported_versions.size(); ++i) {
- if (!writer.WriteUInt32(supported_versions[i])) {
+ if (!writer.WriteUInt32(QuicVersionToQuicTag(supported_versions[i]))) {
return NULL;
}
}
@@ -413,7 +418,7 @@ bool QuicFramer::ProcessVersionNegotiationPacket(
set_detailed_error("Unable to read supported version in negotiation.");
return RaiseError(QUIC_INVALID_VERSION_NEGOTIATION_PACKET);
}
- public_header->versions.push_back(version);
+ public_header->versions.push_back(QuicTagToQuicVersion(version));
} while (!reader_->IsDoneReading());
visitor_->OnVersionNegotiationPacket(*public_header);
@@ -568,7 +573,7 @@ bool QuicFramer::WritePacketHeader(const QuicPacketHeader& header,
if (header.public_header.version_flag) {
DCHECK(!is_server_);
- writer->WriteUInt32(quic_version_);
+ writer->WriteUInt32(QuicVersionToQuicTag(quic_version_));
}
if (!AppendPacketSequenceNumber(header.public_header.sequence_number_length,
@@ -713,13 +718,14 @@ bool QuicFramer::ProcessPublicHeader(
}
if (public_header->version_flag && is_server_) {
- QuicTag version;
- if (!reader_->ReadUInt32(&version)) {
+ QuicTag version_tag;
+ if (!reader_->ReadUInt32(&version_tag)) {
// Read the version only if the packet is from the client.
// version flag from the server means version negotiation packet.
set_detailed_error("Unable to read protocol version.");
return false;
}
+ QuicVersion version = QuicTagToQuicVersion(version_tag);
if (version == quic_version_ && public_flags > PACKET_PUBLIC_FLAGS_MAX) {
set_detailed_error("Illegal public flags value.");
return false;

Powered by Google App Engine
This is Rietveld 408576698