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

Side by Side Diff: net/quic/core/quic_stream.cc

Issue 2916033003: Landing Recent QUIC changes until 03:18 AM, May 28, UTC (Closed)
Patch Set: A few more EXPORTs. Created 3 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
« no previous file with comments | « net/quic/core/quic_stream.h ('k') | net/quic/core/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/core/quic_stream.h" 5 #include "net/quic/core/quic_stream.h"
6 6
7 #include "net/quic/core/quic_flow_controller.h" 7 #include "net/quic/core/quic_flow_controller.h"
8 #include "net/quic/core/quic_session.h" 8 #include "net/quic/core/quic_session.h"
9 #include "net/quic/platform/api/quic_bug_tracker.h" 9 #include "net/quic/platform/api/quic_bug_tracker.h"
10 #include "net/quic/platform/api/quic_logging.h" 10 #include "net/quic/platform/api/quic_logging.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 QuicStream::PendingData::~PendingData() {} 48 QuicStream::PendingData::~PendingData() {}
49 49
50 QuicStream::QuicStream(QuicStreamId id, QuicSession* session) 50 QuicStream::QuicStream(QuicStreamId id, QuicSession* session)
51 : queued_data_bytes_(0), 51 : queued_data_bytes_(0),
52 sequencer_(this, session->connection()->clock()), 52 sequencer_(this, session->connection()->clock()),
53 id_(id), 53 id_(id),
54 session_(session), 54 session_(session),
55 stream_bytes_read_(0), 55 stream_bytes_read_(0),
56 stream_bytes_written_(0), 56 stream_bytes_written_(0),
57 stream_bytes_acked_(0),
57 stream_error_(QUIC_STREAM_NO_ERROR), 58 stream_error_(QUIC_STREAM_NO_ERROR),
58 connection_error_(QUIC_NO_ERROR), 59 connection_error_(QUIC_NO_ERROR),
59 read_side_closed_(false), 60 read_side_closed_(false),
60 write_side_closed_(false), 61 write_side_closed_(false),
61 fin_buffered_(false), 62 fin_buffered_(false),
62 fin_sent_(false), 63 fin_sent_(false),
64 fin_acked_(false),
63 fin_received_(false), 65 fin_received_(false),
64 rst_sent_(false), 66 rst_sent_(false),
65 rst_received_(false), 67 rst_received_(false),
66 perspective_(session_->perspective()), 68 perspective_(session_->perspective()),
67 flow_controller_(session_->connection(), 69 flow_controller_(session_->connection(),
68 id_, 70 id_,
69 perspective_, 71 perspective_,
70 GetReceivedFlowControlWindow(session), 72 GetReceivedFlowControlWindow(session),
71 GetInitialStreamFlowControlWindowToSend(session), 73 GetInitialStreamFlowControlWindowToSend(session),
72 session_->flow_controller()->auto_tune_receive_window(), 74 session_->flow_controller()->auto_tune_receive_window(),
73 session_->flow_controller()), 75 session_->flow_controller()),
74 connection_flow_controller_(session_->flow_controller()), 76 connection_flow_controller_(session_->flow_controller()),
75 stream_contributes_to_connection_flow_control_(true), 77 stream_contributes_to_connection_flow_control_(true),
76 busy_counter_(0), 78 busy_counter_(0),
77 add_random_padding_after_fin_(false) { 79 add_random_padding_after_fin_(false),
80 ack_listener_(nullptr) {
78 SetFromConfig(); 81 SetFromConfig();
79 } 82 }
80 83
81 QuicStream::~QuicStream() {} 84 QuicStream::~QuicStream() {
85 QUIC_LOG_IF(WARNING, !IsWaitingForAcks())
86 << "Stream destroyed while waiting for acks.";
87 }
82 88
83 void QuicStream::SetFromConfig() {} 89 void QuicStream::SetFromConfig() {}
84 90
85 void QuicStream::OnStreamFrame(const QuicStreamFrame& frame) { 91 void QuicStream::OnStreamFrame(const QuicStreamFrame& frame) {
86 DCHECK_EQ(frame.stream_id, id_); 92 DCHECK_EQ(frame.stream_id, id_);
87 93
88 DCHECK(!(read_side_closed_ && write_side_closed_)); 94 DCHECK(!(read_side_closed_ && write_side_closed_));
89 95
90 if (frame.fin) { 96 if (frame.fin) {
91 fin_received_ = true; 97 fin_received_ = true;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // stream will be destroyed by CloseReadSide, so don't need to call 170 // stream will be destroyed by CloseReadSide, so don't need to call
165 // StreamDraining. 171 // StreamDraining.
166 CloseReadSide(); 172 CloseReadSide();
167 } 173 }
168 174
169 void QuicStream::Reset(QuicRstStreamErrorCode error) { 175 void QuicStream::Reset(QuicRstStreamErrorCode error) {
170 stream_error_ = error; 176 stream_error_ = error;
171 // Sending a RstStream results in calling CloseStream. 177 // Sending a RstStream results in calling CloseStream.
172 session()->SendRstStream(id(), error, stream_bytes_written_); 178 session()->SendRstStream(id(), error, stream_bytes_written_);
173 rst_sent_ = true; 179 rst_sent_ = true;
180 if (session()->use_stream_notifier() && !IsWaitingForAcks()) {
181 session_->OnStreamDoneWaitingForAcks(id_);
182 }
174 } 183 }
175 184
176 void QuicStream::CloseConnectionWithDetails(QuicErrorCode error, 185 void QuicStream::CloseConnectionWithDetails(QuicErrorCode error,
177 const string& details) { 186 const string& details) {
178 session()->connection()->CloseConnection( 187 session()->connection()->CloseConnection(
179 error, details, ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); 188 error, details, ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
180 } 189 }
181 190
182 void QuicStream::WriteOrBufferData( 191 void QuicStream::WriteOrBufferData(
183 QuicStringPiece data, 192 QuicStringPiece data,
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 void QuicStream::UpdateSendWindowOffset(QuicStreamOffset new_window) { 494 void QuicStream::UpdateSendWindowOffset(QuicStreamOffset new_window) {
486 if (flow_controller_.UpdateSendWindowOffset(new_window)) { 495 if (flow_controller_.UpdateSendWindowOffset(new_window)) {
487 OnCanWrite(); 496 OnCanWrite();
488 } 497 }
489 } 498 }
490 499
491 void QuicStream::AddRandomPaddingAfterFin() { 500 void QuicStream::AddRandomPaddingAfterFin() {
492 add_random_padding_after_fin_ = true; 501 add_random_padding_after_fin_ = true;
493 } 502 }
494 503
504 void QuicStream::OnStreamFrameAcked(const QuicStreamFrame& frame,
505 QuicTime::Delta ack_delay_time) {
506 DCHECK_EQ(frame.stream_id, id());
507 stream_bytes_acked_ += frame.data_length;
508 if (stream_bytes_acked_ > stream_bytes_written_) {
509 CloseConnectionWithDetails(QUIC_INTERNAL_ERROR,
510 "Unsent stream data is acked");
511 return;
512 }
513 if (frame.fin) {
514 fin_acked_ = true;
515 }
516 if (ack_listener_ != nullptr) {
517 ack_listener_->OnPacketAcked(frame.data_length, ack_delay_time);
518 }
519 if (!IsWaitingForAcks()) {
520 session_->OnStreamDoneWaitingForAcks(id_);
521 }
522 }
523
524 void QuicStream::OnStreamFrameRetransmitted(const QuicStreamFrame& frame) {
525 if (ack_listener_ != nullptr) {
526 ack_listener_->OnPacketRetransmitted(frame.data_length);
527 }
528 }
529
530 bool QuicStream::IsWaitingForAcks() const {
531 if (rst_sent_ && stream_error_ != QUIC_STREAM_NO_ERROR) {
532 // RST_STREAM sent because of error.
533 return false;
534 }
535 if (connection_error_ != QUIC_NO_ERROR) {
536 // Connection encounters error and is going to close.
537 return false;
538 }
539 if (stream_bytes_acked_ == stream_bytes_written_ &&
540 ((fin_sent_ && fin_acked_) || !fin_sent_)) {
541 // All sent data has been acked.
542 return false;
543 }
544
545 return true;
546 }
547
495 } // namespace net 548 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_stream.h ('k') | net/quic/core/quic_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698