Commit 1abfdd58 authored by Torne (Richard Coles)'s avatar Torne (Richard Coles) Committed by Commit Bot

webview: set a webview-specific code cache size.

The HTTP cache in WebView is limited to 20MB but the generated code
caches were being left at the default size automatically calculated
based on disk space, which is typically much larger. Since the source
file needs to be present in the HTTP cache for code cache entries to be
used, it's not useful for the code cache to be so big.

Set the code cache size to 10MB; there are two code caches, so this will
result in a ~40MB cache dir in total; 2x as much as before the code
cache was implemented. This avoids apps complaining that WebView is
using hundreds of megabytes of space in their cache dir (causing users
to complain about the amount of space the app is using).

Bug: 1126485
Change-Id: I44666c0ff745b5f4c43f5776c6177368ee4a6e48
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2404565Reviewed-by: default avatarMythri Alle <mythria@chromium.org>
Reviewed-by: default avatarAnna Malova <amalova@chromium.org>
Commit-Queue: Richard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806175}
parent 162eec0c
......@@ -456,11 +456,14 @@ AwContentBrowserClient::CreateQuotaPermissionContext() {
content::GeneratedCodeCacheSettings
AwContentBrowserClient::GetGeneratedCodeCacheSettings(
content::BrowserContext* context) {
// If we pass 0 for size, disk_cache will pick a default size using the
// heuristics based on available disk size. These are implemented in
// disk_cache::PreferredCacheSize in net/disk_cache/cache_util.cc.
// WebView limits the main HTTP cache to 20MB; we need to set a comparable
// limit for the code cache since the source file needs to be in the HTTP
// cache for the code cache entry to be used. There are two code caches that
// both use this value, so we pass 10MB to keep the total disk usage to
// roughly 2x what it was before the code cache was implemented.
// TODO(crbug/893318): webview should have smarter cache sizing logic.
AwBrowserContext* browser_context = static_cast<AwBrowserContext*>(context);
return content::GeneratedCodeCacheSettings(true, 0,
return content::GeneratedCodeCacheSettings(true, 10 * 1024 * 1024,
browser_context->GetCacheDir());
}
......
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