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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/url_request/url_request.h" 5 #include "net/url_request/url_request.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 void URLRequest::GetCharset(string* charset) { 491 void URLRequest::GetCharset(string* charset) {
492 DCHECK(job_.get()); 492 DCHECK(job_.get());
493 job_->GetCharset(charset); 493 job_->GetCharset(charset);
494 } 494 }
495 495
496 int URLRequest::GetResponseCode() const { 496 int URLRequest::GetResponseCode() const {
497 DCHECK(job_.get()); 497 DCHECK(job_.get());
498 return job_->GetResponseCode(); 498 return job_->GetResponseCode();
499 } 499 }
500 500
501 void URLRequest::SetLoadFlags(int flags) {
502 if ((load_flags_ & LOAD_IGNORE_LIMITS) != (flags & LOAD_IGNORE_LIMITS)) {
503 DCHECK(!job_);
504 DCHECK(flags & LOAD_IGNORE_LIMITS);
mmenke 2013/11/01 19:06:39 So the IGNORE_LIMITS flag can be set, but not unse
akalin 2013/11/01 23:15:51 It's fine, but the only use case doesn't ever clea
505 DCHECK_EQ(priority_, MAXIMUM_PRIORITY);
506 }
507 load_flags_ = flags;
508
509 // This should be a no-op given the above DCHECKs, but do this
510 // anyway for release mode.
511 if ((load_flags_ & LOAD_IGNORE_LIMITS) != 0)
512 SetPriority(MAXIMUM_PRIORITY);
513 }
514
501 // static 515 // static
502 void URLRequest::SetDefaultCookiePolicyToBlock() { 516 void URLRequest::SetDefaultCookiePolicyToBlock() {
503 CHECK(!g_url_requests_started); 517 CHECK(!g_url_requests_started);
504 g_default_can_use_cookies = false; 518 g_default_can_use_cookies = false;
505 } 519 }
506 520
507 // static 521 // static
508 bool URLRequest::IsHandledProtocol(const std::string& scheme) { 522 bool URLRequest::IsHandledProtocol(const std::string& scheme) {
509 return URLRequestJobManager::GetInstance()->SupportsScheme(scheme); 523 return URLRequestJobManager::GetInstance()->SupportsScheme(scheme);
510 } 524 }
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 int64 expected_content_size = -1; 967 int64 expected_content_size = -1;
954 if (job_.get()) 968 if (job_.get())
955 expected_content_size = job_->expected_content_size(); 969 expected_content_size = job_->expected_content_size();
956 970
957 return expected_content_size; 971 return expected_content_size;
958 } 972 }
959 973
960 void URLRequest::SetPriority(RequestPriority priority) { 974 void URLRequest::SetPriority(RequestPriority priority) {
961 DCHECK_GE(priority, MINIMUM_PRIORITY); 975 DCHECK_GE(priority, MINIMUM_PRIORITY);
962 DCHECK_LE(priority, MAXIMUM_PRIORITY); 976 DCHECK_LE(priority, MAXIMUM_PRIORITY);
977
978 if (((load_flags_ & LOAD_IGNORE_LIMITS) != 0) &&
mmenke 2013/11/01 19:06:39 optional nit: Think !(load_flags_ & LOAD_IGNORE_L
akalin 2013/11/01 23:15:51 Done.
979 (priority != MAXIMUM_PRIORITY)) {
mmenke 2013/11/01 19:06:39 nit: Parens not needed.
akalin 2013/11/01 23:15:51 Not needed, but I think it's clearer.
980 NOTREACHED();
981 // Maintain the invariant that requests with IGNORE_LIMITS set
982 // have MAXIMUM_PRIORITY for release mode.
983 priority = MAXIMUM_PRIORITY;
mmenke 2013/11/01 19:06:39 optional nit: In this case, priority_ will now be
akalin 2013/11/01 23:15:51 Done.
984 }
985
963 if (priority_ == priority) 986 if (priority_ == priority)
964 return; 987 return;
965 988
966 priority_ = priority; 989 priority_ = priority;
967 if (job_.get()) { 990 if (job_.get()) {
968 net_log_.AddEvent(NetLog::TYPE_URL_REQUEST_SET_PRIORITY, 991 net_log_.AddEvent(NetLog::TYPE_URL_REQUEST_SET_PRIORITY,
969 NetLog::IntegerCallback("priority", priority_)); 992 NetLog::IntegerCallback("priority", priority_));
970 job_->SetPriority(priority_); 993 job_->SetPriority(priority_);
971 } 994 }
972 } 995 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 new base::debug::StackTrace(NULL, 0); 1182 new base::debug::StackTrace(NULL, 0);
1160 *stack_trace_copy = stack_trace; 1183 *stack_trace_copy = stack_trace;
1161 stack_trace_.reset(stack_trace_copy); 1184 stack_trace_.reset(stack_trace_copy);
1162 } 1185 }
1163 1186
1164 const base::debug::StackTrace* URLRequest::stack_trace() const { 1187 const base::debug::StackTrace* URLRequest::stack_trace() const {
1165 return stack_trace_.get(); 1188 return stack_trace_.get();
1166 } 1189 }
1167 1190
1168 } // namespace net 1191 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698