Commit ef0fdeea authored by Gyuyoung Kim's avatar Gyuyoung Kim Committed by Commit Bot

Pass the maximium disk cache size of appcache in the command line to appcache thread

Embedded devices have limited storage capacity generally. So current maximum disk
cache size(250MB) can make their storage fully used in the embedded devices.
For the embedder, it would be good if we give the power them to set the maximum
disk cache size through the command line.

Bug: 824619
Change-Id: Ib4fae34934eadf23f1165907b5c547fff205b827
Reviewed-on: https://chromium-review.googlesource.com/974804Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Gyuyoung Kim <gyuyoung.kim@lge.com>
Cr-Commit-Position: refs/heads/master@{#545010}
parent f6b7edeb
......@@ -14,11 +14,13 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
......@@ -30,6 +32,7 @@
#include "content/browser/appcache/appcache_quota_client.h"
#include "content/browser/appcache/appcache_response.h"
#include "content/browser/appcache/appcache_service_impl.h"
#include "content/public/common/content_switches.h"
#include "net/base/cache_type.h"
#include "net/base/net_errors.h"
#include "sql/connection.h"
......@@ -41,11 +44,13 @@
namespace content {
const int kMB = 1024 * 1024;
// Hard coded default when not using quota management.
static const int kDefaultQuota = 5 * 1024 * 1024;
static const int kDefaultQuota = 5 * kMB;
static const int kMaxAppCacheDiskCacheSize = 250 * 1024 * 1024;
static const int kMaxAppCacheMemDiskCacheSize = 10 * 1024 * 1024;
static const int kMaxAppCacheDiskCacheSize = 250 * kMB;
static const int kMaxAppCacheMemDiskCacheSize = 10 * kMB;
static const base::FilePath::CharType kDiskCacheDirectoryName[] =
FILE_PATH_LITERAL("Cache");
......@@ -1869,9 +1874,21 @@ AppCacheDiskCache* AppCacheStorageImpl::disk_cache() {
base::Unretained(this)));
} else {
expecting_cleanup_complete_on_disable_ = true;
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
unsigned int max_appcache_disk_cache_size = kMaxAppCacheDiskCacheSize;
if (command_line.HasSwitch(switches::kMaxAppCacheDiskCacheSizeMb)) {
if (base::StringToUint(command_line.GetSwitchValueASCII(
switches::kMaxAppCacheDiskCacheSizeMb),
&max_appcache_disk_cache_size)) {
max_appcache_disk_cache_size *= kMB;
}
}
rv = disk_cache_->InitWithDiskBackend(
cache_directory_.Append(kDiskCacheDirectoryName),
kMaxAppCacheDiskCacheSize, false,
max_appcache_disk_cache_size, false,
base::BindOnce(&AppCacheStorageImpl::OnDiskCacheCleanupComplete,
weak_factory_.GetWeakPtr()),
base::Bind(&AppCacheStorageImpl::OnDiskCacheInitialized,
......
......@@ -574,6 +574,10 @@ const char kLogFile[] = "log-file";
const char kMainFrameResizesAreOrientationChanges[] =
"main-frame-resizes-are-orientation-changes";
// Specifies the maximum disk cache size for the ApplicationCache. Default
// value is 250MB.
const char kMaxAppCacheDiskCacheSizeMb[] = "max-appcache-disk-cache-size-mb";
// Sets the width and height above which a composited layer will get tiled.
const char kMaxUntiledLayerHeight[] = "max-untiled-layer-height";
const char kMaxUntiledLayerWidth[] = "max-untiled-layer-width";
......
......@@ -171,6 +171,7 @@ CONTENT_EXPORT extern const char kLogGpuControlListDecisions[];
CONTENT_EXPORT extern const char kLoggingLevel[];
CONTENT_EXPORT extern const char kLogFile[];
CONTENT_EXPORT extern const char kMainFrameResizesAreOrientationChanges[];
extern const char kMaxAppCacheDiskCacheSizeMb[];
extern const char kMaxUntiledLayerHeight[];
extern const char kMaxUntiledLayerWidth[];
CONTENT_EXPORT extern const char kMessageLoopTypeUi[];
......
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