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

Unified Diff: android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc

Issue 11419093: [Android WebView] Implement WebSettings.{get|set}CacheMode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
diff --git a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
index b24eb2b56eac50e61bccdadb308a07a74515d6c0..fb5106066a38ceb29343eab595901cccea857fc8 100644
--- a/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
+++ b/android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.cc
@@ -37,12 +37,13 @@ void SetOnlyAllowLoadFromCache(
request->set_load_flags(load_flags);
}
-// May cancel this resource request based on result of Java callbacks.
-class MaybeCancelResourceThrottle : public content::ResourceThrottle {
+// Enqueries certain WebSettings values, sets up the resource request
+// accordingly. May cancel the request.
+class ApplyWebSettingsResourceThrottle : public content::ResourceThrottle {
public:
- MaybeCancelResourceThrottle(int child_id,
- int route_id,
- net::URLRequest* request)
+ ApplyWebSettingsResourceThrottle(int child_id,
+ int route_id,
+ net::URLRequest* request)
: child_id_(child_id),
route_id_(route_id),
request_(request) { }
@@ -58,7 +59,7 @@ class MaybeCancelResourceThrottle : public content::ResourceThrottle {
net::URLRequest* request_;
};
-void MaybeCancelResourceThrottle::WillStartRequest(bool* defer) {
+void ApplyWebSettingsResourceThrottle::WillStartRequest(bool* defer) {
// If there is no IO thread client set at this point, use a
// restrictive policy. This can happen for blocked popup
// windows for example.
@@ -71,6 +72,25 @@ void MaybeCancelResourceThrottle::WillStartRequest(bool* defer) {
return;
}
+ AwContentsIoThreadClient::CacheMode cache_mode =
+ GetIoThreadClient()->GetCacheMode();
+ int load_flags = request_->load_flags();
+ switch(cache_mode) {
+ case AwContentsIoThreadClient::LOAD_CACHE_ELSE_NETWORK:
+ load_flags |= net::LOAD_PREFERRING_CACHE;
+ load_flags &= ~net::LOAD_VALIDATE_CACHE;
+ break;
+ case AwContentsIoThreadClient::LOAD_NO_CACHE:
+ load_flags |= net::LOAD_BYPASS_CACHE;
+ break;
+ case AwContentsIoThreadClient::LOAD_CACHE_ONLY:
+ load_flags |= net::LOAD_ONLY_FROM_CACHE;
+ break;
+ default:
+ break;
+ }
+ request_->set_load_flags(load_flags);
boliu 2012/11/20 20:00:09 nit: Let's do better than existing code. I think t
mnaganov (inactive) 2012/11/21 10:37:08 Done. BTW, there was an error in SetOnlyAllowLoadF
+
// Part of implementation of WebSettings.allowContentAccess.
if (request_->url().SchemeIs(android_webview::kContentScheme) &&
GetIoThreadClient()->ShouldBlockContentUrls()) {
@@ -127,7 +147,7 @@ void AwResourceDispatcherHostDelegate::RequestBeginning(
bool is_continuation_of_transferred_request,
ScopedVector<content::ResourceThrottle>* throttles) {
- throttles->push_back(new MaybeCancelResourceThrottle(
+ throttles->push_back(new ApplyWebSettingsResourceThrottle(
child_id, route_id, request));
if (resource_type == ResourceType::MAIN_FRAME) {

Powered by Google App Engine
This is Rietveld 408576698