diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-13 20:57:50 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-13 20:57:50 +0000 |
commit | a84e7b5ec1cbdfe2d6943693d8bd71fcb6c64ce7 (patch) | |
tree | df6dbcf9a6bca8343355ffef01eeed49f6059b83 /webkit/appcache/appcache_update_job.cc | |
parent | 45699d6054f62173d0cd9df0f43af65047d76d79 (diff) | |
download | chromium_src-a84e7b5ec1cbdfe2d6943693d8bd71fcb6c64ce7.zip chromium_src-a84e7b5ec1cbdfe2d6943693d8bd71fcb6c64ce7.tar.gz chromium_src-a84e7b5ec1cbdfe2d6943693d8bd71fcb6c64ce7.tar.bz2 |
Trigger the deletion of unused responses when caches are updated and made obsolete (deleted).
BUG=none
TEST=not yet
Review URL: http://codereview.chromium.org/542021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36166 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_update_job.cc')
-rw-r--r-- | webkit/appcache/appcache_update_job.cc | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/webkit/appcache/appcache_update_job.cc b/webkit/appcache/appcache_update_job.cc index a1f4ec5..f138f4d 100644 --- a/webkit/appcache/appcache_update_job.cc +++ b/webkit/appcache/appcache_update_job.cc @@ -542,7 +542,7 @@ void AppCacheUpdateJob::HandleUrlFetchCompleted(URLRequest* request) { entry.set_response_size(info->response_writer_->amount_written()); if (!inprogress_cache_->AddOrModifyEntry(url, entry)) - service_->storage()->DoomResponse(manifest_url_, entry.response_id()); + duplicate_response_ids_.push_back(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 @@ -612,10 +612,8 @@ void AppCacheUpdateJob::HandleMasterEntryFetchCompleted(URLRequest* request) { AppCacheEntry master_entry(AppCacheEntry::MASTER, 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()); - } + if (!cache->AddOrModifyEntry(url, master_entry)) + duplicate_response_ids_.push_back(master_entry.response_id()); // In no-update case, associate host with the newest cache. if (!inprogress_cache_) { @@ -711,7 +709,7 @@ void AppCacheUpdateJob::OnManifestDataWriteComplete(int result) { 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()); + duplicate_response_ids_.push_back(entry.response_id()); CompleteInprogressCache(); } else { // Treat storage failure as if refetch of manifest failed. @@ -1145,6 +1143,7 @@ void AppCacheUpdateJob::MaybeCompleteUpdate() { case NO_UPDATE: // 6.9.4 steps 7.3-7.7. NotifyAllAssociatedHosts(NO_UPDATE_EVENT); + DiscardDuplicateResponses(); internal_state_ = COMPLETED; break; case DOWNLOADING: @@ -1156,6 +1155,7 @@ void AppCacheUpdateJob::MaybeCompleteUpdate() { NotifyAllAssociatedHosts(CACHED_EVENT); else NotifyAllAssociatedHosts(UPDATE_READY_EVENT); + DiscardDuplicateResponses(); internal_state_ = COMPLETED; break; case CACHE_FAILURE: @@ -1239,6 +1239,10 @@ void AppCacheUpdateJob::DiscardInprogressCache() { inprogress_cache_ = NULL; } +void AppCacheUpdateJob::DiscardDuplicateResponses() { + service_->storage()->DoomResponses(manifest_url_, duplicate_response_ids_); +} + void AppCacheUpdateJob::DeleteSoon() { ClearPendingMasterEntries(); manifest_response_writer_.reset(); |