diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-10 23:29:09 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-10 23:29:09 +0000 |
commit | e0184cbde1634faa300d63c7880b5acf312f45d6 (patch) | |
tree | 69ef5ba562bbc68276fddd3279c6ca7e8e27d025 /webkit/appcache/appcache_storage.cc | |
parent | b7d94558973c6c6f2776f68a4d34d20cd5303ac5 (diff) | |
download | chromium_src-e0184cbde1634faa300d63c7880b5acf312f45d6.zip chromium_src-e0184cbde1634faa300d63c7880b5acf312f45d6.tar.gz chromium_src-e0184cbde1634faa300d63c7880b5acf312f45d6.tar.bz2 |
AppCache + Quota integration
* Notify the QuotaManager of accesses and modifications to the amount of storage utlized.
* Implement the QuotaClient interface so the manager can query the appcache for usage and delete data.
* When storing appcaches, use QuotaManager GetUsageAndQuota and respect the limit.
* Remove the old and unsed support for storing per-origin quota values in the appcache DB.
BUG=61676
TEST=unittests
Review URL: http://codereview.chromium.org/7031065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88746 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_storage.cc')
-rw-r--r-- | webkit/appcache/appcache_storage.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/webkit/appcache/appcache_storage.cc b/webkit/appcache/appcache_storage.cc index a30088f..a4fde29 100644 --- a/webkit/appcache/appcache_storage.cc +++ b/webkit/appcache/appcache_storage.cc @@ -6,6 +6,9 @@ #include "base/stl_util-inl.h" #include "webkit/appcache/appcache_response.h" +#include "webkit/appcache/appcache_service.h" +#include "webkit/quota/quota_client.h" +#include "webkit/quota/quota_manager.h" namespace appcache { @@ -87,5 +90,42 @@ void AppCacheStorage::LoadResponseInfo( info_load->StartIfNeeded(); } +void AppCacheStorage::UpdateUsageMapAndNotify( + const GURL& origin, int64 new_usage) { + DCHECK_GE(new_usage, 0); + int64 old_usage = usage_map_[origin]; + if (new_usage > 0) + usage_map_[origin] = new_usage; + else + usage_map_.erase(origin); + if (new_usage != old_usage && service()->quota_manager_proxy()) { + service()->quota_manager_proxy()->NotifyStorageModified( + quota::QuotaClient::kAppcache, + origin, quota::kStorageTypeTemporary, + new_usage - old_usage); + } +} + +void AppCacheStorage::ClearUsageMapAndNotify() { + if (service()->quota_manager_proxy()) { + for (UsageMap::const_iterator iter = usage_map_.begin(); + iter != usage_map_.end(); ++iter) { + service()->quota_manager_proxy()->NotifyStorageModified( + quota::QuotaClient::kAppcache, + iter->first, quota::kStorageTypeTemporary, + -(iter->second)); + } + } + usage_map_.clear(); +} + +void AppCacheStorage::NotifyStorageAccessed(const GURL& origin) { + if (service()->quota_manager_proxy() && + usage_map_.find(origin) != usage_map_.end()) + service()->quota_manager_proxy()->NotifyStorageAccessed( + quota::QuotaClient::kAppcache, + origin, quota::kStorageTypeTemporary); +} + } // namespace appcache |