| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/test_tools/quic_stream_sequencer_buffer_peer.h" | 5 #include "net/quic/test_tools/quic_stream_sequencer_buffer_peer.h" |
| 6 | 6 |
| 7 #include "net/quic/core/quic_flags.h" | 7 #include "net/quic/core/quic_flags.h" |
| 8 #include "net/test/gtest_util.h" | 8 #include "net/test/gtest_util.h" |
| 9 | 9 |
| 10 typedef net::QuicStreamSequencerBuffer::BufferBlock BufferBlock; | 10 typedef net::QuicStreamSequencerBuffer::BufferBlock BufferBlock; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 return bytes_read; | 34 return bytes_read; |
| 35 } | 35 } |
| 36 | 36 |
| 37 // If buffer is empty, the blocks_ array must be empty, which means all | 37 // If buffer is empty, the blocks_ array must be empty, which means all |
| 38 // blocks are deallocated. | 38 // blocks are deallocated. |
| 39 bool QuicStreamSequencerBufferPeer::CheckEmptyInvariants() { | 39 bool QuicStreamSequencerBufferPeer::CheckEmptyInvariants() { |
| 40 return !buffer_->Empty() || IsBlockArrayEmpty(); | 40 return !buffer_->Empty() || IsBlockArrayEmpty(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 bool QuicStreamSequencerBufferPeer::IsBlockArrayEmpty() { | 43 bool QuicStreamSequencerBufferPeer::IsBlockArrayEmpty() { |
| 44 if (buffer_->blocks_ == nullptr) { | 44 if (FLAGS_quic_reduce_sequencer_buffer_memory_life_time && // NOLINT |
| 45 buffer_->blocks_ == nullptr) { |
| 45 return true; | 46 return true; |
| 46 } | 47 } |
| 47 | 48 |
| 48 size_t count = buffer_->blocks_count_; | 49 size_t count = buffer_->blocks_count_; |
| 49 for (size_t i = 0; i < count; i++) { | 50 for (size_t i = 0; i < count; i++) { |
| 50 if (buffer_->blocks_[i] != nullptr) { | 51 if (buffer_->blocks_[i] != nullptr) { |
| 51 return false; | 52 return false; |
| 52 } | 53 } |
| 53 } | 54 } |
| 54 return true; | 55 return true; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 void QuicStreamSequencerBufferPeer::set_gaps(const std::list<Gap>& gaps) { | 133 void QuicStreamSequencerBufferPeer::set_gaps(const std::list<Gap>& gaps) { |
| 133 buffer_->gaps_ = gaps; | 134 buffer_->gaps_ = gaps; |
| 134 } | 135 } |
| 135 | 136 |
| 136 bool QuicStreamSequencerBufferPeer::IsBufferAllocated() { | 137 bool QuicStreamSequencerBufferPeer::IsBufferAllocated() { |
| 137 return buffer_->blocks_ != nullptr; | 138 return buffer_->blocks_ != nullptr; |
| 138 } | 139 } |
| 139 | 140 |
| 140 } // namespace test | 141 } // namespace test |
| 141 } // namespace net | 142 } // namespace net |
| OLD | NEW |