summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authornhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-06 10:10:07 +0000
committernhiroki@chromium.org <nhiroki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-06 10:10:07 +0000
commitb83d04825b8c8d95eb4e3ca857e1c31c166d0970 (patch)
tree9f2ac6bcb3378f9baf930a45146c36583df164aa /webkit
parent5feea69045b274708422543072f7d2ee12767328 (diff)
downloadchromium_src-b83d04825b8c8d95eb4e3ca857e1c31c166d0970.zip
chromium_src-b83d04825b8c8d95eb4e3ca857e1c31c166d0970.tar.gz
chromium_src-b83d04825b8c8d95eb4e3ca857e1c31c166d0970.tar.bz2
Quota: Cap size of requested quota
This change caps size of requested quota as follows: - Temporary quota is capped at the maximum value of int64 (This is an implementation limitation) - Persistent quota is capped at 10GB per host BUG=256288 TEST=content_unittests NOTRY=true Review URL: https://codereview.chromium.org/150903003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@249326 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/browser/quota/quota_manager.cc12
-rw-r--r--webkit/browser/quota/quota_manager.h2
-rw-r--r--webkit/browser/quota/quota_manager_unittest.cc11
3 files changed, 23 insertions, 2 deletions
diff --git a/webkit/browser/quota/quota_manager.cc b/webkit/browser/quota/quota_manager.cc
index 9e9bc3a..a7e466e 100644
--- a/webkit/browser/quota/quota_manager.cc
+++ b/webkit/browser/quota/quota_manager.cc
@@ -55,6 +55,12 @@ const int64 QuotaManager::kNoLimit = kint64max;
const int QuotaManager::kPerHostTemporaryPortion = 5; // 20%
+// Cap size for per-host persistent quota determined by the histogram.
+// This is a bit lax value because the histogram says nothing about per-host
+// persistent storage usage and we determined by global persistent storage
+// usage that is less than 10GB for almost all users.
+const int64 QuotaManager::kPerHostPersistentQuotaLimit = 10 * 1024 * kMBytes;
+
const char QuotaManager::kDatabaseName[] = "QuotaManager";
// Preserve kMinimumPreserveForSystem disk space for system book-keeping
@@ -1038,11 +1044,17 @@ void QuotaManager::SetPersistentHostQuota(const std::string& host,
callback.Run(kQuotaErrorNotSupported, 0);
return;
}
+
if (new_quota < 0) {
callback.Run(kQuotaErrorInvalidModification, -1);
return;
}
+ if (kPerHostPersistentQuotaLimit < new_quota) {
+ // Cap the requested size at the per-host quota limit.
+ new_quota = kPerHostPersistentQuotaLimit;
+ }
+
if (db_disabled_) {
callback.Run(kQuotaErrorInvalidAccess, -1);
return;
diff --git a/webkit/browser/quota/quota_manager.h b/webkit/browser/quota/quota_manager.h
index 064d548..a6eeb83 100644
--- a/webkit/browser/quota/quota_manager.h
+++ b/webkit/browser/quota/quota_manager.h
@@ -229,6 +229,8 @@ class WEBKIT_STORAGE_BROWSER_EXPORT QuotaManager
// utilized by a single host (ie. 5 for 20%).
static const int kPerHostTemporaryPortion;
+ static const int64 kPerHostPersistentQuotaLimit;
+
static const char kDatabaseName[];
static const int64 kMinimumPreserveForSystem;
diff --git a/webkit/browser/quota/quota_manager_unittest.cc b/webkit/browser/quota/quota_manager_unittest.cc
index 9210537..cc70931 100644
--- a/webkit/browser/quota/quota_manager_unittest.cc
+++ b/webkit/browser/quota/quota_manager_unittest.cc
@@ -962,10 +962,17 @@ TEST_F(QuotaManagerTest, GetAndSetPerststentHostQuota) {
GetPersistentHostQuota("foo.com");
SetPersistentHostQuota("foo.com", 200);
GetPersistentHostQuota("foo.com");
- SetPersistentHostQuota("foo.com", 300000000000ll);
+ SetPersistentHostQuota("foo.com", QuotaManager::kPerHostPersistentQuotaLimit);
GetPersistentHostQuota("foo.com");
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(300000000000ll, quota());
+ EXPECT_EQ(QuotaManager::kPerHostPersistentQuotaLimit, quota());
+
+ // Persistent quota should be capped at the per-host quota limit.
+ SetPersistentHostQuota("foo.com",
+ QuotaManager::kPerHostPersistentQuotaLimit + 100);
+ GetPersistentHostQuota("foo.com");
+ base::RunLoop().RunUntilIdle();
+ EXPECT_EQ(QuotaManager::kPerHostPersistentQuotaLimit, quota());
}
TEST_F(QuotaManagerTest, GetAndSetPersistentUsageAndQuota) {