summaryrefslogtreecommitdiffstats
path: root/webkit/appcache/appcache_group.cc
diff options
context:
space:
mode:
authormichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-13 20:57:50 +0000
committermichaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-13 20:57:50 +0000
commita84e7b5ec1cbdfe2d6943693d8bd71fcb6c64ce7 (patch)
treedf6dbcf9a6bca8343355ffef01eeed49f6059b83 /webkit/appcache/appcache_group.cc
parent45699d6054f62173d0cd9df0f43af65047d76d79 (diff)
downloadchromium_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_group.cc')
-rw-r--r--webkit/appcache/appcache_group.cc32
1 files changed, 31 insertions, 1 deletions
diff --git a/webkit/appcache/appcache_group.cc b/webkit/appcache/appcache_group.cc
index e5511a6..e1906ab 100644
--- a/webkit/appcache/appcache_group.cc
+++ b/webkit/appcache/appcache_group.cc
@@ -60,6 +60,8 @@ AppCacheGroup::~AppCacheGroup() {
DCHECK_EQ(IDLE, update_status_);
service_->storage()->working_set()->RemoveGroup(this);
+ service_->storage()->DeleteResponses(
+ manifest_url_, newly_deletable_response_ids_);
}
void AppCacheGroup::AddUpdateObserver(UpdateObserver* observer) {
@@ -111,16 +113,44 @@ void AppCacheGroup::RemoveCache(AppCache* cache) {
newest_complete_cache_ = NULL;
tmp_cache->set_owning_group(NULL); // may cause this group to be deleted
} else {
+ scoped_refptr<AppCacheGroup> protect(this);
+
Caches::iterator it =
std::find(old_caches_.begin(), old_caches_.end(), cache);
if (it != old_caches_.end()) {
AppCache* tmp_cache = *it;
old_caches_.erase(it);
- tmp_cache->set_owning_group(NULL); // may cause group to be deleted
+ tmp_cache->set_owning_group(NULL); // may cause group to be released
+ }
+
+ if (!is_obsolete() && old_caches_.empty() &&
+ !newly_deletable_response_ids_.empty()) {
+ service_->storage()->DeleteResponses(
+ manifest_url_, newly_deletable_response_ids_);
+ newly_deletable_response_ids_.clear();
}
}
}
+void AppCacheGroup::AddNewlyDeletableResponseIds(
+ std::vector<int64>* response_ids) {
+ if (!is_obsolete() && old_caches_.empty()) {
+ service_->storage()->DeleteResponses(
+ manifest_url_, *response_ids);
+ response_ids->clear();
+ return;
+ }
+
+ if (newly_deletable_response_ids_.empty()) {
+ newly_deletable_response_ids_.swap(*response_ids);
+ return;
+ }
+ newly_deletable_response_ids_.insert(
+ newly_deletable_response_ids_.end(),
+ response_ids->begin(), response_ids->end());
+ response_ids->clear();
+}
+
void AppCacheGroup::StartUpdateWithNewMasterEntry(
AppCacheHost* host, const GURL& new_master_resource) {
if (!update_job_)