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/quic_stream_sequencer.h" | 5 #include "net/quic/quic_stream_sequencer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 } | 87 } |
88 | 88 |
89 // Buffer any remaining data to be consumed by the stream when ready. | 89 // Buffer any remaining data to be consumed by the stream when ready. |
90 for (size_t i = 0; i < data.Size(); ++i) { | 90 for (size_t i = 0; i < data.Size(); ++i) { |
91 DVLOG(1) << "Buffering stream data at offset " << byte_offset; | 91 DVLOG(1) << "Buffering stream data at offset " << byte_offset; |
92 const iovec& iov = data.iovec()[i]; | 92 const iovec& iov = data.iovec()[i]; |
93 frames_.insert(make_pair( | 93 frames_.insert(make_pair( |
94 byte_offset, string(static_cast<char*>(iov.iov_base), iov.iov_len))); | 94 byte_offset, string(static_cast<char*>(iov.iov_base), iov.iov_len))); |
95 byte_offset += iov.iov_len; | 95 byte_offset += iov.iov_len; |
96 num_bytes_buffered_ += iov.iov_len; | 96 num_bytes_buffered_ += iov.iov_len; |
97 stream_->AddBytesBuffered(iov.iov_len); | |
98 } | 97 } |
99 return true; | 98 return true; |
100 } | 99 } |
101 | 100 |
102 void QuicStreamSequencer::CloseStreamAtOffset(QuicStreamOffset offset) { | 101 void QuicStreamSequencer::CloseStreamAtOffset(QuicStreamOffset offset) { |
103 const QuicStreamOffset kMaxOffset = numeric_limits<QuicStreamOffset>::max(); | 102 const QuicStreamOffset kMaxOffset = numeric_limits<QuicStreamOffset>::max(); |
104 | 103 |
105 // If we have a scheduled termination or close, any new offset should match | 104 // If we have a scheduled termination or close, any new offset should match |
106 // it. | 105 // it. |
107 if (close_offset_ != kMaxOffset && offset != close_offset_) { | 106 if (close_offset_ != kMaxOffset && offset != close_offset_) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 } | 239 } |
241 } | 240 } |
242 MaybeCloseStream(); | 241 MaybeCloseStream(); |
243 } | 242 } |
244 | 243 |
245 void QuicStreamSequencer::RecordBytesConsumed(size_t bytes_consumed) { | 244 void QuicStreamSequencer::RecordBytesConsumed(size_t bytes_consumed) { |
246 num_bytes_consumed_ += bytes_consumed; | 245 num_bytes_consumed_ += bytes_consumed; |
247 num_bytes_buffered_ -= bytes_consumed; | 246 num_bytes_buffered_ -= bytes_consumed; |
248 | 247 |
249 stream_->AddBytesConsumed(bytes_consumed); | 248 stream_->AddBytesConsumed(bytes_consumed); |
250 stream_->RemoveBytesBuffered(bytes_consumed); | |
251 } | 249 } |
252 | 250 |
253 } // namespace net | 251 } // namespace net |
OLD | NEW |