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_update_job.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_update_job.cc')
-rw-r--r-- | webkit/appcache/appcache_update_job.cc | 25 |
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_; } |