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

Unified Diff: net/url_request/url_request.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: Rebase onto 51953002 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/url_request/url_request.cc
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index dae9d0e5339f860eb066eea982ef63061636968e..c1d3956dadfbcb71e9a109416ee40325dd944a1d 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -498,6 +498,20 @@ int URLRequest::GetResponseCode() const {
return job_->GetResponseCode();
}
+void URLRequest::SetLoadFlags(int flags) {
+ if ((load_flags_ & LOAD_IGNORE_LIMITS) != (flags & LOAD_IGNORE_LIMITS)) {
+ DCHECK(!job_);
+ DCHECK(flags & LOAD_IGNORE_LIMITS);
+ DCHECK_EQ(priority_, MAXIMUM_PRIORITY);
+ }
+ load_flags_ = flags;
+
+ // This should be a no-op given the above DCHECKs, but do this
+ // anyway for release mode.
+ if ((load_flags_ & LOAD_IGNORE_LIMITS) != 0)
+ SetPriority(MAXIMUM_PRIORITY);
+}
+
// static
void URLRequest::SetDefaultCookiePolicyToBlock() {
CHECK(!g_url_requests_started);
@@ -960,6 +974,15 @@ int64 URLRequest::GetExpectedContentSize() const {
void URLRequest::SetPriority(RequestPriority priority) {
DCHECK_GE(priority, MINIMUM_PRIORITY);
DCHECK_LE(priority, MAXIMUM_PRIORITY);
+
+ if (((load_flags_ & LOAD_IGNORE_LIMITS) != 0) &&
+ (priority != MAXIMUM_PRIORITY)) {
+ NOTREACHED();
+ // Maintain the invariant that requests with IGNORE_LIMITS set
+ // have MAXIMUM_PRIORITY for release mode.
+ priority = MAXIMUM_PRIORITY;
+ }
+
if (priority_ == priority)
return;

Powered by Google App Engine
This is Rietveld 408576698