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

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

Issue 717353004: ServiceWorker: Add support for .skipWaiting and controllerchange event(2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again Created 6 years 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 c4d8d6ac20524a6074f6f0b669d0e180dfd1d6e5..7d41454f4adab012710e26305a44a4d697bb03e5 100644
--- a/content/browser/service_worker/service_worker_registration.cc
+++ b/content/browser/service_worker/service_worker_registration.cc
@@ -125,6 +125,8 @@ void ServiceWorkerRegistration::SetVersionInternal(
ChangedVersionAttributesMask mask;
if (version)
UnsetVersionInternal(version, &mask);
+ if (*data_member && *data_member == active_version_)
+ active_version_->RemoveListener(this);
*data_member = version;
if (active_version_.get() && active_version_.get() == version)
active_version_->AddListener(this);
@@ -154,7 +156,8 @@ void ServiceWorkerRegistration::UnsetVersionInternal(
void ServiceWorkerRegistration::ActivateWaitingVersionWhenReady() {
DCHECK(waiting_version());
should_activate_when_ready_ = true;
- if (!active_version() || !active_version()->HasControllee())
+ if (!active_version() || !active_version()->HasControllee() ||
+ waiting_version()->skip_waiting())
ActivateWaitingVersion();
}
@@ -243,9 +246,8 @@ void ServiceWorkerRegistration::ActivateWaitingVersion() {
return; // Activation is no longer relevant.
}
- // "4. If exitingWorker is not null,
+ // "5. If exitingWorker is not null,
if (exiting_version.get()) {
- DCHECK(!exiting_version->HasControllee());
// TODO(michaeln): should wait for events to be complete
// "1. Wait for exitingWorker to finish handling any in-progress requests."
// "2. Terminate exitingWorker."
@@ -256,17 +258,19 @@ void ServiceWorkerRegistration::ActivateWaitingVersion() {
exiting_version->SetStatus(ServiceWorkerVersion::REDUNDANT);
}
- // "5. Set serviceWorkerRegistration.activeWorker to activatingWorker."
- // "6. Set serviceWorkerRegistration.waitingWorker to null."
+ // "6. Set serviceWorkerRegistration.activeWorker to activatingWorker."
+ // "7. Set serviceWorkerRegistration.waitingWorker to null."
SetActiveVersion(activating_version.get());
- // "7. Run the [[UpdateState]] algorithm passing registration.activeWorker and
+ // "8. Run the [[UpdateState]] algorithm passing registration.activeWorker and
// "activating" as arguments."
activating_version->SetStatus(ServiceWorkerVersion::ACTIVATING);
+ // "9. Fire a simple event named controllerchange..."
+ // Notify associated provider hosts to change the controller.
+ if (activating_version->skip_waiting())
+ FOR_EACH_OBSERVER(Listener, listeners_, OnSkippedWaiting(this));
- // TODO(nhiroki): "8. Fire a simple event named controllerchange..."
-
- // "9. Queue a task to fire an event named activate..."
+ // "10. Queue a task to fire an event named activate..."
activating_version->DispatchActivateEvent(
base::Bind(&ServiceWorkerRegistration::OnActivateEventFinished,
this, activating_version));
« no previous file with comments | « content/browser/service_worker/service_worker_registration.h ('k') | content/browser/service_worker/service_worker_version.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698