Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: net/quic/quic_write_blocked_list_test.cc

Issue 137893008: WriteBlockedList for QUIC that prioritizes Crypto and Headers streams (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_write_blocked_list.cc ('k') | net/quic/reliable_quic_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 //
5 #include "net/quic/quic_write_blocked_list.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace net {
10 namespace test {
11 namespace {
12
13 TEST(QuicWriteBlockedListTest, PriorityOrder) {
14 QuicWriteBlockedList write_blocked_list;
15
16 // Mark streams blocked in roughly reverse priority order, and
17 // verify that streams are sorted.
18 write_blocked_list.PushBack(40,
19 QuicWriteBlockedList::kLowestPriority,
20 QUIC_VERSION_13);
21 write_blocked_list.PushBack(23,
22 QuicWriteBlockedList::kHighestPriority,
23 QUIC_VERSION_13);
24 write_blocked_list.PushBack(17,
25 QuicWriteBlockedList::kHighestPriority,
26 QUIC_VERSION_13);
27 write_blocked_list.PushBack(kHeadersStreamId,
28 QuicWriteBlockedList::kHighestPriority,
29 QUIC_VERSION_13);
30 write_blocked_list.PushBack(kCryptoStreamId,
31 QuicWriteBlockedList::kHighestPriority,
32 QUIC_VERSION_13);
33
34 EXPECT_EQ(5u, write_blocked_list.NumBlockedStreams());
35 EXPECT_TRUE(write_blocked_list.HasWriteBlockedStreams());
36 // The Crypto stream is highest priority.
37 EXPECT_EQ(kCryptoStreamId, write_blocked_list.PopFront());
38 // Followed by the Headers stream.
39 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront());
40 // Streams with same priority are popped in the order they were inserted.
41 EXPECT_EQ(23u, write_blocked_list.PopFront());
42 EXPECT_EQ(17u, write_blocked_list.PopFront());
43 // Low priority stream appears last.
44 EXPECT_EQ(40u, write_blocked_list.PopFront());
45
46 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
47 EXPECT_FALSE(write_blocked_list.HasWriteBlockedStreams());
48 }
49
50 TEST(QuicWriteBlockedListTest, CryptoStream) {
51 QuicWriteBlockedList write_blocked_list;
52 write_blocked_list.PushBack(kCryptoStreamId,
53 QuicWriteBlockedList::kHighestPriority,
54 QUIC_VERSION_13);
55
56 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams());
57 EXPECT_TRUE(write_blocked_list.HasWriteBlockedStreams());
58 EXPECT_EQ(kCryptoStreamId, write_blocked_list.PopFront());
59 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
60 EXPECT_FALSE(write_blocked_list.HasWriteBlockedStreams());
61 }
62
63 TEST(QuicWriteBlockedListTest, HeadersStream) {
64 QuicWriteBlockedList write_blocked_list;
65 write_blocked_list.PushBack(kHeadersStreamId,
66 QuicWriteBlockedList::kHighestPriority,
67 QUIC_VERSION_13);
68
69 EXPECT_EQ(1u, write_blocked_list.NumBlockedStreams());
70 EXPECT_TRUE(write_blocked_list.HasWriteBlockedStreams());
71 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront());
72 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
73 EXPECT_FALSE(write_blocked_list.HasWriteBlockedStreams());
74 }
75
76 TEST(QuicWriteBlockedListTest, NoHeadersStreamInVersion12) {
77 for (int idx = 0; idx < 2; ++idx) {
78 QuicVersion version = ((idx == 0) ? QUIC_VERSION_13 : QUIC_VERSION_12);
79 QuicWriteBlockedList write_blocked_list;
80 write_blocked_list.PushBack(5,
81 QuicWriteBlockedList::kHighestPriority,
82 version);
83 write_blocked_list.PushBack(kHeadersStreamId,
84 QuicWriteBlockedList::kHighestPriority,
85 version);
86
87 EXPECT_EQ(2u, write_blocked_list.NumBlockedStreams());
88 EXPECT_TRUE(write_blocked_list.HasWriteBlockedStreams());
89 if (version > QUIC_VERSION_12) {
90 // In newer QUIC versions, there is a headers stream which is
91 // higher priority than data streams.
92 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront());
93 EXPECT_EQ(5u, write_blocked_list.PopFront());
94 } else {
95 // In older QUIC versions, there is no reserved headers stream id.
96 EXPECT_EQ(5u, write_blocked_list.PopFront());
97 EXPECT_EQ(kHeadersStreamId, write_blocked_list.PopFront());
98 }
99 EXPECT_EQ(0u, write_blocked_list.NumBlockedStreams());
100 EXPECT_FALSE(write_blocked_list.HasWriteBlockedStreams());
101 }
102 }
103
104 } // namespace
105 } // namespace test
106 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_write_blocked_list.cc ('k') | net/quic/reliable_quic_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698