| 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;
|
|
|