| 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) != 0) && |
| 979 (priority != MAXIMUM_PRIORITY)) { |
| 980 NOTREACHED(); |
| 981 // Maintain the invariant that requests with IGNORE_LIMITS set |
| 982 // have MAXIMUM_PRIORITY for release mode. |
| 983 priority = MAXIMUM_PRIORITY; |
| 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 Loading... |
| 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 |
| OLD | NEW |