| OLD | NEW |
| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 id_, | 70 id_, |
| 71 perspective_, | 71 perspective_, |
| 72 GetReceivedFlowControlWindow(session), | 72 GetReceivedFlowControlWindow(session), |
| 73 GetInitialStreamFlowControlWindowToSend(session), | 73 GetInitialStreamFlowControlWindowToSend(session), |
| 74 session_->flow_controller()->auto_tune_receive_window(), | 74 session_->flow_controller()->auto_tune_receive_window(), |
| 75 session_->flow_controller()), | 75 session_->flow_controller()), |
| 76 connection_flow_controller_(session_->flow_controller()), | 76 connection_flow_controller_(session_->flow_controller()), |
| 77 stream_contributes_to_connection_flow_control_(true), | 77 stream_contributes_to_connection_flow_control_(true), |
| 78 busy_counter_(0), | 78 busy_counter_(0), |
| 79 add_random_padding_after_fin_(false), | 79 add_random_padding_after_fin_(false), |
| 80 ack_listener_(nullptr) { | 80 ack_listener_(nullptr), |
| 81 send_buffer_(session->connection()->helper()->GetBufferAllocator()) { |
| 81 SetFromConfig(); | 82 SetFromConfig(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 QuicStream::~QuicStream() { | 85 QuicStream::~QuicStream() { |
| 85 if (session_ != nullptr && session_->use_stream_notifier() && | 86 if (session_ != nullptr && session_->use_stream_notifier() && |
| 86 IsWaitingForAcks()) { | 87 IsWaitingForAcks()) { |
| 87 QUIC_DVLOG(1) | 88 QUIC_DVLOG(1) |
| 88 << ENDPOINT << "Stream " << id_ | 89 << ENDPOINT << "Stream " << id_ |
| 89 << " gets destroyed while waiting for acks. stream_bytes_outstanding = " | 90 << " gets destroyed while waiting for acks. stream_bytes_outstanding = " |
| 90 << stream_bytes_outstanding_ | 91 << stream_bytes_outstanding_ |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 if (stream_bytes_outstanding_ < frame.data_length || | 526 if (stream_bytes_outstanding_ < frame.data_length || |
| 526 (!fin_outstanding_ && frame.fin)) { | 527 (!fin_outstanding_ && frame.fin)) { |
| 527 CloseConnectionWithDetails(QUIC_INTERNAL_ERROR, | 528 CloseConnectionWithDetails(QUIC_INTERNAL_ERROR, |
| 528 "Trying to discard unsent data."); | 529 "Trying to discard unsent data."); |
| 529 return; | 530 return; |
| 530 } | 531 } |
| 531 stream_bytes_outstanding_ -= frame.data_length; | 532 stream_bytes_outstanding_ -= frame.data_length; |
| 532 if (frame.fin) { | 533 if (frame.fin) { |
| 533 fin_outstanding_ = false; | 534 fin_outstanding_ = false; |
| 534 } | 535 } |
| 536 if (session_->streams_own_data() && frame.data_length > 0) { |
| 537 send_buffer_.RemoveStreamFrame(frame.offset, frame.data_length); |
| 538 } |
| 535 if (!IsWaitingForAcks()) { | 539 if (!IsWaitingForAcks()) { |
| 536 session_->OnStreamDoneWaitingForAcks(id_); | 540 session_->OnStreamDoneWaitingForAcks(id_); |
| 537 } | 541 } |
| 538 } | 542 } |
| 539 | 543 |
| 540 bool QuicStream::IsWaitingForAcks() const { | 544 bool QuicStream::IsWaitingForAcks() const { |
| 541 return stream_bytes_outstanding_ || fin_outstanding_; | 545 return stream_bytes_outstanding_ || fin_outstanding_; |
| 542 } | 546 } |
| 543 | 547 |
| 548 void QuicStream::SaveStreamData(QuicIOVector iov, |
| 549 size_t iov_offset, |
| 550 QuicStreamOffset offset, |
| 551 QuicByteCount data_length) { |
| 552 DCHECK_LT(0u, data_length); |
| 553 send_buffer_.SaveStreamData(iov, iov_offset, offset, data_length); |
| 554 } |
| 555 |
| 556 bool QuicStream::WriteStreamData(QuicStreamOffset offset, |
| 557 QuicByteCount data_length, |
| 558 QuicDataWriter* writer) { |
| 559 DCHECK_LT(0u, data_length); |
| 560 return send_buffer_.WriteStreamData(offset, data_length, writer); |
| 561 } |
| 562 |
| 544 } // namespace net | 563 } // namespace net |
| OLD | NEW |