Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1138)

Unified Diff: content/browser/service_worker/service_worker_storage.cc

Issue 377153003: Service Worker: set active worker to REDUNDANT when unregistered (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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_);

Powered by Google App Engine
This is Rietveld 408576698