| Index: content/browser/service_worker/service_worker_register_job.cc
|
| diff --git a/content/browser/service_worker/service_worker_register_job.cc b/content/browser/service_worker/service_worker_register_job.cc
|
| index dd96b604b3c19393659c30f33e7d5f79bc0b4c3b..c5b50487d43539e2f1ecf8c43e190ef8628b7934 100644
|
| --- a/content/browser/service_worker/service_worker_register_job.cc
|
| +++ b/content/browser/service_worker/service_worker_register_job.cc
|
| @@ -197,9 +197,8 @@ void ServiceWorkerRegisterJob::SetPhase(Phase phase) {
|
| phase_ = phase;
|
| }
|
|
|
| -// This function corresponds to the steps in Register following
|
| -// "Let serviceWorkerRegistration be _GetRegistration(scope)"
|
| -// |existing_registration| corresponds to serviceWorkerRegistration.
|
| +// This function corresponds to the steps in [[Register]] following
|
| +// "Let registration be the result of running the [[GetRegistration]] algorithm.
|
| // Throughout this file, comments in quotes are excerpts from the spec.
|
| void ServiceWorkerRegisterJob::ContinueWithRegistration(
|
| ServiceWorkerStatusCode status,
|
| @@ -211,39 +210,36 @@ void ServiceWorkerRegisterJob::ContinueWithRegistration(
|
| return;
|
| }
|
|
|
| - // "If serviceWorkerRegistration is not null and script is equal to
|
| - // serviceWorkerRegistration.scriptUrl..." resolve with the existing
|
| - // registration and abort.
|
| - if (existing_registration.get() &&
|
| - existing_registration->script_url() == script_url_) {
|
| + if (!existing_registration) {
|
| + RegisterAndContinue(SERVICE_WORKER_OK);
|
| + return;
|
| + }
|
| +
|
| + // "1. Set registration.[[Uninstalling]] to false."
|
| + existing_registration->set_uninstalling(false);
|
| +
|
| + // "2. If scriptURL is equal to registration.[[ScriptURL]], then:"
|
| + if (existing_registration->script_url() == script_url_) {
|
| + // Spec says to resolve with registration.[[GetNewestWorker]]. We come close
|
| + // by resolving with the active version.
|
| set_registration(existing_registration);
|
| - // If there's no active version, go ahead to Update (this isn't in the spec
|
| - // but seems reasonable, and without SoftUpdate implemented we can never
|
| - // Update otherwise).
|
| +
|
| if (!existing_registration->active_version()) {
|
| UpdateAndContinue();
|
| return;
|
| }
|
| +
|
| ResolvePromise(
|
| status, existing_registration, existing_registration->active_version());
|
| Complete(SERVICE_WORKER_OK);
|
| return;
|
| }
|
|
|
| - // "If serviceWorkerRegistration is null..." create a new registration.
|
| - if (!existing_registration.get()) {
|
| - RegisterAndContinue(SERVICE_WORKER_OK);
|
| - return;
|
| - }
|
| -
|
| - // On script URL mismatch, "set serviceWorkerRegistration.scriptUrl to
|
| - // script." We accomplish this by deleting the existing registration and
|
| - // registering a new one.
|
| - // TODO(falken): Match the spec. We now throw away the active_version_ and
|
| - // waiting_version_ of the existing registration, which isn't in the spec.
|
| + // "Set registration.[[ScriptURL]] to scriptURL." We accomplish this by
|
| + // deleting the existing registration and registering a new one.
|
| // TODO(michaeln): Deactivate the live existing_registration object and
|
| - // eventually call storage->DeleteVersionResources()
|
| - // when it no longer has any controllees.
|
| + // eventually call storage->DeleteVersionResources() when it no longer has any
|
| + // controllees.
|
| context_->storage()->DeleteRegistration(
|
| existing_registration->id(),
|
| existing_registration->script_url().GetOrigin(),
|
|
|