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

Side by Side Diff: android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc

Issue 2398613002: [HttpCache] LOAD_ONLY_FROM_CACHE should not imply LOAD_PREFERRING_CACHE (Closed)
Patch Set: Always check vary Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/threat_details_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h" 5 #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_dele gate.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "android_webview/browser/aw_browser_context.h" 10 #include "android_webview/browser/aw_browser_context.h"
(...skipping 23 matching lines...) Expand all
34 using content::ResourceType; 34 using content::ResourceType;
35 using navigation_interception::InterceptNavigationDelegate; 35 using navigation_interception::InterceptNavigationDelegate;
36 36
37 namespace { 37 namespace {
38 38
39 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate> 39 base::LazyInstance<android_webview::AwResourceDispatcherHostDelegate>
40 g_webview_resource_dispatcher_host_delegate = LAZY_INSTANCE_INITIALIZER; 40 g_webview_resource_dispatcher_host_delegate = LAZY_INSTANCE_INITIALIZER;
41 41
42 void SetCacheControlFlag( 42 void SetCacheControlFlag(
43 net::URLRequest* request, int flag) { 43 net::URLRequest* request, int flag) {
44 const int all_cache_control_flags = net::LOAD_BYPASS_CACHE | 44 const int all_cache_control_flags =
45 net::LOAD_VALIDATE_CACHE | 45 net::LOAD_BYPASS_CACHE | net::LOAD_VALIDATE_CACHE |
46 net::LOAD_PREFERRING_CACHE | 46 net::LOAD_SKIP_CACHE_VALIDATION | net::LOAD_ONLY_FROM_CACHE;
47 net::LOAD_ONLY_FROM_CACHE;
48 DCHECK_EQ((flag & all_cache_control_flags), flag); 47 DCHECK_EQ((flag & all_cache_control_flags), flag);
49 int load_flags = request->load_flags(); 48 int load_flags = request->load_flags();
50 load_flags &= ~all_cache_control_flags; 49 load_flags &= ~all_cache_control_flags;
51 load_flags |= flag; 50 load_flags |= flag;
52 request->SetLoadFlags(load_flags); 51 request->SetLoadFlags(load_flags);
53 } 52 }
54 53
55 } // namespace 54 } // namespace
56 55
57 namespace android_webview { 56 namespace android_webview {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (request_->url().SchemeIsFile() && 169 if (request_->url().SchemeIsFile() &&
171 io_client->ShouldBlockFileUrls()) { 170 io_client->ShouldBlockFileUrls()) {
172 // Application's assets and resources are always available. 171 // Application's assets and resources are always available.
173 return !IsAndroidSpecialFileUrl(request_->url()); 172 return !IsAndroidSpecialFileUrl(request_->url());
174 } 173 }
175 174
176 if (io_client->ShouldBlockNetworkLoads()) { 175 if (io_client->ShouldBlockNetworkLoads()) {
177 if (request_->url().SchemeIs(url::kFtpScheme)) { 176 if (request_->url().SchemeIs(url::kFtpScheme)) {
178 return true; 177 return true;
179 } 178 }
180 SetCacheControlFlag(request_, net::LOAD_ONLY_FROM_CACHE); 179 SetCacheControlFlag(
180 request_, net::LOAD_ONLY_FROM_CACHE | net::LOAD_SKIP_CACHE_VALIDATION);
181 } else { 181 } else {
182 AwContentsIoThreadClient::CacheMode cache_mode = io_client->GetCacheMode(); 182 AwContentsIoThreadClient::CacheMode cache_mode = io_client->GetCacheMode();
183 switch(cache_mode) { 183 switch(cache_mode) {
184 case AwContentsIoThreadClient::LOAD_CACHE_ELSE_NETWORK: 184 case AwContentsIoThreadClient::LOAD_CACHE_ELSE_NETWORK:
185 SetCacheControlFlag(request_, net::LOAD_PREFERRING_CACHE); 185 SetCacheControlFlag(request_, net::LOAD_SKIP_CACHE_VALIDATION);
186 break; 186 break;
187 case AwContentsIoThreadClient::LOAD_NO_CACHE: 187 case AwContentsIoThreadClient::LOAD_NO_CACHE:
188 SetCacheControlFlag(request_, net::LOAD_BYPASS_CACHE); 188 SetCacheControlFlag(request_, net::LOAD_BYPASS_CACHE);
189 break; 189 break;
190 case AwContentsIoThreadClient::LOAD_CACHE_ONLY: 190 case AwContentsIoThreadClient::LOAD_CACHE_ONLY:
191 SetCacheControlFlag(request_, net::LOAD_ONLY_FROM_CACHE); 191 SetCacheControlFlag(request_, net::LOAD_ONLY_FROM_CACHE |
192 net::LOAD_SKIP_CACHE_VALIDATION);
192 break; 193 break;
193 default: 194 default:
194 break; 195 break;
195 } 196 }
196 } 197 }
197 return false; 198 return false;
198 } 199 }
199 200
200 // static 201 // static
201 void AwResourceDispatcherHostDelegate::ResourceDispatcherHostCreated() { 202 void AwResourceDispatcherHostDelegate::ResourceDispatcherHostCreated() {
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 net::HttpRequestHeaders headers; 444 net::HttpRequestHeaders headers;
444 headers.AddHeadersFromString(extra_headers); 445 headers.AddHeadersFromString(extra_headers);
445 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) { 446 for (net::HttpRequestHeaders::Iterator it(headers); it.GetNext(); ) {
446 request->SetExtraRequestHeaderByName(it.name(), it.value(), false); 447 request->SetExtraRequestHeaderByName(it.name(), it.value(), false);
447 } 448 }
448 } 449 }
449 } 450 }
450 } 451 }
451 452
452 } // namespace android_webview 453 } // namespace android_webview
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/threat_details_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698