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

Unified Diff: net/spdy/write_blocked_list.h

Issue 822713002: Update from https://crrev.com/309415 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years 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
Index: net/spdy/write_blocked_list.h
diff --git a/net/spdy/write_blocked_list.h b/net/spdy/write_blocked_list.h
index be97f89c71fe8a6b11e9ab1e3b9afbcb66706737..e936402a8342474450917f245d8864b16ae76cee 100644
--- a/net/spdy/write_blocked_list.h
+++ b/net/spdy/write_blocked_list.h
@@ -11,6 +11,10 @@
#include "base/logging.h"
#include "net/spdy/spdy_protocol.h"
+namespace {
+class WriteBlockedListPeer;
+}
+
namespace net {
const int kHighestPriority = 0;
@@ -76,16 +80,32 @@ class WriteBlockedList {
write_blocked_lists_[ClampPriority(priority)].push_back(stream_id);
}
- void RemoveStreamFromWriteBlockedList(IdType stream_id,
+ bool RemoveStreamFromWriteBlockedList(IdType stream_id,
SpdyPriority priority) {
+ // We shouldn't really add a stream_id to a list multiple times,
+ // but under some conditions it does happen. Doing a check in PushBack
+ // would be too costly, so instead we check here to eliminate duplicates.
+ bool found = false;
iterator it = std::find(write_blocked_lists_[priority].begin(),
write_blocked_lists_[priority].end(),
stream_id);
while (it != write_blocked_lists_[priority].end()) {
- write_blocked_lists_[priority].erase(it);
- it = std::find(write_blocked_lists_[priority].begin(),
- write_blocked_lists_[priority].end(),
- stream_id);
+ found = true;
+ iterator next_it = write_blocked_lists_[priority].erase(it);
+ it = std::find(next_it, write_blocked_lists_[priority].end(), stream_id);
+ }
+ return found;
+ }
+
+ void UpdateStreamPriorityInWriteBlockedList(IdType stream_id,
+ SpdyPriority old_priority,
+ SpdyPriority new_priority) {
+ if (old_priority == new_priority) {
+ return;
+ }
+ bool found = RemoveStreamFromWriteBlockedList(stream_id, old_priority);
+ if (found) {
+ PushBack(stream_id, new_priority);
}
}
@@ -98,6 +118,7 @@ class WriteBlockedList {
}
private:
+ friend WriteBlockedListPeer;
BlockedList write_blocked_lists_[kLowestPriority + 1];
};

Powered by Google App Engine
This is Rietveld 408576698