diff options
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/browser/quota/quota_manager.cc | 12 | ||||
-rw-r--r-- | webkit/browser/quota/quota_manager.h | 2 | ||||
-rw-r--r-- | webkit/browser/quota/quota_manager_unittest.cc | 11 |
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) { |