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

Unified Diff: net/socket/client_socket_pool_base.cc

Issue 51683002: [Net] Assert that URLRequests with LOAD_IGNORE_LIMITS have MAXIMUM_PRIORITY (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments 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
Index: net/socket/client_socket_pool_base.cc
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index 46de10e810f7f8a5eaf45eeeeed495caa53fa8c9..976eec8792ac92c06cba13e4a399dc2455ce3fde 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -140,7 +140,10 @@ ClientSocketPoolBaseHelper::Request::Request(
priority_(priority),
ignore_limits_(ignore_limits),
flags_(flags),
- net_log_(net_log) {}
+ net_log_(net_log) {
+ if (ignore_limits_)
+ DCHECK_EQ(priority_, MAXIMUM_PRIORITY);
+}
ClientSocketPoolBaseHelper::Request::~Request() {}
@@ -1131,9 +1134,7 @@ void ClientSocketPoolBaseHelper::TryToCloseSocketsInLayeredPools() {
ClientSocketPoolBaseHelper::Group::Group()
: unassigned_job_count_(0),
- // The number of priorities is doubled since requests with
- // |ignore_limits| are prioritized over other requests.
- pending_requests_(2 * NUM_PRIORITIES),
+ pending_requests_(NUM_PRIORITIES),
active_socket_count_(0) {}
ClientSocketPoolBaseHelper::Group::~Group() {
@@ -1270,11 +1271,17 @@ bool ClientSocketPoolBaseHelper::Group::HasConnectJobForHandle(
void ClientSocketPoolBaseHelper::Group::InsertPendingRequest(
scoped_ptr<const Request> request) {
- RequestQueue::Priority queue_priority = request->priority();
- // Prioritize requests with |ignore_limits| over ones that don't.
- if (request->ignore_limits())
- queue_priority += NUM_PRIORITIES;
- pending_requests_.Insert(request.release(), queue_priority);
+ // We must cache this value before we release |request|.
mmenke 2013/11/01 19:06:39 nit: --We
akalin 2013/11/01 23:15:51 Done.
+ RequestPriority priority = request->priority();
+ if (request->ignore_limits()) {
+ // Put requests with ignore_limits == true (which should have
+ // priority == MAXIMUM_PRIORITY) ahead of other requests with
+ // MAXIMUM_PRIORITY.
+ DCHECK_EQ(priority, MAXIMUM_PRIORITY);
+ pending_requests_.InsertAtFront(request.release(), priority);
+ } else {
+ pending_requests_.Insert(request.release(), priority);
+ }
}
scoped_ptr<const ClientSocketPoolBaseHelper::Request>

Powered by Google App Engine
This is Rietveld 408576698