OLD | NEW |
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 Loading... |
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); |
| 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 Loading... |
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) && (priority != MAXIMUM_PRIORITY)) { |
| 979 NOTREACHED(); |
| 980 // Maintain the invariant that requests with IGNORE_LIMITS set |
| 981 // have MAXIMUM_PRIORITY for release mode. |
| 982 return; |
| 983 } |
| 984 |
963 if (priority_ == priority) | 985 if (priority_ == priority) |
964 return; | 986 return; |
965 | 987 |
966 priority_ = priority; | 988 priority_ = priority; |
967 if (job_.get()) { | 989 if (job_.get()) { |
968 net_log_.AddEvent(NetLog::TYPE_URL_REQUEST_SET_PRIORITY, | 990 net_log_.AddEvent(NetLog::TYPE_URL_REQUEST_SET_PRIORITY, |
969 NetLog::IntegerCallback("priority", priority_)); | 991 NetLog::IntegerCallback("priority", priority_)); |
970 job_->SetPriority(priority_); | 992 job_->SetPriority(priority_); |
971 } | 993 } |
972 } | 994 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1159 new base::debug::StackTrace(NULL, 0); | 1181 new base::debug::StackTrace(NULL, 0); |
1160 *stack_trace_copy = stack_trace; | 1182 *stack_trace_copy = stack_trace; |
1161 stack_trace_.reset(stack_trace_copy); | 1183 stack_trace_.reset(stack_trace_copy); |
1162 } | 1184 } |
1163 | 1185 |
1164 const base::debug::StackTrace* URLRequest::stack_trace() const { | 1186 const base::debug::StackTrace* URLRequest::stack_trace() const { |
1165 return stack_trace_.get(); | 1187 return stack_trace_.get(); |
1166 } | 1188 } |
1167 | 1189 |
1168 } // namespace net | 1190 } // namespace net |
OLD | NEW |