diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 22:25:33 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 22:25:33 +0000 |
commit | 0dfeec38d00d53b6751a937e43394d6036987698 (patch) | |
tree | b8641d3bd07cbe185deb9f1dba29acb551bb92a2 /webkit/appcache/appcache.cc | |
parent | f1002ee286ad56e2b80736661e89989b650aad6e (diff) | |
download | chromium_src-0dfeec38d00d53b6751a937e43394d6036987698.zip chromium_src-0dfeec38d00d53b6751a937e43394d6036987698.tar.gz chromium_src-0dfeec38d00d53b6751a937e43394d6036987698.tar.bz2 |
AppCache quota tracking groundwork, store response sizes in the SQL database.
TEST=updated existing unittests
BUG=none
Review URL: http://codereview.chromium.org/525060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache.cc')
-rw-r--r-- | webkit/appcache/appcache.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/webkit/appcache/appcache.cc b/webkit/appcache/appcache.cc index ec00cc4..e1819d4 100644 --- a/webkit/appcache/appcache.cc +++ b/webkit/appcache/appcache.cc @@ -44,13 +44,15 @@ void AppCache::AddEntry(const GURL& url, const AppCacheEntry& entry) { entries_.insert(EntryMap::value_type(url, entry)); } -void AppCache::AddOrModifyEntry(const GURL& url, const AppCacheEntry& entry) { +bool AppCache::AddOrModifyEntry(const GURL& url, const AppCacheEntry& entry) { std::pair<EntryMap::iterator, bool> ret = entries_.insert(EntryMap::value_type(url, entry)); // Entry already exists. Merge the types of the new and existing entries. if (!ret.second) ret.first->second.add_types(entry.types()); + + return ret.second; } AppCacheEntry* AppCache::GetEntry(const GURL& url) { @@ -90,7 +92,8 @@ void AppCache::InitializeWithDatabaseRecords( for (size_t i = 0; i < entries.size(); ++i) { const AppCacheDatabase::EntryRecord& entry = entries.at(i); - AddEntry(entry.url, AppCacheEntry(entry.flags, entry.response_id)); + AddEntry(entry.url, AppCacheEntry(entry.flags, entry.response_id, + entry.response_size)); } for (size_t i = 0; i < fallbacks.size(); ++i) { @@ -124,6 +127,7 @@ void AppCache::ToDatabaseRecords( cache_record->group_id = group->group_id(); cache_record->online_wildcard = online_whitelist_all_; cache_record->update_time = update_time_; + cache_record->cache_size = 0; for (EntryMap::const_iterator iter = entries_.begin(); iter != entries_.end(); ++iter) { @@ -133,6 +137,8 @@ void AppCache::ToDatabaseRecords( record.cache_id = cache_id_; record.flags = iter->second.types(); record.response_id = iter->second.response_id(); + record.response_size = iter->second.response_size(); + cache_record->cache_size += record.response_size; } GURL origin = group->manifest_url().GetOrigin(); |