| 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_sequencer.h" | 5 #include "net/quic/core/quic_stream_sequencer.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 using std::min; | 27 using std::min; |
| 28 using std::numeric_limits; | 28 using std::numeric_limits; |
| 29 using std::string; | 29 using std::string; |
| 30 | 30 |
| 31 namespace net { | 31 namespace net { |
| 32 | 32 |
| 33 QuicStreamSequencer::QuicStreamSequencer(ReliableQuicStream* quic_stream, | 33 QuicStreamSequencer::QuicStreamSequencer(ReliableQuicStream* quic_stream, |
| 34 const QuicClock* clock) | 34 const QuicClock* clock) |
| 35 : stream_(quic_stream), | 35 : stream_(quic_stream), |
| 36 buffered_frames_(kStreamReceiveWindowLimit), | 36 buffered_frames_(kStreamReceiveWindowLimit), |
| 37 close_offset_(numeric_limits<QuicStreamOffset>::max()), | 37 close_offset_(std::numeric_limits<QuicStreamOffset>::max()), |
| 38 blocked_(false), | 38 blocked_(false), |
| 39 num_frames_received_(0), | 39 num_frames_received_(0), |
| 40 num_duplicate_frames_received_(0), | 40 num_duplicate_frames_received_(0), |
| 41 clock_(clock), | 41 clock_(clock), |
| 42 ignore_read_data_(false) {} | 42 ignore_read_data_(false) {} |
| 43 | 43 |
| 44 QuicStreamSequencer::~QuicStreamSequencer() {} | 44 QuicStreamSequencer::~QuicStreamSequencer() {} |
| 45 | 45 |
| 46 void QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) { | 46 void QuicStreamSequencer::OnStreamFrame(const QuicStreamFrame& frame) { |
| 47 ++num_frames_received_; | 47 ++num_frames_received_; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 if (byte_offset == buffered_frames_.BytesConsumed()) { | 83 if (byte_offset == buffered_frames_.BytesConsumed()) { |
| 84 if (ignore_read_data_) { | 84 if (ignore_read_data_) { |
| 85 FlushBufferedFrames(); | 85 FlushBufferedFrames(); |
| 86 } else { | 86 } else { |
| 87 stream_->OnDataAvailable(); | 87 stream_->OnDataAvailable(); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 void QuicStreamSequencer::CloseStreamAtOffset(QuicStreamOffset offset) { | 92 void QuicStreamSequencer::CloseStreamAtOffset(QuicStreamOffset offset) { |
| 93 const QuicStreamOffset kMaxOffset = numeric_limits<QuicStreamOffset>::max(); | 93 const QuicStreamOffset kMaxOffset = |
| 94 std::numeric_limits<QuicStreamOffset>::max(); |
| 94 | 95 |
| 95 // If there is a scheduled close, the new offset should match it. | 96 // If there is a scheduled close, the new offset should match it. |
| 96 if (close_offset_ != kMaxOffset && offset != close_offset_) { | 97 if (close_offset_ != kMaxOffset && offset != close_offset_) { |
| 97 stream_->Reset(QUIC_MULTIPLE_TERMINATION_OFFSETS); | 98 stream_->Reset(QUIC_MULTIPLE_TERMINATION_OFFSETS); |
| 98 return; | 99 return; |
| 99 } | 100 } |
| 100 | 101 |
| 101 close_offset_ = offset; | 102 close_offset_ = offset; |
| 102 | 103 |
| 103 MaybeCloseStream(); | 104 MaybeCloseStream(); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 "\n bytes buffered: " + IntToString(NumBytesBuffered()) + | 228 "\n bytes buffered: " + IntToString(NumBytesBuffered()) + |
| 228 "\n bytes consumed: " + IntToString( NumBytesConsumed()) + | 229 "\n bytes consumed: " + IntToString( NumBytesConsumed()) + |
| 229 "\n has bytes to read: " + (HasBytesToRead() ? "true" : "false") + | 230 "\n has bytes to read: " + (HasBytesToRead() ? "true" : "false") + |
| 230 "\n frames received: " + IntToString(num_frames_received()) + | 231 "\n frames received: " + IntToString(num_frames_received()) + |
| 231 "\n close offset bytes: " + IntToString( close_offset_) + | 232 "\n close offset bytes: " + IntToString( close_offset_) + |
| 232 "\n is closed: " + (IsClosed() ? "true" : "false"); | 233 "\n is closed: " + (IsClosed() ? "true" : "false"); |
| 233 // clang-format on | 234 // clang-format on |
| 234 } | 235 } |
| 235 | 236 |
| 236 } // namespace net | 237 } // namespace net |
| OLD | NEW |