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

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 & add should_notify_controllerchange Created 6 years, 1 month 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 0445f08f7e646ba73497be4257adeb4d6ad008c3..46cfa9aa380f15b58e399b131320884a01935d5a 100644
--- a/content/browser/service_worker/service_worker_registration.cc
+++ b/content/browser/service_worker/service_worker_registration.cc
@@ -154,7 +154,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();
}
@@ -198,7 +199,6 @@ void ServiceWorkerRegistration::AbortPendingClear(
}
void ServiceWorkerRegistration::OnNoControllees(ServiceWorkerVersion* version) {
- DCHECK_EQ(active_version(), version);
falken 2014/12/01 02:29:59 I guess this DCHECK can fail now if OnNoControllee
xiang 2014/12/01 07:20:07 Thanks for point this out, I think we can remove t
falken 2014/12/01 07:27:52 Looks right, nice idea.
if (is_uninstalling_)
Clear();
else if (should_activate_when_ready_)
@@ -220,9 +220,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."
@@ -233,17 +232,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));

Powered by Google App Engine
This is Rietveld 408576698