summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_update_job.cc
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-06 03:26:41 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-06 03:26:41 +0000
commitfd4882e6faab19e1de6d791acebfa3b34faf5701 (patch)
tree2fa95bddd8b6189d0dd7b850d24da0b7ab382e28 /webkit/appcache/appcache_update_job.cc
parent12e8fecd3923d3ace7fe3f505ba3fa490b5417c1 (diff)
downloadchromium_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_update_job.cc')
-rw-r--r--webkit/appcache/appcache_update_job.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/webkit/appcache/appcache_update_job.cc b/webkit/appcache/appcache_update_job.cc
index 04c409e..a1f4ec5 100644
--- a/webkit/appcache/appcache_update_job.cc
+++ b/webkit/appcache/appcache_update_job.cc
@@ -539,8 +539,10 @@ void AppCacheUpdateJob::HandleUrlFetchCompleted(URLRequest* request) {
static_cast<UpdateJobInfo*>(request->GetUserData(this));
DCHECK(info->response_writer_.get());
entry.set_response_id(info->response_writer_->response_id());
+ entry.set_response_size(info->response_writer_->amount_written());
- inprogress_cache_->AddOrModifyEntry(url, entry);
+ if (!inprogress_cache_->AddOrModifyEntry(url, entry))
+ service_->storage()->DoomResponse(manifest_url_, entry.response_id());
// Foreign entries will be detected during cache selection.
// Note: 6.9.4, step 17.9 possible optimization: if resource is HTML or XML
@@ -567,6 +569,7 @@ void AppCacheUpdateJob::HandleUrlFetchCompleted(URLRequest* request) {
AppCacheEntry* copy = cache->GetEntry(url);
if (copy) {
entry.set_response_id(copy->response_id());
+ entry.set_response_size(copy->response_size());
inprogress_cache_->AddOrModifyEntry(url, entry);
}
}
@@ -607,8 +610,12 @@ void AppCacheUpdateJob::HandleMasterEntryFetchCompleted(URLRequest* request) {
group_->newest_complete_cache();
DCHECK(info->response_writer_.get());
AppCacheEntry master_entry(AppCacheEntry::MASTER,
- info->response_writer_->response_id());
- cache->AddOrModifyEntry(url, master_entry);
+ info->response_writer_->response_id(),
+ info->response_writer_->amount_written());
+ if (!cache->AddOrModifyEntry(url, master_entry)) {
+ service_->storage()->DoomResponse(
+ manifest_url_, master_entry.response_id());
+ }
// In no-update case, associate host with the newest cache.
if (!inprogress_cache_) {
@@ -701,8 +708,10 @@ void AppCacheUpdateJob::OnManifestInfoWriteComplete(int result) {
void AppCacheUpdateJob::OnManifestDataWriteComplete(int result) {
if (result > 0) {
AppCacheEntry entry(AppCacheEntry::MANIFEST,
- manifest_response_writer_->response_id());
- inprogress_cache_->AddOrModifyEntry(manifest_url_, entry);
+ manifest_response_writer_->response_id(),
+ manifest_response_writer_->amount_written());
+ if (!inprogress_cache_->AddOrModifyEntry(manifest_url_, entry))
+ service_->storage()->DoomResponse(manifest_url_, entry.response_id());
CompleteInprogressCache();
} else {
// Treat storage failure as if refetch of manifest failed.
@@ -1096,10 +1105,16 @@ void AppCacheUpdateJob::OnResponseInfoLoaded(
http_info->headers->EnumerateHeader(&iter, name, &value)) {
LoadFromNewestCacheFailed(url);
} else {
+ DCHECK(group_->newest_complete_cache());
+ AppCacheEntry* copy_me = group_->newest_complete_cache()->GetEntry(url);
+ DCHECK(copy_me);
+ DCHECK(copy_me->response_id() == response_id);
+
AppCache::EntryMap::iterator it = url_file_list_.find(url);
DCHECK(it != url_file_list_.end());
AppCacheEntry& entry = it->second;
entry.set_response_id(response_id);
+ entry.set_response_size(copy_me->response_size());
inprogress_cache_->AddOrModifyEntry(url, entry);
++url_fetches_completed_;
}