diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 03:26:41 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 03:26:41 +0000 |
commit | fd4882e6faab19e1de6d791acebfa3b34faf5701 (patch) | |
tree | 2fa95bddd8b6189d0dd7b850d24da0b7ab382e28 /webkit/appcache/appcache.cc | |
parent | 12e8fecd3923d3ace7fe3f505ba3fa490b5417c1 (diff) | |
download | chromium_src-fd4882e6faab19e1de6d791acebfa3b34faf5701.zip chromium_src-fd4882e6faab19e1de6d791acebfa3b34faf5701.tar.gz chromium_src-fd4882e6faab19e1de6d791acebfa3b34faf5701.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/523046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35609 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(); |