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

Unified Diff: net/base/client_socket_pool.cc

Issue 42541: Prioritize which HTTP requests get a socket first by adding a priority level ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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
« no previous file with comments | « net/base/client_socket_pool.h ('k') | net/base/client_socket_pool_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/client_socket_pool.cc
===================================================================
--- net/base/client_socket_pool.cc (revision 12453)
+++ net/base/client_socket_pool.cc (working copy)
@@ -41,7 +41,21 @@
DCHECK(group_map_.empty());
}
+// InsertRequestIntoQueue inserts the request into the queue based on
+// priority. Highest priorities are closest to the front. Older requests are
+// prioritized over requests of equal priority.
+//
+// static
+void ClientSocketPool::InsertRequestIntoQueue(const Request& r,
+ RequestQueue* pending_requests) {
+ RequestQueue::iterator it = pending_requests->begin();
+ while (it != pending_requests->end() && r.priority <= it->priority)
+ ++it;
+ pending_requests->insert(it, r);
+}
+
int ClientSocketPool::RequestSocket(ClientSocketHandle* handle,
+ int priority,
CompletionCallback* callback) {
Group& group = group_map_[handle->group_name_];
@@ -51,7 +65,8 @@
r.handle = handle;
DCHECK(callback);
r.callback = callback;
- group.pending_requests.push_back(r);
+ r.priority = priority;
+ InsertRequestIntoQueue(r, &group.pending_requests);
return ERR_IO_PENDING;
}
@@ -183,7 +198,7 @@
if (!group.pending_requests.empty()) {
Request r = group.pending_requests.front();
group.pending_requests.pop_front();
- int rv = RequestSocket(r.handle, NULL);
+ int rv = RequestSocket(r.handle, r.priority, NULL);
DCHECK(rv == OK);
r.callback->Run(rv);
return;
« no previous file with comments | « net/base/client_socket_pool.h ('k') | net/base/client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698