Index: content/browser/service_worker/service_worker_storage.cc |
diff --git a/content/browser/service_worker/service_worker_storage.cc b/content/browser/service_worker/service_worker_storage.cc |
index bc5a82aef2e091fa80aaafa7a67264334eb64ad2..13e0ca311b141d7124ef2c95f137d5331b6e0ea0 100644 |
--- a/content/browser/service_worker/service_worker_storage.cc |
+++ b/content/browser/service_worker/service_worker_storage.cc |
@@ -450,8 +450,6 @@ void ServiceWorkerStorage::NotifyDoneInstallingRegistration( |
&ServiceWorkerDatabase::PurgeUncommittedResourceIds), |
base::Unretained(database_.get()), |
ids)); |
- |
- StartPurgingResources(resources); |
} |
} |
@@ -465,6 +463,12 @@ bool ServiceWorkerStorage::IsDisabled() const { |
return state_ == DISABLED; |
} |
+void ServiceWorkerStorage::PurgeResources(const ResourceList& resources) { |
+ if (!has_checked_for_stale_resources_) |
+ DeleteStaleResources(); |
+ StartPurgingResources(resources); |
+} |
+ |
ServiceWorkerStorage::ServiceWorkerStorage( |
const base::FilePath& path, |
base::WeakPtr<ServiceWorkerContextCore> context, |
@@ -705,7 +709,8 @@ void ServiceWorkerStorage::DidStoreRegistration( |
registered_origins_.insert(origin); |
callback.Run(SERVICE_WORKER_OK); |
- SchedulePurgeResources(deleted_version_id, newly_purgeable_resources); |
+ if (!context_ || !context_->GetLiveVersion(deleted_version_id)) |
+ StartPurgingResources(newly_purgeable_resources); |
} |
void ServiceWorkerStorage::DidUpdateToActiveState( |
@@ -734,7 +739,8 @@ void ServiceWorkerStorage::DidDeleteRegistration( |
registered_origins_.erase(origin); |
callback.Run(SERVICE_WORKER_OK); |
- SchedulePurgeResources(version_id, newly_purgeable_resources); |
+ if (!context_ || !context_->GetLiveVersion(version_id)) |
+ StartPurgingResources(newly_purgeable_resources); |
} |
scoped_refptr<ServiceWorkerRegistration> |
@@ -844,32 +850,6 @@ void ServiceWorkerStorage::OnDiskCacheInitialized(int rv) { |
ServiceWorkerMetrics::CountInitDiskCacheResult(rv == net::OK); |
} |
-void ServiceWorkerStorage::OnNoControllees(ServiceWorkerVersion* version) { |
- std::map<int64, std::vector<int64> >::iterator it = |
- deleted_version_resource_ids_.find(version->version_id()); |
- DCHECK(it != deleted_version_resource_ids_.end()); |
- StartPurgingResources(it->second); |
- deleted_version_resource_ids_.erase(it); |
- version->RemoveListener(this); |
-} |
- |
-void ServiceWorkerStorage::SchedulePurgeResources( |
- int64 version_id, |
- const std::vector<int64>& resources) { |
- DCHECK(deleted_version_resource_ids_.find(version_id) == |
- deleted_version_resource_ids_.end()); |
- if (resources.empty()) |
- return; |
- scoped_refptr<ServiceWorkerVersion> version = |
- context_ ? context_->GetLiveVersion(version_id) : NULL; |
- if (version && version->HasControllee()) { |
- deleted_version_resource_ids_[version_id] = resources; |
- version->AddListener(this); |
- } else { |
- StartPurgingResources(resources); |
- } |
-} |
- |
void ServiceWorkerStorage::StartPurgingResources( |
const std::vector<int64>& ids) { |
DCHECK(has_checked_for_stale_resources_); |