diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-25 03:52:45 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-25 03:52:45 +0000 |
commit | 4fd2eee382a133a5eeca0fd46e69069eaa5976f1 (patch) | |
tree | a0c23b89c99ec800567c38b03efc40364d8b31c5 /webkit/quota | |
parent | 13114c26c5a3e8232d21b9bccd9c625a596eef28 (diff) | |
download | chromium_src-4fd2eee382a133a5eeca0fd46e69069eaa5976f1.zip chromium_src-4fd2eee382a133a5eeca0fd46e69069eaa5976f1.tar.gz chromium_src-4fd2eee382a133a5eeca0fd46e69069eaa5976f1.tar.bz2 |
Cap the quota by the actual available space for installed apps
Currently we only do this for apps with unlimitedStorage permission.
BUG=223425
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/13009013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190335 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/quota')
-rw-r--r-- | webkit/quota/quota_manager.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/webkit/quota/quota_manager.cc b/webkit/quota/quota_manager.cc index 779e5530..aece68f 100644 --- a/webkit/quota/quota_manager.cc +++ b/webkit/quota/quota_manager.cc @@ -185,18 +185,18 @@ const int QuotaManager::kEvictionIntervalInMilliSeconds = // and by multiple apps. int64 QuotaManager::kSyncableStorageDefaultHostQuota = 500 * kMBytes; -int64 CalculateQuotaForUnlimitedInstalledApp( - int64 available_disk_space, int64 usage) { +int64 CalculateQuotaForInstalledApp( + int64 available_disk_space, int64 usage, int64 quota) { if (available_disk_space < QuotaManager::kMinimumPreserveForSystem) { // No more space; cap the quota to the current usage. return usage; } available_disk_space -= QuotaManager::kMinimumPreserveForSystem; - if (available_disk_space < kint64max - usage) + if (available_disk_space < quota - usage) return available_disk_space + usage; - return kint64max; + return quota; } // Callback translators. @@ -208,6 +208,15 @@ void CallGetUsageAndQuotaCallback( const QuotaAndUsage& quota_and_usage) { // Regular limited case. if (!unlimited) { + if (is_installed_app) { + // Cap the quota by the available disk space. + callback.Run(status, quota_and_usage.usage, + CalculateQuotaForInstalledApp( + quota_and_usage.available_disk_space, + quota_and_usage.usage, + quota_and_usage.quota)); + return; + } callback.Run(status, quota_and_usage.usage, quota_and_usage.quota); return; } @@ -225,8 +234,9 @@ void CallGetUsageAndQuotaCallback( // For installed unlimited apps. callback.Run(status, usage, - CalculateQuotaForUnlimitedInstalledApp( - quota_and_usage.available_disk_space, usage)); + CalculateQuotaForInstalledApp( + quota_and_usage.available_disk_space, + usage, QuotaManager::kNoLimit)); } void CallQuotaCallback( |