Commit 4a0206d9 authored by Nate Fischer's avatar Nate Fischer Committed by Commit Bot

AW: refactor cache size into a getter method.

No change to behavior, this only moves the value into a getter method
for both code paths.

This moves the cache size to a centrally-determined spot, since we may
want to create more complex logic for the value we set.

R=changwan@chromium.org

Bug: 893318,887538
Test: None
Change-Id: I0e22928bc37a247f165e3913b1e7007fa0d7a1f3
Reviewed-on: https://chromium-review.googlesource.com/c/1357331Reviewed-by: default avatarChangwan Ryu <changwan@chromium.org>
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613212}
parent a378c4d3
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "android_webview/browser/aw_url_checker_delegate_impl.h" #include "android_webview/browser/aw_url_checker_delegate_impl.h"
#include "android_webview/browser/aw_web_contents_view_delegate.h" #include "android_webview/browser/aw_web_contents_view_delegate.h"
#include "android_webview/browser/net/aw_url_request_context_getter.h" #include "android_webview/browser/net/aw_url_request_context_getter.h"
#include "android_webview/browser/net_helpers.h"
#include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h" #include "android_webview/browser/renderer_host/aw_resource_dispatcher_host_delegate.h"
#include "android_webview/browser/tracing/aw_tracing_delegate.h" #include "android_webview/browser/tracing/aw_tracing_delegate.h"
#include "android_webview/common/aw_content_client.h" #include "android_webview/common/aw_content_client.h"
...@@ -269,7 +270,7 @@ network::mojom::NetworkContextPtr AwContentBrowserClient::CreateNetworkContext( ...@@ -269,7 +270,7 @@ network::mojom::NetworkContextPtr AwContentBrowserClient::CreateNetworkContext(
context_params->enable_data_url_support = true; context_params->enable_data_url_support = true;
context_params->http_cache_enabled = true; context_params->http_cache_enabled = true;
context_params->http_cache_max_size = 20 * 1024 * 1024; // 20M context_params->http_cache_max_size = GetHttpCacheSize();
context_params->http_cache_path = AwBrowserContext::GetCacheDir(); context_params->http_cache_path = AwBrowserContext::GetCacheDir();
// WebView does not currently support Certificate Transparency. // WebView does not currently support Certificate Transparency.
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "android_webview/browser/net/aw_url_request_job_factory.h" #include "android_webview/browser/net/aw_url_request_job_factory.h"
#include "android_webview/browser/net/init_native_callback.h" #include "android_webview/browser/net/init_native_callback.h"
#include "android_webview/browser/net/token_binding_manager.h" #include "android_webview/browser/net/token_binding_manager.h"
#include "android_webview/browser/net_helpers.h"
#include "android_webview/common/aw_content_client.h" #include "android_webview/common/aw_content_client.h"
#include "base/base_paths_android.h" #include "base/base_paths_android.h"
#include "base/bind.h" #include "base/bind.h"
...@@ -324,7 +325,7 @@ void AwURLRequestContextGetter::InitializeURLRequestContext() { ...@@ -324,7 +325,7 @@ void AwURLRequestContextGetter::InitializeURLRequestContext() {
base::FeatureList::IsEnabled(network::features::kNetworkService) base::FeatureList::IsEnabled(network::features::kNetworkService)
? net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY ? net::URLRequestContextBuilder::HttpCacheParams::IN_MEMORY
: net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE; : net::URLRequestContextBuilder::HttpCacheParams::DISK_SIMPLE;
cache_params.max_size = 20 * 1024 * 1024; // 20M cache_params.max_size = GetHttpCacheSize();
cache_params.path = cache_path_; cache_params.path = cache_path_;
builder.EnableHttpCache(cache_params); builder.EnableHttpCache(cache_params);
......
...@@ -32,4 +32,11 @@ int GetCacheModeForClient(AwContentsIoThreadClient* client) { ...@@ -32,4 +32,11 @@ int GetCacheModeForClient(AwContentsIoThreadClient* client) {
} }
} }
int GetHttpCacheSize() {
// This currently returns a constant value, but we may consider deciding cache
// size dynamically, since Android provides better support on newer versions
// (http://crbug.com/893318).
return 20 * 1024 * 1024; // 20M
}
} // namespace android_webview } // namespace android_webview
...@@ -14,6 +14,10 @@ class AwContentsIoThreadClient; ...@@ -14,6 +14,10 @@ class AwContentsIoThreadClient;
// Gets the net-layer load_flags which reflect |client|'s cache mode. // Gets the net-layer load_flags which reflect |client|'s cache mode.
int GetCacheModeForClient(AwContentsIoThreadClient* client); int GetCacheModeForClient(AwContentsIoThreadClient* client);
// Determines the desired size for WebView's on-disk HttpCache, measured in
// Bytes.
int GetHttpCacheSize();
} // namespace android_webview } // namespace android_webview
#endif // ANDROID_WEBVIEW_BROWSER_NET_HELPERS_H_ #endif // ANDROID_WEBVIEW_BROWSER_NET_HELPERS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment