| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_write_blocked_list.h" | 5 #include "net/quic/core/quic_write_blocked_list.h" |
| 6 | 6 |
| 7 #include "net/quic/platform/api/quic_test.h" | 7 #include "net/quic/platform/api/quic_test.h" |
| 8 #include "net/quic/test_tools/quic_test_utils.h" | 8 #include "net/quic/test_tools/quic_test_utils.h" |
| 9 | 9 |
| 10 using net::kV3LowestPriority; | 10 using net::kV3LowestPriority; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream()); | 93 EXPECT_FALSE(write_blocked_list.HasWriteBlockedCryptoOrHeadersStream()); |
| 94 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams()); | 94 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 TEST_F(QuicWriteBlockedListTest, NoDuplicateEntries) { | 97 TEST_F(QuicWriteBlockedListTest, NoDuplicateEntries) { |
| 98 // Test that QuicWriteBlockedList doesn't allow duplicate entries. | 98 // Test that QuicWriteBlockedList doesn't allow duplicate entries. |
| 99 QuicWriteBlockedList write_blocked_list; | 99 QuicWriteBlockedList write_blocked_list; |
| 100 | 100 |
| 101 // Try to add a stream to the write blocked list multiple times at the same | 101 // Try to add a stream to the write blocked list multiple times at the same |
| 102 // priority. | 102 // priority. |
| 103 const QuicStreamId kBlockedId = kClientDataStreamId1; | 103 const QuicStreamId kBlockedId = kHeadersStreamId + 2; |
| 104 write_blocked_list.RegisterStream(kBlockedId, kV3HighestPriority); | 104 write_blocked_list.RegisterStream(kBlockedId, kV3HighestPriority); |
| 105 write_blocked_list.AddStream(kBlockedId); | 105 write_blocked_list.AddStream(kBlockedId); |
| 106 write_blocked_list.AddStream(kBlockedId); | 106 write_blocked_list.AddStream(kBlockedId); |
| 107 write_blocked_list.AddStream(kBlockedId); | 107 write_blocked_list.AddStream(kBlockedId); |
| 108 | 108 |
| 109 // This should only result in one blocked stream being added. | 109 // This should only result in one blocked stream being added. |
| 110 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams()); | 110 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams()); |
| 111 EXPECT_TRUE(write_blocked_list.HasWriteBlockedDataStreams()); | 111 EXPECT_TRUE(write_blocked_list.HasWriteBlockedDataStreams()); |
| 112 | 112 |
| 113 // There should only be one stream to pop off the front. | 113 // There should only be one stream to pop off the front. |
| 114 EXPECT_EQ(kBlockedId, write_blocked_list.PopFront()); | 114 EXPECT_EQ(kBlockedId, write_blocked_list.PopFront()); |
| 115 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams()); | 115 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams()); |
| 116 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams()); | 116 EXPECT_FALSE(write_blocked_list.HasWriteBlockedDataStreams()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 TEST_F(QuicWriteBlockedListTest, BatchingWrites) { | 119 TEST_F(QuicWriteBlockedListTest, BatchingWrites) { |
| 120 QuicWriteBlockedList write_blocked_list; | 120 QuicWriteBlockedList write_blocked_list; |
| 121 | 121 |
| 122 const QuicStreamId id1 = kClientDataStreamId1; | 122 const QuicStreamId id1 = kHeadersStreamId + 2; |
| 123 const QuicStreamId id2 = kClientDataStreamId2; | 123 const QuicStreamId id2 = id1 + 2; |
| 124 const QuicStreamId id3 = kClientDataStreamId2 + 2; | 124 const QuicStreamId id3 = id2 + 2; |
| 125 write_blocked_list.RegisterStream(id1, kV3LowestPriority); | 125 write_blocked_list.RegisterStream(id1, kV3LowestPriority); |
| 126 write_blocked_list.RegisterStream(id2, kV3LowestPriority); | 126 write_blocked_list.RegisterStream(id2, kV3LowestPriority); |
| 127 write_blocked_list.RegisterStream(id3, kV3HighestPriority); | 127 write_blocked_list.RegisterStream(id3, kV3HighestPriority); |
| 128 | 128 |
| 129 write_blocked_list.AddStream(id1); | 129 write_blocked_list.AddStream(id1); |
| 130 write_blocked_list.AddStream(id2); | 130 write_blocked_list.AddStream(id2); |
| 131 EXPECT_EQ(2u, write_blocked_list.NumBlockedStreams()); | 131 EXPECT_EQ(2u, write_blocked_list.NumBlockedStreams()); |
| 132 | 132 |
| 133 // The first stream we push back should stay at the front until 16k is | 133 // The first stream we push back should stay at the front until 16k is |
| 134 // written. | 134 // written. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 write_blocked_list.AddStream(kCryptoStreamId); | 212 write_blocked_list.AddStream(kCryptoStreamId); |
| 213 EXPECT_TRUE(write_blocked_list.ShouldYield(16)); | 213 EXPECT_TRUE(write_blocked_list.ShouldYield(16)); |
| 214 EXPECT_TRUE(write_blocked_list.ShouldYield(15)); | 214 EXPECT_TRUE(write_blocked_list.ShouldYield(15)); |
| 215 EXPECT_TRUE(write_blocked_list.ShouldYield(kHeadersStreamId)); | 215 EXPECT_TRUE(write_blocked_list.ShouldYield(kHeadersStreamId)); |
| 216 EXPECT_FALSE(write_blocked_list.ShouldYield(kCryptoStreamId)); | 216 EXPECT_FALSE(write_blocked_list.ShouldYield(kCryptoStreamId)); |
| 217 } | 217 } |
| 218 | 218 |
| 219 } // namespace | 219 } // namespace |
| 220 } // namespace test | 220 } // namespace test |
| 221 } // namespace net | 221 } // namespace net |
| OLD | NEW |