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

Unified Diff: net/base/priority_queue.h

Issue 23620058: Add a cap of six in-flight requests per host to the ResourceScheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed build Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: net/base/priority_queue.h
diff --git a/net/base/priority_queue.h b/net/base/priority_queue.h
index 7b7d97c0e8e31764d737c59239338cd4a3c17d99..ab4be3ef1f29b8d3990122dc2fcdf9151a2f3a7e 100644
--- a/net/base/priority_queue.h
+++ b/net/base/priority_queue.h
@@ -264,6 +264,31 @@ class PriorityQueue : public base::NonThreadSafe {
size_ = 0u;
}
+ // This can be used to iterate through the composite container, in
+ // highest-to-lowest, first-inserted-to-last order.
+ Pointer NextHighest(const Pointer& previous) {
+ Priority priority = previous.priority_;
+ typename Pointer::ListIterator list_entry = previous.iterator_;
+
+ if (list_entry != lists_[priority].end()) {
+ ++list_entry;
+ }
+
+ while (priority < lists_.size()) {
+ if (list_entry == lists_[priority].end()) {
+ if (priority == 0) {
+ break;
+ }
+ priority--;
+ list_entry = lists_[priority].begin();
+ } else {
+ return Pointer(priority, list_entry);
+ }
+ }
+
+ return Pointer();
+ }
+
// Returns the number of priorities the queue supports.
size_t num_priorities() const {
DCHECK(CalledOnValidThread());

Powered by Google App Engine
This is Rietveld 408576698