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

Unified Diff: mojo/services/network/url_loader_impl.cc

Issue 1241553003: Update implementation following changes to URLRequest cache mode. (Closed) Base URL: https://github.com/domokit/monet.git@master
Patch Set: Follow review Created 5 years, 5 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
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/services/network/url_loader_impl.cc
diff --git a/mojo/services/network/url_loader_impl.cc b/mojo/services/network/url_loader_impl.cc
index 955a49c2e958484272fd7896de24912b26b723d1..89e64b8922ca1a99b7ba693fa21d2a9eadb9eb04 100644
--- a/mojo/services/network/url_loader_impl.cc
+++ b/mojo/services/network/url_loader_impl.cc
@@ -94,6 +94,16 @@ class UploadDataPipeElementReader : public net::UploadElementReader {
DISALLOW_COPY_AND_ASSIGN(UploadDataPipeElementReader);
};
+bool IsValidCacheMode(int cache_mode) {
+ switch (cache_mode) {
+ case URLRequest::CACHE_MODE_DEFAULT:
+ case URLRequest::CACHE_MODE_BYPASS_CACHE:
+ case URLRequest::CACHE_MODE_ONLY_FROM_CACHE:
+ return true;
+ }
+ return false;
+}
+
} // namespace
// Each body fetcher takes ownership of a net::URLRequest and stream its data
@@ -495,6 +505,12 @@ void URLLoaderImpl::StartInternal(URLRequestPtr request) {
DCHECK(!url_request_);
DCHECK(!redirect_info_);
+ if (!IsValidCacheMode(request->cache_mode)) {
+ // Unknown cache mode. The request must fail.
+ delete this;
+ return;
+ }
+
if (interceptor_index_ >= 0 &&
interceptor_index_ < static_cast<int>(interceptors_.size())) {
interceptors_[interceptor_index_]->InterceptRequest(
@@ -537,10 +553,15 @@ void URLLoaderImpl::StartInternal(URLRequestPtr request) {
new net::ElementsUploadDataStream(element_readers.Pass(), 0)));
}
int load_flags = 0;
- if (request->bypass_cache)
- load_flags |= net::LOAD_BYPASS_CACHE;
- if (request->only_from_cache)
- load_flags |= net::LOAD_ONLY_FROM_CACHE;
+ switch (request->cache_mode) {
+ case URLRequest::CACHE_MODE_DEFAULT:
+ break;
+ case URLRequest::CACHE_MODE_BYPASS_CACHE:
+ load_flags |= net::LOAD_BYPASS_CACHE;
+ case URLRequest::CACHE_MODE_ONLY_FROM_CACHE:
+ load_flags |= net::LOAD_ONLY_FROM_CACHE;
+ break;
+ }
if (load_flags)
url_request_->SetLoadFlags(load_flags);
« no previous file with comments | « DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698