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

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

Issue 472103003: Service Worker: Handle same-scope, new script registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 6 years, 4 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_registration.cc
diff --git a/content/browser/service_worker/service_worker_registration.cc b/content/browser/service_worker/service_worker_registration.cc
index ce5686381e8009f90565288ad05e72d0f52d0433..ec8b257575552cde2e3d4582ba698fb1316eed3e 100644
--- a/content/browser/service_worker/service_worker_registration.cc
+++ b/content/browser/service_worker/service_worker_registration.cc
@@ -157,15 +157,17 @@ void ServiceWorkerRegistration::ClearWhenReady() {
id(),
script_url().GetOrigin(),
base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
-
if (!active_version() || !active_version()->HasControllee())
Clear();
}
-void ServiceWorkerRegistration::AbortPendingClear() {
+void ServiceWorkerRegistration::AbortPendingClear(
+ const StatusCallback& callback) {
DCHECK(context_);
- if (!is_uninstalling())
+ if (!is_uninstalling()) {
+ callback.Run(SERVICE_WORKER_OK);
return;
+ }
is_uninstalling_ = false;
context_->storage()->NotifyDoneUninstallingRegistration(this);
@@ -176,8 +178,9 @@ void ServiceWorkerRegistration::AbortPendingClear() {
context_->storage()->StoreRegistration(
this,
most_recent_version,
- base::Bind(&ServiceWorkerRegistration::OnStoreFinished,
+ base::Bind(&ServiceWorkerRegistration::OnRestoreFinished,
this,
+ callback,
most_recent_version));
}
@@ -273,7 +276,9 @@ void ServiceWorkerRegistration::OnDeleteFinished(
}
void ServiceWorkerRegistration::Clear() {
- context_->storage()->NotifyDoneUninstallingRegistration(this);
+ is_uninstalling_ = false;
+ if (context_)
+ context_->storage()->NotifyDoneUninstallingRegistration(this);
ChangedVersionAttributesMask mask;
if (installing_version_) {
@@ -297,15 +302,22 @@ void ServiceWorkerRegistration::Clear() {
FOR_EACH_OBSERVER(Listener, listeners_,
OnVersionAttributesChanged(this, mask, info));
}
+
+ FOR_EACH_OBSERVER(
+ Listener, listeners_, OnRegistrationFinishedUninstalling(this));
}
-void ServiceWorkerRegistration::OnStoreFinished(
+void ServiceWorkerRegistration::OnRestoreFinished(
+ const StatusCallback& callback,
scoped_refptr<ServiceWorkerVersion> version,
ServiceWorkerStatusCode status) {
- if (!context_)
+ if (!context_) {
+ callback.Run(ServiceWorkerStatusCode::SERVICE_WORKER_ERROR_ABORT);
return;
+ }
context_->storage()->NotifyDoneInstallingRegistration(
this, version.get(), status);
+ callback.Run(status);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698