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

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: make setting redundant clearly the responsibility of SWStorage 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 05e65323ca88818b8e574aa08c3cc9ff314d22c1..4bddee64b79a20776e9fe43413af4307385decd0 100644
--- a/content/browser/service_worker/service_worker_storage.cc
+++ b/content/browser/service_worker/service_worker_storage.cc
@@ -696,7 +696,7 @@ void ServiceWorkerStorage::DidStoreRegistration(
registered_origins_.insert(origin);
callback.Run(SERVICE_WORKER_OK);
- SchedulePurgeResources(deleted_version_id, newly_purgeable_resources);
+ DecommissionVersion(deleted_version_id, newly_purgeable_resources);
michaeln 2014/07/10 00:55:23 presuming two things: * higher level job classes h
falken 2014/07/10 14:05:12 I think that block kind of makes sense, it's a spe
}
void ServiceWorkerStorage::DidUpdateToActiveState(
@@ -725,7 +725,7 @@ void ServiceWorkerStorage::DidDeleteRegistration(
registered_origins_.erase(origin);
callback.Run(SERVICE_WORKER_OK);
- SchedulePurgeResources(version_id, newly_purgeable_resources);
+ DecommissionVersion(version_id, newly_purgeable_resources);
}
scoped_refptr<ServiceWorkerRegistration>
@@ -836,29 +836,33 @@ void ServiceWorkerStorage::OnDiskCacheInitialized(int rv) {
}
void ServiceWorkerStorage::OnNoControllees(ServiceWorkerVersion* version) {
+ version->RemoveListener(this);
+ version->SetStatus(ServiceWorkerVersion::REDUNDANT);
+
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(
+void ServiceWorkerStorage::DecommissionVersion(
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()) {
+ // Defer decommissioning.
deleted_version_resource_ids_[version_id] = resources;
version->AddListener(this);
- } else {
- StartPurgingResources(resources);
+ return;
}
+
+ if (version)
+ version->SetStatus(ServiceWorkerVersion::REDUNDANT);
+ StartPurgingResources(resources);
}
void ServiceWorkerStorage::StartPurgingResources(

Powered by Google App Engine
This is Rietveld 408576698