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

Side by Side Diff: net/quic/quic_write_blocked_list.h

Issue 1134603005: Remove WriteBlockedList::use_stream_to_priority. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/quic_write_blocked_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ 5 #ifndef NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_
6 #define NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ 6 #define NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_
7 7
8 #include <set> 8 #include <set>
9 9
10 #include "net/base/net_export.h" 10 #include "net/base/net_export.h"
11 #include "net/quic/quic_protocol.h" 11 #include "net/quic/quic_protocol.h"
12 #include "net/spdy/write_blocked_list.h" 12 #include "net/spdy/write_blocked_list.h"
13 13
14 namespace net { 14 namespace net {
15 15
16 // Keeps tracks of the QUIC streams that have data to write, sorted by 16 // Keeps tracks of the QUIC streams that have data to write, sorted by
17 // priority. QUIC stream priority order is: 17 // priority. QUIC stream priority order is:
18 // Crypto stream > Headers stream > Data streams by requested priority. 18 // Crypto stream > Headers stream > Data streams by requested priority.
19 class NET_EXPORT_PRIVATE QuicWriteBlockedList { 19 class NET_EXPORT_PRIVATE QuicWriteBlockedList {
20 private: 20 private:
21 typedef WriteBlockedList<QuicStreamId> QuicWriteBlockedListBase; 21 typedef WriteBlockedList<QuicStreamId> QuicWriteBlockedListBase;
22 22
23 public: 23 public:
24 static const QuicPriority kHighestPriority; 24 static const QuicPriority kHighestPriority;
25 static const QuicPriority kLowestPriority; 25 static const QuicPriority kLowestPriority;
26 26
27 explicit QuicWriteBlockedList(bool avoid_duplicate_streams); 27 QuicWriteBlockedList();
28 ~QuicWriteBlockedList(); 28 ~QuicWriteBlockedList();
29 29
30 bool HasWriteBlockedDataStreams() const { 30 bool HasWriteBlockedDataStreams() const {
31 return base_write_blocked_list_.HasWriteBlockedStreams(); 31 return base_write_blocked_list_.HasWriteBlockedStreams();
32 } 32 }
33 33
34 bool HasWriteBlockedCryptoOrHeadersStream() const { 34 bool HasWriteBlockedCryptoOrHeadersStream() const {
35 return crypto_stream_blocked_ || headers_stream_blocked_; 35 return crypto_stream_blocked_ || headers_stream_blocked_;
36 } 36 }
37 37
(...skipping 16 matching lines...) Expand all
54 } 54 }
55 55
56 if (headers_stream_blocked_) { 56 if (headers_stream_blocked_) {
57 headers_stream_blocked_ = false; 57 headers_stream_blocked_ = false;
58 return kHeadersStreamId; 58 return kHeadersStreamId;
59 } 59 }
60 60
61 SpdyPriority priority = 61 SpdyPriority priority =
62 base_write_blocked_list_.GetHighestPriorityWriteBlockedList(); 62 base_write_blocked_list_.GetHighestPriorityWriteBlockedList();
63 QuicStreamId id = base_write_blocked_list_.PopFront(priority); 63 QuicStreamId id = base_write_blocked_list_.PopFront(priority);
64 blocked_streams_.erase(id);
65 return id; 64 return id;
66 } 65 }
67 66
68 void PushBack(QuicStreamId stream_id, QuicPriority priority) { 67 void PushBack(QuicStreamId stream_id, QuicPriority priority) {
69 if (stream_id == kCryptoStreamId) { 68 if (stream_id == kCryptoStreamId) {
70 DCHECK_EQ(kHighestPriority, priority); 69 DCHECK_EQ(kHighestPriority, priority);
71 // TODO(avd) Add DCHECK(!crypto_stream_blocked_) 70 // TODO(avd) Add DCHECK(!crypto_stream_blocked_)
72 crypto_stream_blocked_ = true; 71 crypto_stream_blocked_ = true;
73 return; 72 return;
74 } 73 }
75 74
76 if (stream_id == kHeadersStreamId) { 75 if (stream_id == kHeadersStreamId) {
77 DCHECK_EQ(kHighestPriority, priority); 76 DCHECK_EQ(kHighestPriority, priority);
78 // TODO(avd) Add DCHECK(!headers_stream_blocked_); 77 // TODO(avd) Add DCHECK(!headers_stream_blocked_);
79 headers_stream_blocked_ = true; 78 headers_stream_blocked_ = true;
80 return; 79 return;
81 } 80 }
82 81
83 if (!base_write_blocked_list_.avoids_inserting_duplicates() &&
84 blocked_streams_.find(stream_id) != blocked_streams_.end()) {
85 DVLOG(1) << "Stream " << stream_id << " already in write blocked list.";
86 return;
87 }
88
89 base_write_blocked_list_.PushBack( 82 base_write_blocked_list_.PushBack(
90 stream_id, static_cast<SpdyPriority>(priority)); 83 stream_id, static_cast<SpdyPriority>(priority));
91 blocked_streams_.insert(stream_id);
92 return; 84 return;
93 } 85 }
94 86
95 bool crypto_stream_blocked() const { return crypto_stream_blocked_; } 87 bool crypto_stream_blocked() const { return crypto_stream_blocked_; }
96 bool headers_stream_blocked() const { return headers_stream_blocked_; } 88 bool headers_stream_blocked() const { return headers_stream_blocked_; }
97 89
98 private: 90 private:
99 QuicWriteBlockedListBase base_write_blocked_list_; 91 QuicWriteBlockedListBase base_write_blocked_list_;
100 bool crypto_stream_blocked_; 92 bool crypto_stream_blocked_;
101 bool headers_stream_blocked_; 93 bool headers_stream_blocked_;
102 94
103 // Keep track of write blocked streams in a set for faster membership checking
104 // than iterating over the base_write_blocked_list_. The contents of this set
105 // should mirror the contents of base_write_blocked_list_.
106 std::set<QuicStreamId> blocked_streams_;
107
108 DISALLOW_COPY_AND_ASSIGN(QuicWriteBlockedList); 95 DISALLOW_COPY_AND_ASSIGN(QuicWriteBlockedList);
109 }; 96 };
110 97
111 } // namespace net 98 } // namespace net
112 99
113 100
114 #endif // NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_ 101 #endif // NET_QUIC_QUIC_WRITE_BLOCKED_LIST_H_
OLDNEW
« no previous file with comments | « net/quic/quic_session.cc ('k') | net/quic/quic_write_blocked_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698