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

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

Issue 413063004: Service Worker: in Unregister, wait until after the active worker no longer controls a document (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: delete/restore from storage 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 ab73931ce614b32d33342a396969431d57f1555a..519275c3f9744c78ef702186a7e8bf536054b2ae 100644
--- a/content/browser/service_worker/service_worker_storage.cc
+++ b/content/browser/service_worker/service_worker_storage.cc
@@ -320,6 +320,22 @@ void ServiceWorkerStorage::FindRegistrationForPattern(
weak_factory_.GetWeakPtr(), scope, callback)));
}
+scoped_refptr<ServiceWorkerRegistration>
+ServiceWorkerStorage::GetUninstallingRegistration(const GURL& scope) {
+ if (state_ != INITIALIZED || !context_)
+ return NULL;
+ for (RegistrationRefsById::const_iterator it =
+ uninstalling_registrations_.begin();
+ it != uninstalling_registrations_.end();
+ ++it) {
+ if (it->second->pattern() == scope) {
+ DCHECK(it->second->is_uninstalling());
+ return it->second;
+ }
+ }
+ return NULL;
+}
+
void ServiceWorkerStorage::FindRegistrationForId(
int64 registration_id,
const GURL& origin,
@@ -411,7 +427,7 @@ void ServiceWorkerStorage::StoreRegistration(
data.has_fetch_handler = true;
data.version_id = version->version_id();
data.last_update_check = base::Time::Now();
- data.is_active = false; // initially stored in the waiting state
+ data.is_active = (version == registration->active_version());
ResourceList resources;
version->script_cache_map()->GetResources(&resources);
@@ -592,6 +608,16 @@ void ServiceWorkerStorage::NotifyDoneInstallingRegistration(
}
}
+void ServiceWorkerStorage::NotifyUninstallingRegistration(
+ ServiceWorkerRegistration* registration) {
+ uninstalling_registrations_[registration->id()] = registration;
+}
+
+void ServiceWorkerStorage::NotifyDoneUninstallingRegistration(
+ ServiceWorkerRegistration* registration) {
+ uninstalling_registrations_.erase(registration->id());
+}
+
void ServiceWorkerStorage::Disable() {
state_ = DISABLED;
if (disk_cache_)
@@ -758,7 +784,7 @@ void ServiceWorkerStorage::DidFindRegistrationForId(
}
if (status == ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) {
- // TODO(nhiroki): Find a registration in |installing_registrations_|.
+ // TODO(nhiroki): Find a registration in |installing_registrations|.
callback.Run(DatabaseStatusToStatusCode(status),
scoped_refptr<ServiceWorkerRegistration>());
return;

Powered by Google App Engine
This is Rietveld 408576698