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

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

Issue 330333006: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linus_tsan error - reverted the change to ConnectionMigrationClientPortChanged unitttest 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/reliable_quic_stream_test.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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 stream_bytes_written_(0), 117 stream_bytes_written_(0),
118 stream_error_(QUIC_STREAM_NO_ERROR), 118 stream_error_(QUIC_STREAM_NO_ERROR),
119 connection_error_(QUIC_NO_ERROR), 119 connection_error_(QUIC_NO_ERROR),
120 read_side_closed_(false), 120 read_side_closed_(false),
121 write_side_closed_(false), 121 write_side_closed_(false),
122 fin_buffered_(false), 122 fin_buffered_(false),
123 fin_sent_(false), 123 fin_sent_(false),
124 fin_received_(false), 124 fin_received_(false),
125 rst_sent_(false), 125 rst_sent_(false),
126 rst_received_(false), 126 rst_received_(false),
127 fec_policy_(FEC_PROTECT_OPTIONAL),
127 is_server_(session_->is_server()), 128 is_server_(session_->is_server()),
128 flow_controller_( 129 flow_controller_(
129 session_->connection(), 130 session_->connection(),
130 id_, 131 id_,
131 is_server_, 132 is_server_,
132 session_->config()->HasReceivedInitialFlowControlWindowBytes() ? 133 session_->config()->HasReceivedInitialFlowControlWindowBytes() ?
133 session_->config()->ReceivedInitialFlowControlWindowBytes() : 134 session_->config()->ReceivedInitialFlowControlWindowBytes() :
134 kDefaultFlowControlSendWindow, 135 kDefaultFlowControlSendWindow,
135 session_->max_flow_control_receive_window_bytes(), 136 session_->config()->GetInitialFlowControlWindowToSend(),
136 session_->max_flow_control_receive_window_bytes()), 137 session_->config()->GetInitialFlowControlWindowToSend()),
137 connection_flow_controller_(session_->flow_controller()) { 138 connection_flow_controller_(session_->flow_controller()) {
138 } 139 }
139 140
140 ReliableQuicStream::~ReliableQuicStream() { 141 ReliableQuicStream::~ReliableQuicStream() {
141 } 142 }
142 143
143 bool ReliableQuicStream::OnStreamFrame(const QuicStreamFrame& frame) { 144 bool ReliableQuicStream::OnStreamFrame(const QuicStreamFrame& frame) {
144 if (read_side_closed_) { 145 if (read_side_closed_) {
145 DVLOG(1) << ENDPOINT << "Ignoring frame " << frame.stream_id; 146 DVLOG(1) << ENDPOINT << "Ignoring frame " << frame.stream_id;
146 // We don't want to be reading: blackhole the data. 147 // We don't want to be reading: blackhole the data.
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 354
354 // Writing more data would be a violation of flow control. 355 // Writing more data would be a violation of flow control.
355 write_length = send_window; 356 write_length = send_window;
356 } 357 }
357 } 358 }
358 359
359 // Fill an IOVector with bytes from the iovec. 360 // Fill an IOVector with bytes from the iovec.
360 IOVector data; 361 IOVector data;
361 data.AppendIovecAtMostBytes(iov, iov_count, write_length); 362 data.AppendIovecAtMostBytes(iov, iov_count, write_length);
362 363
363 // TODO(jri): Use the correct FecProtection based on FecPolicy on stream.
364 QuicConsumedData consumed_data = session()->WritevData( 364 QuicConsumedData consumed_data = session()->WritevData(
365 id(), data, stream_bytes_written_, fin, MAY_FEC_PROTECT, 365 id(), data, stream_bytes_written_, fin, GetFecProtection(),
366 ack_notifier_delegate); 366 ack_notifier_delegate);
367 stream_bytes_written_ += consumed_data.bytes_consumed; 367 stream_bytes_written_ += consumed_data.bytes_consumed;
368 368
369 AddBytesSent(consumed_data.bytes_consumed); 369 AddBytesSent(consumed_data.bytes_consumed);
370 370
371 if (consumed_data.bytes_consumed == write_length) { 371 if (consumed_data.bytes_consumed == write_length) {
372 if (!fin_with_zero_data) { 372 if (!fin_with_zero_data) {
373 MaybeSendBlocked(); 373 MaybeSendBlocked();
374 } 374 }
375 if (fin && consumed_data.fin_consumed) { 375 if (fin && consumed_data.fin_consumed) {
376 fin_sent_ = true; 376 fin_sent_ = true;
377 CloseWriteSide(); 377 CloseWriteSide();
378 } else if (fin && !consumed_data.fin_consumed) { 378 } else if (fin && !consumed_data.fin_consumed) {
379 session_->MarkWriteBlocked(id(), EffectivePriority()); 379 session_->MarkWriteBlocked(id(), EffectivePriority());
380 } 380 }
381 } else { 381 } else {
382 session_->MarkWriteBlocked(id(), EffectivePriority()); 382 session_->MarkWriteBlocked(id(), EffectivePriority());
383 } 383 }
384 return consumed_data; 384 return consumed_data;
385 } 385 }
386 386
387 FecProtection ReliableQuicStream::GetFecProtection() {
388 return fec_policy_ == FEC_PROTECT_ALWAYS ? MUST_FEC_PROTECT : MAY_FEC_PROTECT;
389 }
390
387 void ReliableQuicStream::CloseReadSide() { 391 void ReliableQuicStream::CloseReadSide() {
388 if (read_side_closed_) { 392 if (read_side_closed_) {
389 return; 393 return;
390 } 394 }
391 DVLOG(1) << ENDPOINT << "Done reading from stream " << id(); 395 DVLOG(1) << ENDPOINT << "Done reading from stream " << id();
392 396
393 read_side_closed_ = true; 397 read_side_closed_ = true;
394 if (write_side_closed_) { 398 if (write_side_closed_) {
395 DVLOG(1) << ENDPOINT << "Closing stream: " << id(); 399 DVLOG(1) << ENDPOINT << "Closing stream: " << id();
396 session_->CloseStream(id()); 400 session_->CloseStream(id());
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 connection_flow_controller_->AddBytesConsumed(bytes); 492 connection_flow_controller_->AddBytesConsumed(bytes);
489 } 493 }
490 } 494 }
491 495
492 bool ReliableQuicStream::IsFlowControlBlocked() { 496 bool ReliableQuicStream::IsFlowControlBlocked() {
493 return flow_controller_.IsBlocked() || 497 return flow_controller_.IsBlocked() ||
494 connection_flow_controller_->IsBlocked(); 498 connection_flow_controller_->IsBlocked();
495 } 499 }
496 500
497 } // namespace net 501 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/reliable_quic_stream.h ('k') | net/quic/reliable_quic_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698