diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-18 01:52:46 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-18 01:52:46 +0000 |
commit | 2a2248971a73352589e184db43e81db808e72803 (patch) | |
tree | 4c9c1a28c46ec66e391d5f16d9bed33324281476 /webkit | |
parent | 420fb56759f0ac2d0291ea47397ffb7eb87ade04 (diff) | |
download | chromium_src-2a2248971a73352589e184db43e81db808e72803.zip chromium_src-2a2248971a73352589e184db43e81db808e72803.tar.gz chromium_src-2a2248971a73352589e184db43e81db808e72803.tar.bz2 |
Rename SpecialStoragePolicy::IsInstalledApp() to CanQueryDiskSize()
To fix layering leakage issue.
BUG=none
TEST=existing tests
Review URL: https://codereview.chromium.org/14237003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194748 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/quota/mock_special_storage_policy.cc | 4 | ||||
-rw-r--r-- | webkit/quota/mock_special_storage_policy.h | 10 | ||||
-rw-r--r-- | webkit/quota/quota_manager.cc | 19 | ||||
-rw-r--r-- | webkit/quota/quota_manager.h | 4 | ||||
-rw-r--r-- | webkit/quota/quota_manager_unittest.cc | 6 | ||||
-rw-r--r-- | webkit/quota/special_storage_policy.h | 5 |
6 files changed, 25 insertions, 23 deletions
diff --git a/webkit/quota/mock_special_storage_policy.cc b/webkit/quota/mock_special_storage_policy.cc index 340e169..5aaf21c 100644 --- a/webkit/quota/mock_special_storage_policy.cc +++ b/webkit/quota/mock_special_storage_policy.cc @@ -24,8 +24,8 @@ bool MockSpecialStoragePolicy::IsStorageSessionOnly(const GURL& origin) { return session_only_.find(origin) != session_only_.end(); } -bool MockSpecialStoragePolicy::IsInstalledApp(const GURL& origin) { - return installed_.find(origin) != installed_.end(); +bool MockSpecialStoragePolicy::CanQueryDiskSize(const GURL& origin) { + return can_query_disk_size_.find(origin) != can_query_disk_size_.end(); } bool MockSpecialStoragePolicy::IsFileHandler(const std::string& extension_id) { diff --git a/webkit/quota/mock_special_storage_policy.h b/webkit/quota/mock_special_storage_policy.h index ed8d2ec..3a7fcb9 100644 --- a/webkit/quota/mock_special_storage_policy.h +++ b/webkit/quota/mock_special_storage_policy.h @@ -20,7 +20,7 @@ class MockSpecialStoragePolicy : public quota::SpecialStoragePolicy { virtual bool IsStorageProtected(const GURL& origin) OVERRIDE; virtual bool IsStorageUnlimited(const GURL& origin) OVERRIDE; virtual bool IsStorageSessionOnly(const GURL& origin) OVERRIDE; - virtual bool IsInstalledApp(const GURL& origin) OVERRIDE; + virtual bool CanQueryDiskSize(const GURL& origin) OVERRIDE; virtual bool IsFileHandler(const std::string& extension_id) OVERRIDE; virtual bool HasSessionOnlyOrigins() OVERRIDE; @@ -36,8 +36,8 @@ class MockSpecialStoragePolicy : public quota::SpecialStoragePolicy { session_only_.insert(origin); } - void AddInstalledApp(const GURL& origin) { - installed_.insert(origin); + void GrantQueryDiskSize(const GURL& origin) { + can_query_disk_size_.insert(origin); } void AddFileHandler(const std::string& id) { @@ -52,7 +52,7 @@ class MockSpecialStoragePolicy : public quota::SpecialStoragePolicy { protected_.clear(); unlimited_.clear(); session_only_.clear(); - installed_.clear(); + can_query_disk_size_.clear(); file_handlers_.clear(); all_unlimited_ = false; } @@ -68,7 +68,7 @@ class MockSpecialStoragePolicy : public quota::SpecialStoragePolicy { std::set<GURL> protected_; std::set<GURL> unlimited_; std::set<GURL> session_only_; - std::set<GURL> installed_; + std::set<GURL> can_query_disk_size_; std::set<std::string> file_handlers_; bool all_unlimited_; diff --git a/webkit/quota/quota_manager.cc b/webkit/quota/quota_manager.cc index 2c810a7..93462ce 100644 --- a/webkit/quota/quota_manager.cc +++ b/webkit/quota/quota_manager.cc @@ -185,7 +185,7 @@ const int QuotaManager::kEvictionIntervalInMilliSeconds = // and by multiple apps. int64 QuotaManager::kSyncableStorageDefaultHostQuota = 500 * kMBytes; -int64 CalculateQuotaForInstalledApp( +int64 CalculateQuotaWithDiskSpace( int64 available_disk_space, int64 usage, int64 quota) { if (available_disk_space < QuotaManager::kMinimumPreserveForSystem || quota < usage) { @@ -204,15 +204,15 @@ int64 CalculateQuotaForInstalledApp( void CallGetUsageAndQuotaCallback( const QuotaManager::GetUsageAndQuotaCallback& callback, bool unlimited, - bool is_installed_app, + bool can_query_disk_size, QuotaStatusCode status, const QuotaAndUsage& quota_and_usage) { // Regular limited case. if (!unlimited) { - if (is_installed_app) { + if (can_query_disk_size) { // Cap the quota by the available disk space. callback.Run(status, quota_and_usage.usage, - CalculateQuotaForInstalledApp( + CalculateQuotaWithDiskSpace( quota_and_usage.available_disk_space, quota_and_usage.usage, quota_and_usage.quota)); @@ -224,11 +224,12 @@ void CallGetUsageAndQuotaCallback( int64 usage = quota_and_usage.unlimited_usage; - // Unlimited case: this must be only for installed-app and extensions, + // Unlimited case: this must be only for apps with unlimitedStorage permission // or only when --unlimited-storage flag is given. - // We return the available disk space (minus kMinimumPreserveForSystem). + // We assume we can expose the disk size for them and return the available + // disk space (minus kMinimumPreserveForSystem). callback.Run(status, usage, - CalculateQuotaForInstalledApp( + CalculateQuotaWithDiskSpace( quota_and_usage.available_disk_space, usage, QuotaManager::kNoLimit)); } @@ -967,7 +968,7 @@ void QuotaManager::GetUsageAndQuotaForWebApps( GetUsageAndQuotaInternal( origin, type, false /* global */, base::Bind(&CallGetUsageAndQuotaCallback, callback, - IsStorageUnlimited(origin, type), IsInstalledApp(origin))); + IsStorageUnlimited(origin, type), CanQueryDiskSize(origin))); } void QuotaManager::GetUsageAndQuota( @@ -977,7 +978,7 @@ void QuotaManager::GetUsageAndQuota( if (IsStorageUnlimited(origin, type)) { CallGetUsageAndQuotaCallback( - callback, false, IsInstalledApp(origin), + callback, false, CanQueryDiskSize(origin), kQuotaStatusOk, QuotaAndUsage::CreateForUnlimitedStorage()); return; } diff --git a/webkit/quota/quota_manager.h b/webkit/quota/quota_manager.h index 8bcaae5..a5f0fe2 100644 --- a/webkit/quota/quota_manager.h +++ b/webkit/quota/quota_manager.h @@ -202,9 +202,9 @@ class WEBKIT_STORAGE_EXPORT QuotaManager bool IsStorageUnlimited(const GURL& origin, StorageType type) const; - bool IsInstalledApp(const GURL& origin) const { + bool CanQueryDiskSize(const GURL& origin) const { return special_storage_policy_.get() && - special_storage_policy_->IsInstalledApp(origin); + special_storage_policy_->CanQueryDiskSize(origin); } virtual void GetOriginsModifiedSince(StorageType type, diff --git a/webkit/quota/quota_manager_unittest.cc b/webkit/quota/quota_manager_unittest.cc index 8ed9759..94efa8b 100644 --- a/webkit/quota/quota_manager_unittest.cc +++ b/webkit/quota/quota_manager_unittest.cc @@ -631,7 +631,7 @@ TEST_F(QuotaManagerTest, GetUsage_MultipleClients) { { "http://installed/", kTemp, 1024 }, }; mock_special_storage_policy()->AddUnlimited(GURL("http://unlimited/")); - mock_special_storage_policy()->AddInstalledApp(GURL("http://installed/")); + mock_special_storage_policy()->GrantQueryDiskSize(GURL("http://installed/")); RegisterClient(CreateClient(kData1, ARRAYSIZE_UNSAFE(kData1), QuotaClient::kFileSystem)); RegisterClient(CreateClient(kData2, ARRAYSIZE_UNSAFE(kData2), @@ -997,7 +997,7 @@ TEST_F(QuotaManagerTest, GetAndSetPersistentUsageAndQuota) { EXPECT_EQ(100, quota()); // For installed app GetUsageAndQuotaForWebApps returns the capped quota. - mock_special_storage_policy()->AddInstalledApp(GURL("http://installed/")); + mock_special_storage_policy()->GrantQueryDiskSize(GURL("http://installed/")); SetPersistentHostQuota("installed", kAvailableSpaceForApp + 100); GetUsageAndQuotaForWebApps(GURL("http://installed/"), kPerm); MessageLoop::current()->RunUntilIdle(); @@ -1027,7 +1027,7 @@ TEST_F(QuotaManagerTest, GetSyncableQuota) { // For installed apps the quota manager should return // kAvailableSpaceForApp as syncable quota (because of the pre-condition). - mock_special_storage_policy()->AddInstalledApp(GURL("http://installed/")); + mock_special_storage_policy()->GrantQueryDiskSize(GURL("http://installed/")); GetUsageAndQuotaForWebApps(GURL("http://installed/"), kSync); MessageLoop::current()->RunUntilIdle(); EXPECT_EQ(kQuotaStatusOk, status()); diff --git a/webkit/quota/special_storage_policy.h b/webkit/quota/special_storage_policy.h index a048f63..a7ceed1 100644 --- a/webkit/quota/special_storage_policy.h +++ b/webkit/quota/special_storage_policy.h @@ -39,8 +39,9 @@ class WEBKIT_STORAGE_EXPORT SpecialStoragePolicy // Unlimited storage is not subject to 'quotas'. virtual bool IsStorageUnlimited(const GURL& origin) = 0; - // Installed apps have access to the size of the remaining disk capacity. - virtual bool IsInstalledApp(const GURL& origin) = 0; + // Some origins (e.g. installed apps) have access to the size of the remaining + // disk capacity. + virtual bool CanQueryDiskSize(const GURL& origin) = 0; // Checks if extension identified with |extension_id| is registered as // file handler. |