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

Side by Side Diff: net/quic/reliable_quic_stream.cc

Issue 305033011: QUIC flow control now based on highest received byte offset rather than (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/reliable_quic_stream.h ('k') | net/quic/test_tools/quic_flow_controller_peer.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/reliable_quic_stream.h" 5 #include "net/quic/reliable_quic_stream.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/quic/iovector.h" 8 #include "net/quic/iovector.h"
9 #include "net/quic/quic_flow_controller.h" 9 #include "net/quic/quic_flow_controller.h"
10 #include "net/quic/quic_session.h" 10 #include "net/quic/quic_session.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // We don't want to be reading: blackhole the data. 144 // We don't want to be reading: blackhole the data.
145 return true; 145 return true;
146 } 146 }
147 147
148 if (frame.stream_id != id_) { 148 if (frame.stream_id != id_) {
149 LOG(ERROR) << "Error!"; 149 LOG(ERROR) << "Error!";
150 return false; 150 return false;
151 } 151 }
152 152
153 // This count include duplicate data received. 153 // This count include duplicate data received.
154 stream_bytes_read_ += frame.data.TotalBufferSize(); 154 size_t frame_payload_size = frame.data.TotalBufferSize();
155 stream_bytes_read_ += frame_payload_size;
156
157 // Flow control is interested in tracking highest received offset.
158 MaybeIncreaseHighestReceivedOffset(frame.offset + frame_payload_size);
155 159
156 bool accepted = sequencer_.OnStreamFrame(frame); 160 bool accepted = sequencer_.OnStreamFrame(frame);
157 161
158 if (flow_controller_.FlowControlViolation() || 162 if (flow_controller_.FlowControlViolation() ||
159 connection_flow_controller_->FlowControlViolation()) { 163 connection_flow_controller_->FlowControlViolation()) {
160 session_->connection()->SendConnectionClose(QUIC_FLOW_CONTROL_ERROR); 164 session_->connection()->SendConnectionClose(QUIC_FLOW_CONTROL_ERROR);
161 return false; 165 return false;
162 } 166 }
163 167
164 return accepted; 168 return accepted;
165 } 169 }
166 170
167 int ReliableQuicStream::num_frames_received() const { 171 int ReliableQuicStream::num_frames_received() const {
168 return sequencer_.num_frames_received(); 172 return sequencer_.num_frames_received();
169 } 173 }
170 174
171 int ReliableQuicStream::num_duplicate_frames_received() const { 175 int ReliableQuicStream::num_duplicate_frames_received() const {
172 return sequencer_.num_duplicate_frames_received(); 176 return sequencer_.num_duplicate_frames_received();
173 } 177 }
174 178
175 void ReliableQuicStream::OnStreamReset(const QuicRstStreamFrame& frame) { 179 void ReliableQuicStream::OnStreamReset(const QuicRstStreamFrame& frame) {
180 MaybeIncreaseHighestReceivedOffset(frame.byte_offset);
181
176 stream_error_ = frame.error_code; 182 stream_error_ = frame.error_code;
177 CloseWriteSide(); 183 CloseWriteSide();
178 CloseReadSide(); 184 CloseReadSide();
179 } 185 }
180 186
181 void ReliableQuicStream::OnConnectionClosed(QuicErrorCode error, 187 void ReliableQuicStream::OnConnectionClosed(QuicErrorCode error,
182 bool from_peer) { 188 bool from_peer) {
183 if (read_side_closed_ && write_side_closed_) { 189 if (read_side_closed_ && write_side_closed_) {
184 return; 190 return;
185 } 191 }
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 if (flow_controller_.UpdateSendWindowOffset(frame.byte_offset)) { 429 if (flow_controller_.UpdateSendWindowOffset(frame.byte_offset)) {
424 // We can write again! 430 // We can write again!
425 // TODO(rjshade): This does not respect priorities (e.g. multiple 431 // TODO(rjshade): This does not respect priorities (e.g. multiple
426 // outstanding POSTs are unblocked on arrival of 432 // outstanding POSTs are unblocked on arrival of
427 // SHLO with initial window). 433 // SHLO with initial window).
428 // As long as the connection is not flow control blocked, we can write! 434 // As long as the connection is not flow control blocked, we can write!
429 OnCanWrite(); 435 OnCanWrite();
430 } 436 }
431 } 437 }
432 438
433 void ReliableQuicStream::AddBytesBuffered(uint64 bytes) { 439 void ReliableQuicStream::MaybeIncreaseHighestReceivedOffset(uint64 new_offset) {
434 if (flow_controller_.IsEnabled()) { 440 if (flow_controller_.IsEnabled()) {
435 flow_controller_.AddBytesBuffered(bytes); 441 uint64 increment =
436 connection_flow_controller_->AddBytesBuffered(bytes); 442 new_offset - flow_controller_.highest_received_byte_offset();
443 if (flow_controller_.UpdateHighestReceivedOffset(new_offset)) {
444 // If |new_offset| increased the stream flow controller's highest received
445 // offset, then we need to increase the connection flow controller's value
446 // by the incremental difference.
447 connection_flow_controller_->UpdateHighestReceivedOffset(
448 connection_flow_controller_->highest_received_byte_offset() +
449 increment);
450 }
437 } 451 }
438 } 452 }
439 453
440 void ReliableQuicStream::RemoveBytesBuffered(uint64 bytes) {
441 if (flow_controller_.IsEnabled()) {
442 flow_controller_.RemoveBytesBuffered(bytes);
443 connection_flow_controller_->RemoveBytesBuffered(bytes);
444 }
445 }
446
447 void ReliableQuicStream::AddBytesSent(uint64 bytes) { 454 void ReliableQuicStream::AddBytesSent(uint64 bytes) {
448 if (flow_controller_.IsEnabled()) { 455 if (flow_controller_.IsEnabled()) {
449 flow_controller_.AddBytesSent(bytes); 456 flow_controller_.AddBytesSent(bytes);
450 connection_flow_controller_->AddBytesSent(bytes); 457 connection_flow_controller_->AddBytesSent(bytes);
451 } 458 }
452 } 459 }
453 460
454 void ReliableQuicStream::AddBytesConsumed(uint64 bytes) { 461 void ReliableQuicStream::AddBytesConsumed(uint64 bytes) {
455 if (flow_controller_.IsEnabled()) { 462 if (flow_controller_.IsEnabled()) {
456 flow_controller_.AddBytesConsumed(bytes); 463 flow_controller_.AddBytesConsumed(bytes);
457 flow_controller_.MaybeSendWindowUpdate(session()->connection()); 464 flow_controller_.MaybeSendWindowUpdate(session()->connection());
458 465
459 connection_flow_controller_->AddBytesConsumed(bytes); 466 connection_flow_controller_->AddBytesConsumed(bytes);
460 connection_flow_controller_->MaybeSendWindowUpdate(session()->connection()); 467 connection_flow_controller_->MaybeSendWindowUpdate(session()->connection());
461 } 468 }
462 } 469 }
463 470
464 bool ReliableQuicStream::IsFlowControlBlocked() { 471 bool ReliableQuicStream::IsFlowControlBlocked() {
465 return flow_controller_.IsBlocked() || 472 return flow_controller_.IsBlocked() ||
466 connection_flow_controller_->IsBlocked(); 473 connection_flow_controller_->IsBlocked();
467 } 474 }
468 475
469 } // namespace net 476 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/reliable_quic_stream.h ('k') | net/quic/test_tools/quic_flow_controller_peer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698