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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/write_blocked_list.h
diff --git a/net/spdy/write_blocked_list.h b/net/spdy/write_blocked_list.h
index 32ed19c98d8a403f5771ec25d5239bd4c167743b..7622dc204ce66b0bf07ec923263ab783704a2172 100644
--- a/net/spdy/write_blocked_list.h
+++ b/net/spdy/write_blocked_list.h
@@ -81,29 +81,20 @@ class WriteBlockedList {
return false;
}
+ // Add this stream to the back of the write blocked list for this priority
+ // level. If the stream is already on that write blocked list this is a
+ // no-op. If the stream is on a write blocked list for a different priority
+ // it will be removed from that list.
void PushBack(IdType stream_id, SpdyPriority priority) {
- priority = ClampPriority(priority);
- DVLOG(2) << "Adding stream " << stream_id << " at priority "
- << static_cast<int>(priority);
- bool should_insert_stream = true;
- typename StreamToPriorityMap::iterator iter =
- stream_to_priority_.find(stream_id);
- if (iter != stream_to_priority_.end()) {
- DVLOG(1) << "Stream " << stream_id << " already in write blocked list.";
- if (iter->second == priority) {
- // The stream is already in the write blocked list for the priority.
- should_insert_stream = false;
- } else {
- // The stream is in a write blocked list for a different priority.
- bool removed =
- RemoveStreamFromWriteBlockedList(stream_id, iter->second);
- DCHECK(removed);
- }
- }
- if (should_insert_stream) {
- stream_to_priority_[stream_id] = priority;
- write_blocked_lists_[priority].push_back(stream_id);
- }
+ AddStream(stream_id, priority, true);
+ }
+
+ // Add this stream to the front of the write blocked list for this priority
+ // level. If the stream is already on that write blocked list this is a
+ // no-op. If the stream is on a write blocked list for a different priority
+ // it will be removed from that list.
+ void PushFront(IdType stream_id, SpdyPriority priority) {
+ AddStream(stream_id, priority, false);
}
bool RemoveStreamFromWriteBlockedList(IdType stream_id,
@@ -153,11 +144,48 @@ class WriteBlockedList {
return num_blocked_streams;
}
+ size_t NumBlockedStreams(SpdyPriority priority) const {
+ priority = ClampPriority(priority);
+ return write_blocked_lists_[priority].size();
+ }
+
private:
friend class net::test::WriteBlockedListPeer;
typedef base::hash_map<IdType, SpdyPriority> StreamToPriorityMap;
+ void AddStream(IdType stream_id, SpdyPriority priority, bool push_back) {
+ priority = ClampPriority(priority);
+ DVLOG(2) << "Adding stream " << stream_id << " at priority "
+ << static_cast<int>(priority);
+ bool should_insert_stream = true;
+ typename StreamToPriorityMap::iterator iter =
+ stream_to_priority_.find(stream_id);
+ // Ensure the stream is not in the write blocked list multiple times.
+ if (iter != stream_to_priority_.end()) {
+ DVLOG(1) << "Stream " << stream_id << " already in write blocked list.";
+ if (iter->second == priority) {
+ // The stream is already in the write blocked list for the priority.
+ // It will not be inserted again but will retain its place in the list.
+ should_insert_stream = false;
+ } else {
+ // The stream is in a write blocked list for a different priority.
+ // Remove it from that list and allow it to be added to the list for
+ // this priority.
+ bool removed =
+ RemoveStreamFromWriteBlockedList(stream_id, iter->second);
+ DCHECK(removed);
+ }
+ }
+ if (should_insert_stream) {
+ stream_to_priority_[stream_id] = priority;
+ if (push_back) {
+ write_blocked_lists_[priority].push_back(stream_id);
+ } else {
+ write_blocked_lists_[priority].push_front(stream_id);
+ }
+ }
+ }
BlockedList write_blocked_lists_[kLowestPriority + 1];
StreamToPriorityMap stream_to_priority_;
};
« 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