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

Unified Diff: net/quic/quic_flow_controller.cc

Issue 312553003: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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_flow_controller.h ('k') | net/quic/quic_flow_controller_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_flow_controller.cc
diff --git a/net/quic/quic_flow_controller.cc b/net/quic/quic_flow_controller.cc
index 412f250b8e56aa7ba8135e777e004163e42f259f..a469fd53fd69f4d405a2505843d55a5ac9f29078 100644
--- a/net/quic/quic_flow_controller.cc
+++ b/net/quic/quic_flow_controller.cc
@@ -23,7 +23,7 @@ QuicFlowController::QuicFlowController(QuicVersion version,
is_enabled_(true),
is_server_(is_server),
bytes_consumed_(0),
- bytes_buffered_(0),
+ highest_received_byte_offset_(0),
bytes_sent_(0),
send_window_offset_(send_window_offset),
receive_window_offset_(receive_window_offset),
@@ -51,29 +51,21 @@ void QuicFlowController::AddBytesConsumed(uint64 bytes_consumed) {
DVLOG(1) << ENDPOINT << "Stream " << id_ << " consumed: " << bytes_consumed_;
}
-void QuicFlowController::AddBytesBuffered(uint64 bytes_buffered) {
+bool QuicFlowController::UpdateHighestReceivedOffset(uint64 new_offset) {
if (!IsEnabled()) {
- return;
- }
-
- bytes_buffered_ += bytes_buffered;
- DVLOG(1) << ENDPOINT << "Stream " << id_ << " buffered: " << bytes_buffered_;
-}
-
-void QuicFlowController::RemoveBytesBuffered(uint64 bytes_buffered) {
- if (!IsEnabled()) {
- return;
+ return false;
}
- if (bytes_buffered_ < bytes_buffered) {
- LOG(DFATAL) << "Trying to remove " << bytes_buffered << " bytes, when only "
- << bytes_buffered_ << " bytes are buffered";
- bytes_buffered_ = 0;
- return;
+ // Only update if offset has increased.
+ if (new_offset <= highest_received_byte_offset_) {
+ return false;
}
- bytes_buffered_ -= bytes_buffered;
- DVLOG(1) << ENDPOINT << "Stream " << id_ << " buffered: " << bytes_buffered_;
+ DVLOG(1) << ENDPOINT << "Stream " << id_
+ << " highest byte offset increased from: "
+ << highest_received_byte_offset_ << " to " << new_offset;
+ highest_received_byte_offset_ = new_offset;
+ return true;
}
void QuicFlowController::AddBytesSent(uint64 bytes_sent) {
@@ -98,12 +90,12 @@ bool QuicFlowController::FlowControlViolation() {
return false;
}
- if (receive_window_offset_ < TotalReceivedBytes()) {
- LOG(ERROR)
- << ENDPOINT << "Flow control violation on stream " << id_
- << ", receive window: " << receive_window_offset_
- << ", bytes received: " << TotalReceivedBytes();
-
+ if (highest_received_byte_offset_ > receive_window_offset_) {
+ LOG(ERROR) << ENDPOINT << "Flow control violation on stream "
+ << id_ << ", receive window offset: "
+ << receive_window_offset_
+ << ", highest received byte offset: "
+ << highest_received_byte_offset_;
return true;
}
return false;
@@ -201,8 +193,4 @@ uint64 QuicFlowController::SendWindowSize() const {
return send_window_offset_ - bytes_sent_;
}
-uint64 QuicFlowController::TotalReceivedBytes() const {
- return bytes_consumed_ + bytes_buffered_;
-}
-
} // namespace net
« no previous file with comments | « net/quic/quic_flow_controller.h ('k') | net/quic/quic_flow_controller_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698