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

Unified Diff: net/spdy/write_blocked_list.h

Issue 76723002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compilation error Created 7 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/test_tools/quic_test_utils.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 fe5668fae8aae610d31487b8577ec0cfd91b8d07..be97f89c71fe8a6b11e9ab1e3b9afbcb66706737 100644
--- a/net/spdy/write_blocked_list.h
+++ b/net/spdy/write_blocked_list.h
@@ -9,6 +9,7 @@
#include <deque>
#include "base/logging.h"
+#include "net/spdy/spdy_protocol.h"
namespace net {
@@ -22,25 +23,39 @@ class WriteBlockedList {
typedef std::deque<IdType> BlockedList;
typedef typename BlockedList::iterator iterator;
- // Returns the priority of the highest priority list with sessions on it, or
- // -1 if none of the lists have pending sessions.
- int GetHighestPriorityWriteBlockedList() const {
- for (int i = 0; i <= kLowestPriority; ++i) {
+ static SpdyPriority ClampPriority(SpdyPriority priority) {
+ if (priority < kHighestPriority) {
+ LOG(DFATAL) << "Invalid priority: " << static_cast<int>(priority);
+ return kHighestPriority;
+ }
+ if (priority > kLowestPriority) {
+ LOG(DFATAL) << "Invalid priority: " << static_cast<int>(priority);
+ return kLowestPriority;
+ }
+ return priority;
+ }
+
+ // Returns the priority of the highest priority list with sessions on it.
+ SpdyPriority GetHighestPriorityWriteBlockedList() const {
+ for (SpdyPriority i = 0; i <= kLowestPriority; ++i) {
if (write_blocked_lists_[i].size() > 0)
return i;
}
- return -1;
+ LOG(DFATAL) << "No blocked streams";
+ return kHighestPriority;
}
- int PopFront(int priority) {
+ IdType PopFront(SpdyPriority priority) {
+ priority = ClampPriority(priority);
DCHECK(!write_blocked_lists_[priority].empty());
IdType stream_id = write_blocked_lists_[priority].front();
write_blocked_lists_[priority].pop_front();
return stream_id;
}
- bool HasWriteBlockedStreamsGreaterThanPriority(int priority) const {
- for (int i = kHighestPriority; i < priority; ++i) {
+ bool HasWriteBlockedStreamsGreaterThanPriority(SpdyPriority priority) const {
+ priority = ClampPriority(priority);
+ for (SpdyPriority i = kHighestPriority; i < priority; ++i) {
if (!write_blocked_lists_[i].empty()) {
return true;
}
@@ -49,14 +64,20 @@ class WriteBlockedList {
}
bool HasWriteBlockedStreams() const {
- return HasWriteBlockedStreamsGreaterThanPriority(kLowestPriority + 1);
+ for (SpdyPriority i = kHighestPriority; i <= kLowestPriority; ++i) {
+ if (!write_blocked_lists_[i].empty()) {
+ return true;
+ }
+ }
+ return false;
}
- void PushBack(IdType stream_id, int priority) {
- write_blocked_lists_[priority].push_back(stream_id);
+ void PushBack(IdType stream_id, SpdyPriority priority) {
+ write_blocked_lists_[ClampPriority(priority)].push_back(stream_id);
}
- void RemoveStreamFromWriteBlockedList(IdType stream_id, int priority) {
+ void RemoveStreamFromWriteBlockedList(IdType stream_id,
+ SpdyPriority priority) {
iterator it = std::find(write_blocked_lists_[priority].begin(),
write_blocked_lists_[priority].end(),
stream_id);
@@ -68,17 +89,16 @@ class WriteBlockedList {
}
}
- int NumBlockedStreams() {
- int num_blocked_streams = 0;
- for (int i = kHighestPriority; i <= kLowestPriority; ++i) {
+ size_t NumBlockedStreams() const {
+ size_t num_blocked_streams = 0;
+ for (SpdyPriority i = kHighestPriority; i <= kLowestPriority; ++i) {
num_blocked_streams += write_blocked_lists_[i].size();
}
return num_blocked_streams;
}
private:
- // Priority ranges from 0 to 7
- BlockedList write_blocked_lists_[8];
+ BlockedList write_blocked_lists_[kLowestPriority + 1];
};
} // namespace net
« no previous file with comments | « net/quic/test_tools/quic_test_utils.cc ('k') | net/spdy/write_blocked_list_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698