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

Side by Side Diff: net/spdy/write_blocked_list.h

Issue 1472563002: Let QUIC streams write 16k before ceding. Behind FLAG_quic_batch_writes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@107581674
Patch Set: Created 5 years, 1 month 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_write_blocked_list_test.cc ('k') | net/spdy/write_blocked_list_test.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_SPDY_WRITE_BLOCKED_LIST_H_ 5 #ifndef NET_SPDY_WRITE_BLOCKED_LIST_H_
6 #define NET_SPDY_WRITE_BLOCKED_LIST_H_ 6 #define NET_SPDY_WRITE_BLOCKED_LIST_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <deque> 9 #include <deque>
10 10
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 bool HasWriteBlockedStreams() const { 75 bool HasWriteBlockedStreams() const {
76 for (SpdyPriority i = kHighestPriority; i <= kLowestPriority; ++i) { 76 for (SpdyPriority i = kHighestPriority; i <= kLowestPriority; ++i) {
77 if (!write_blocked_lists_[i].empty()) { 77 if (!write_blocked_lists_[i].empty()) {
78 return true; 78 return true;
79 } 79 }
80 } 80 }
81 return false; 81 return false;
82 } 82 }
83 83
84 // Add this stream to the back of the write blocked list for this priority
85 // level. If the stream is already on that write blocked list this is a
86 // no-op. If the stream is on a write blocked list for a different priority
87 // it will be removed from that list.
84 void PushBack(IdType stream_id, SpdyPriority priority) { 88 void PushBack(IdType stream_id, SpdyPriority priority) {
85 priority = ClampPriority(priority); 89 AddStream(stream_id, priority, true);
86 DVLOG(2) << "Adding stream " << stream_id << " at priority " 90 }
87 << static_cast<int>(priority); 91
88 bool should_insert_stream = true; 92 // Add this stream to the front of the write blocked list for this priority
89 typename StreamToPriorityMap::iterator iter = 93 // level. If the stream is already on that write blocked list this is a
90 stream_to_priority_.find(stream_id); 94 // no-op. If the stream is on a write blocked list for a different priority
91 if (iter != stream_to_priority_.end()) { 95 // it will be removed from that list.
92 DVLOG(1) << "Stream " << stream_id << " already in write blocked list."; 96 void PushFront(IdType stream_id, SpdyPriority priority) {
93 if (iter->second == priority) { 97 AddStream(stream_id, priority, false);
94 // The stream is already in the write blocked list for the priority.
95 should_insert_stream = false;
96 } else {
97 // The stream is in a write blocked list for a different priority.
98 bool removed =
99 RemoveStreamFromWriteBlockedList(stream_id, iter->second);
100 DCHECK(removed);
101 }
102 }
103 if (should_insert_stream) {
104 stream_to_priority_[stream_id] = priority;
105 write_blocked_lists_[priority].push_back(stream_id);
106 }
107 } 98 }
108 99
109 bool RemoveStreamFromWriteBlockedList(IdType stream_id, 100 bool RemoveStreamFromWriteBlockedList(IdType stream_id,
110 SpdyPriority priority) { 101 SpdyPriority priority) {
111 typename StreamToPriorityMap::iterator iter = 102 typename StreamToPriorityMap::iterator iter =
112 stream_to_priority_.find(stream_id); 103 stream_to_priority_.find(stream_id);
113 if (iter == stream_to_priority_.end()) { 104 if (iter == stream_to_priority_.end()) {
114 // The stream is not present in the write blocked list. 105 // The stream is not present in the write blocked list.
115 return false; 106 return false;
116 } else if (iter->second == priority) { 107 } else if (iter->second == priority) {
(...skipping 29 matching lines...) Expand all
146 } 137 }
147 138
148 size_t NumBlockedStreams() const { 139 size_t NumBlockedStreams() const {
149 size_t num_blocked_streams = 0; 140 size_t num_blocked_streams = 0;
150 for (SpdyPriority i = kHighestPriority; i <= kLowestPriority; ++i) { 141 for (SpdyPriority i = kHighestPriority; i <= kLowestPriority; ++i) {
151 num_blocked_streams += write_blocked_lists_[i].size(); 142 num_blocked_streams += write_blocked_lists_[i].size();
152 } 143 }
153 return num_blocked_streams; 144 return num_blocked_streams;
154 } 145 }
155 146
147 size_t NumBlockedStreams(SpdyPriority priority) const {
148 priority = ClampPriority(priority);
149 return write_blocked_lists_[priority].size();
150 }
151
156 private: 152 private:
157 friend class net::test::WriteBlockedListPeer; 153 friend class net::test::WriteBlockedListPeer;
158 154
159 typedef base::hash_map<IdType, SpdyPriority> StreamToPriorityMap; 155 typedef base::hash_map<IdType, SpdyPriority> StreamToPriorityMap;
160 156
157 void AddStream(IdType stream_id, SpdyPriority priority, bool push_back) {
158 priority = ClampPriority(priority);
159 DVLOG(2) << "Adding stream " << stream_id << " at priority "
160 << static_cast<int>(priority);
161 bool should_insert_stream = true;
162 typename StreamToPriorityMap::iterator iter =
163 stream_to_priority_.find(stream_id);
164 // Ensure the stream is not in the write blocked list multiple times.
165 if (iter != stream_to_priority_.end()) {
166 DVLOG(1) << "Stream " << stream_id << " already in write blocked list.";
167 if (iter->second == priority) {
168 // The stream is already in the write blocked list for the priority.
169 // It will not be inserted again but will retain its place in the list.
170 should_insert_stream = false;
171 } else {
172 // The stream is in a write blocked list for a different priority.
173 // Remove it from that list and allow it to be added to the list for
174 // this priority.
175 bool removed =
176 RemoveStreamFromWriteBlockedList(stream_id, iter->second);
177 DCHECK(removed);
178 }
179 }
180 if (should_insert_stream) {
181 stream_to_priority_[stream_id] = priority;
182 if (push_back) {
183 write_blocked_lists_[priority].push_back(stream_id);
184 } else {
185 write_blocked_lists_[priority].push_front(stream_id);
186 }
187 }
188 }
161 BlockedList write_blocked_lists_[kLowestPriority + 1]; 189 BlockedList write_blocked_lists_[kLowestPriority + 1];
162 StreamToPriorityMap stream_to_priority_; 190 StreamToPriorityMap stream_to_priority_;
163 }; 191 };
164 192
165 } // namespace net 193 } // namespace net
166 194
167 #endif // NET_SPDY_WRITE_BLOCKED_LIST_H_ 195 #endif // NET_SPDY_WRITE_BLOCKED_LIST_H_
OLDNEW
« no previous file with comments | « net/quic/quic_write_blocked_list_test.cc ('k') | net/spdy/write_blocked_list_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698