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

Unified Diff: net/quic/quic_framer.cc

Issue 1009543004: Create a Perspective enum to use instead of a bool is_server to improve (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NET_EXPORT_PRIVATE to fix compiler error Created 5 years, 9 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
« no previous file with comments | « net/quic/quic_framer.h ('k') | net/quic/quic_framer_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_framer.cc
diff --git a/net/quic/quic_framer.cc b/net/quic/quic_framer.cc
index 4d387cf4183d87a178512ff460dd45bd291cd15d..7d6ecc250acc13dd71ba1938efe29e4c5079988f 100644
--- a/net/quic/quic_framer.cc
+++ b/net/quic/quic_framer.cc
@@ -142,7 +142,7 @@ bool QuicFramerVisitorInterface::OnBlockedFrame(const QuicBlockedFrame& frame) {
QuicFramer::QuicFramer(const QuicVersionVector& supported_versions,
QuicTime creation_time,
- bool is_server)
+ Perspective perspective)
: visitor_(nullptr),
fec_builder_(nullptr),
entropy_calculator_(nullptr),
@@ -153,7 +153,7 @@ QuicFramer::QuicFramer(const QuicVersionVector& supported_versions,
decrypter_level_(ENCRYPTION_NONE),
alternative_decrypter_level_(ENCRYPTION_NONE),
alternative_decrypter_latch_(false),
- is_server_(is_server),
+ perspective_(perspective),
validate_flags_(true),
creation_time_(creation_time),
last_timestamp_(QuicTime::Delta::Zero()) {
@@ -531,7 +531,7 @@ bool QuicFramer::ProcessPacket(const QuicEncryptedPacket& packet) {
return true;
}
- if (is_server_ && public_header.version_flag &&
+ if (perspective_ == Perspective::IS_SERVER && public_header.version_flag &&
public_header.versions[0] != quic_version_) {
if (!visitor_->OnProtocolVersionMismatch(public_header.versions[0])) {
reader_.reset(nullptr);
@@ -540,7 +540,7 @@ bool QuicFramer::ProcessPacket(const QuicEncryptedPacket& packet) {
}
bool rv;
- if (!is_server_ && public_header.version_flag) {
+ if (perspective_ == Perspective::IS_CLIENT && public_header.version_flag) {
rv = ProcessVersionNegotiationPacket(&public_header);
} else if (public_header.reset_flag) {
rv = ProcessPublicResetPacket(public_header);
@@ -562,7 +562,7 @@ bool QuicFramer::ProcessPacket(const QuicEncryptedPacket& packet) {
bool QuicFramer::ProcessVersionNegotiationPacket(
QuicPacketPublicHeader* public_header) {
- DCHECK(!is_server_);
+ DCHECK_EQ(Perspective::IS_CLIENT, perspective_);
// Try reading at least once to raise error if the packet is invalid.
do {
QuicTag version;
@@ -744,7 +744,7 @@ bool QuicFramer::AppendPacketHeader(const QuicPacketHeader& header,
last_serialized_connection_id_ = header.public_header.connection_id;
if (header.public_header.version_flag) {
- DCHECK(!is_server_);
+ DCHECK_EQ(Perspective::IS_CLIENT, perspective_);
writer->WriteUInt32(QuicVersionToQuicTag(quic_version_));
}
@@ -910,7 +910,7 @@ bool QuicFramer::ProcessPublicHeader(
// Read the version only if the packet is from the client.
// version flag from the server means version negotiation packet.
- if (public_header->version_flag && is_server_) {
+ if (public_header->version_flag && perspective_ == Perspective::IS_SERVER) {
QuicTag version_tag;
if (!reader_->ReadUInt32(&version_tag)) {
set_detailed_error("Unable to read protocol version.");
« no previous file with comments | « net/quic/quic_framer.h ('k') | net/quic/quic_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698