| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 #include "net/quic/core/quic_stream_sequencer_buffer.h" | 4 #include "net/quic/core/quic_stream_sequencer_buffer.h" |
| 5 | 5 |
| 6 #include <algorithm> | 6 #include <algorithm> |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 EXPECT_EQ(max_capacity_bytes_ + 512, buffer_->BytesConsumed()); | 861 EXPECT_EQ(max_capacity_bytes_ + 512, buffer_->BytesConsumed()); |
| 862 EXPECT_TRUE(buffer_->Empty()); | 862 EXPECT_TRUE(buffer_->Empty()); |
| 863 EXPECT_TRUE(helper_->CheckBufferInvariants()); | 863 EXPECT_TRUE(helper_->CheckBufferInvariants()); |
| 864 // Clear buffer at this point should still preserve BytesConsumed(). | 864 // Clear buffer at this point should still preserve BytesConsumed(). |
| 865 buffer_->Clear(); | 865 buffer_->Clear(); |
| 866 EXPECT_EQ(max_capacity_bytes_ + 512, buffer_->BytesConsumed()); | 866 EXPECT_EQ(max_capacity_bytes_ + 512, buffer_->BytesConsumed()); |
| 867 EXPECT_TRUE(helper_->CheckBufferInvariants()); | 867 EXPECT_TRUE(helper_->CheckBufferInvariants()); |
| 868 } | 868 } |
| 869 | 869 |
| 870 TEST_F(QuicStreamSequencerBufferTest, TooManyGaps) { | 870 TEST_F(QuicStreamSequencerBufferTest, TooManyGaps) { |
| 871 QuicFlagSaver flags; | |
| 872 FLAGS_quic_limit_frame_gaps_in_buffer = true; | |
| 873 // Make sure max capacity is large enough that it is possible to have more | 871 // Make sure max capacity is large enough that it is possible to have more |
| 874 // than |kMaxNumGapsAllowed| number of gaps. | 872 // than |kMaxNumGapsAllowed| number of gaps. |
| 875 max_capacity_bytes_ = 3 * kBlockSizeBytes; | 873 max_capacity_bytes_ = 3 * kBlockSizeBytes; |
| 876 // Feed buffer with 1-byte discontiguous frames. e.g. [1,2), [3,4), [5,6)... | 874 // Feed buffer with 1-byte discontiguous frames. e.g. [1,2), [3,4), [5,6)... |
| 877 for (QuicStreamOffset begin = 1; begin <= max_capacity_bytes_; begin += 2) { | 875 for (QuicStreamOffset begin = 1; begin <= max_capacity_bytes_; begin += 2) { |
| 878 size_t written; | 876 size_t written; |
| 879 QuicErrorCode rs = buffer_->OnStreamData( | 877 QuicErrorCode rs = buffer_->OnStreamData( |
| 880 begin, "a", clock_.ApproximateNow(), &written, &error_details_); | 878 begin, "a", clock_.ApproximateNow(), &written, &error_details_); |
| 881 | 879 |
| 882 QuicStreamOffset last_straw = 2 * kMaxNumGapsAllowed - 1; | 880 QuicStreamOffset last_straw = 2 * kMaxNumGapsAllowed - 1; |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1112 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: " | 1110 EXPECT_LE(bytes_to_buffer_, total_bytes_read_) << "iterations: " |
| 1113 << iterations; | 1111 << iterations; |
| 1114 EXPECT_LE(bytes_to_buffer_, total_bytes_written_); | 1112 EXPECT_LE(bytes_to_buffer_, total_bytes_written_); |
| 1115 } | 1113 } |
| 1116 | 1114 |
| 1117 } // anonymous namespace | 1115 } // anonymous namespace |
| 1118 | 1116 |
| 1119 } // namespace test | 1117 } // namespace test |
| 1120 | 1118 |
| 1121 } // namespace net | 1119 } // namespace net |
| OLD | NEW |