diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-26 00:28:43 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-26 00:28:43 +0000 |
commit | 19eb8015c483fff874bf1eddb80bd26cf4167f33 (patch) | |
tree | be896411dde17d24eb8dbcd67e7b4c5cad2ef1b6 /webkit/appcache | |
parent | f02074331bddc7d89b20e6b3a8fb934e6891207c (diff) | |
download | chromium_src-19eb8015c483fff874bf1eddb80bd26cf4167f33.zip chromium_src-19eb8015c483fff874bf1eddb80bd26cf4167f33.tar.gz chromium_src-19eb8015c483fff874bf1eddb80bd26cf4167f33.tar.bz2 |
Add an accessor for an ExtensionSpecialStoragePolicy to the Profile class
and use it in the extension service, data remover, and storage subsystems.
BUG=52357
TEST=extension_service_unittest.cc
Review URL: http://codereview.chromium.org/6551028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76126 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache')
-rw-r--r-- | webkit/appcache/appcache_service.cc | 5 | ||||
-rw-r--r-- | webkit/appcache/appcache_service.h | 10 | ||||
-rw-r--r-- | webkit/appcache/appcache_storage.cc | 20 | ||||
-rw-r--r-- | webkit/appcache/appcache_storage.h | 10 | ||||
-rw-r--r-- | webkit/appcache/appcache_storage_impl.cc | 10 | ||||
-rw-r--r-- | webkit/appcache/appcache_storage_impl_unittest.cc | 15 |
6 files changed, 26 insertions, 44 deletions
diff --git a/webkit/appcache/appcache_service.cc b/webkit/appcache/appcache_service.cc index 1eb4673..e748434 100644 --- a/webkit/appcache/appcache_service.cc +++ b/webkit/appcache/appcache_service.cc @@ -10,6 +10,7 @@ #include "webkit/appcache/appcache_backend_impl.h" #include "webkit/appcache/appcache_entry.h" #include "webkit/appcache/appcache_storage_impl.h" +#include "webkit/quota/special_storage_policy.h" namespace appcache { @@ -216,6 +217,10 @@ void AppCacheService::DeleteAppCacheGroup(const GURL& manifest_url, helper->Start(); } +void AppCacheService::set_special_storage_policy( + quota::SpecialStoragePolicy* policy) { + special_storage_policy_ = policy; +} void AppCacheService::RegisterBackend( AppCacheBackendImpl* backend_impl) { DCHECK(backends_.find(backend_impl->process_id()) == backends_.end()); diff --git a/webkit/appcache/appcache_service.h b/webkit/appcache/appcache_service.h index 6a0c931..b36951f 100644 --- a/webkit/appcache/appcache_service.h +++ b/webkit/appcache/appcache_service.h @@ -27,6 +27,10 @@ namespace base { class MessageLoopProxy; } +namespace quota { +class SpecialStoragePolicy; +} + namespace appcache { class AppCacheBackendImpl; @@ -95,6 +99,11 @@ class AppCacheService { appcache_policy_ = policy; } + quota::SpecialStoragePolicy* special_storage_policy() const { + return special_storage_policy_.get(); + } + void set_special_storage_policy(quota::SpecialStoragePolicy* policy); + // Each child process in chrome uses a distinct backend instance. // See chrome/browser/AppCacheDispatcherHost. void RegisterBackend(AppCacheBackendImpl* backend_impl); @@ -117,6 +126,7 @@ class AppCacheService { AppCachePolicy* appcache_policy_; scoped_ptr<AppCacheStorage> storage_; + scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy_; PendingAsyncHelpers pending_helpers_; BackendMap backends_; // One 'backend' per child process. // Context for use during cache updates. diff --git a/webkit/appcache/appcache_storage.cc b/webkit/appcache/appcache_storage.cc index 01c18f1..a30088f 100644 --- a/webkit/appcache/appcache_storage.cc +++ b/webkit/appcache/appcache_storage.cc @@ -87,25 +87,5 @@ void AppCacheStorage::LoadResponseInfo( info_load->StartIfNeeded(); } -void AppCacheStorage::SetOriginQuotaInMemory(const GURL& origin, int64 quota) { - DCHECK(quota >= 0); - DCHECK(origin == origin.GetOrigin()); - if (IsSchemeSupported(origin)) - in_memory_quotas_[origin] = quota; -} - -void AppCacheStorage::ResetOriginQuotaInMemory(const GURL& origin) { - DCHECK(origin == origin.GetOrigin()); - in_memory_quotas_.erase(origin); -} - -int64 AppCacheStorage::GetOriginQuotaInMemory(const GURL& origin) { - DCHECK(origin == origin.GetOrigin()); - QuotaMap::const_iterator found = in_memory_quotas_.find(origin); - if (found == in_memory_quotas_.end()) - return -1; - return found->second; -} - } // namespace appcache diff --git a/webkit/appcache/appcache_storage.h b/webkit/appcache/appcache_storage.h index 1d64ef9..1767127 100644 --- a/webkit/appcache/appcache_storage.h +++ b/webkit/appcache/appcache_storage.h @@ -167,11 +167,6 @@ class AppCacheStorage { virtual void PurgeMemory() = 0; - // Maintain a collection of quota overrides in memory. - void SetOriginQuotaInMemory(const GURL& origin, int64 quota); - void ResetOriginQuotaInMemory(const GURL& origin); - int64 GetOriginQuotaInMemory(const GURL& origin); - // Generates unique storage ids for different object types. int64 NewCacheId() { return ++last_cache_id_; @@ -283,11 +278,6 @@ class AppCacheStorage { return ++last_response_id_; } - // Store quotas for extensions in memory, in order to prevent writing a row - // to quota_table_ every time an extention is loaded. - typedef std::map<GURL, int64> QuotaMap; - QuotaMap in_memory_quotas_; - // The last storage id used for different object types. int64 last_cache_id_; int64 last_group_id_; diff --git a/webkit/appcache/appcache_storage_impl.cc b/webkit/appcache/appcache_storage_impl.cc index 8d21105..0f78b77 100644 --- a/webkit/appcache/appcache_storage_impl.cc +++ b/webkit/appcache/appcache_storage_impl.cc @@ -22,6 +22,7 @@ #include "webkit/appcache/appcache_response.h" #include "webkit/appcache/appcache_service.h" #include "webkit/appcache/appcache_thread.h" +#include "webkit/quota/special_storage_policy.h" namespace { // Helper with no return value for use with NewRunnableFunction. @@ -410,8 +411,7 @@ AppCacheStorageImpl::StoreGroupAndCacheTask::StoreGroupAndCacheTask( AppCacheStorageImpl* storage, AppCacheGroup* group, AppCache* newest_cache) : StoreOrLoadTask(storage), group_(group), cache_(newest_cache), success_(false), would_exceed_quota_(false), - quota_override_( - storage->GetOriginQuotaInMemory(group->manifest_url().GetOrigin())) { + quota_override_(-1) { group_record_.group_id = group->group_id(); group_record_.manifest_url = group->manifest_url(); group_record_.origin = group_record_.manifest_url.GetOrigin(); @@ -419,6 +419,12 @@ AppCacheStorageImpl::StoreGroupAndCacheTask::StoreGroupAndCacheTask( group, &cache_record_, &entry_records_, &fallback_namespace_records_, &online_whitelist_records_); + + if (storage->service()->special_storage_policy() && + storage->service()->special_storage_policy()->IsStorageUnlimited( + group_record_.origin)) { + quota_override_ = kint64max; + } } void AppCacheStorageImpl::StoreGroupAndCacheTask::Run() { diff --git a/webkit/appcache/appcache_storage_impl_unittest.cc b/webkit/appcache/appcache_storage_impl_unittest.cc index 2f25b65..1d874bc 100644 --- a/webkit/appcache/appcache_storage_impl_unittest.cc +++ b/webkit/appcache/appcache_storage_impl_unittest.cc @@ -547,19 +547,14 @@ class AppCacheStorageImplTest : public testing::Test { PushNextTask(NewRunnableMethod( this, &AppCacheStorageImplTest::Verify_FailStoreGroup)); - // Set a low quota to force a failure. - const GURL kOrigin(kManifestUrl.GetOrigin()); - EXPECT_EQ(-1L, storage()->GetOriginQuotaInMemory(kOrigin)); - storage()->SetOriginQuotaInMemory(kManifestUrl.GetOrigin(), 0); - EXPECT_EQ(0L, storage()->GetOriginQuotaInMemory(kOrigin)); - // Setup some preconditions. Create a group and newest cache that - // appear to be "unstored". + // appear to be "unstored" and big enough to exceed the 5M limit. + const int64 kTooBig = 10 * 1024 * 1024; // 10M group_ = new AppCacheGroup( service(), kManifestUrl, storage()->NewGroupId()); cache_ = new AppCache(service(), storage()->NewCacheId()); cache_->AddEntry(kManifestUrl, - AppCacheEntry(AppCacheEntry::MANIFEST, 1, 1024)); + AppCacheEntry(AppCacheEntry::MANIFEST, 1, kTooBig)); // Hold a ref to the cache simulate the UpdateJob holding that ref, // and hold a ref to the group to simulate the CacheHost holding that ref. @@ -578,10 +573,6 @@ class AppCacheStorageImplTest : public testing::Test { EXPECT_FALSE(database()->FindGroup(group_->group_id(), &group_record)); EXPECT_FALSE(database()->FindCache(cache_->cache_id(), &cache_record)); - const GURL kOrigin(kManifestUrl.GetOrigin()); - storage()->ResetOriginQuotaInMemory(kOrigin); - EXPECT_EQ(-1L, storage()->GetOriginQuotaInMemory(kOrigin)); - TestFinished(); } |