| 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 089e7b24e9af1cd75b39e2cf2af7f9b340a2dcf2..81582d965f365d8366f2a5eeca865b094bf610e6 100644
|
| --- a/content/browser/service_worker/service_worker_register_job.cc
|
| +++ b/content/browser/service_worker/service_worker_register_job.cc
|
| @@ -44,7 +44,7 @@ ServiceWorkerRegisterJob::ServiceWorkerRegisterJob(
|
| : context_(context),
|
| job_type_(UPDATE_JOB),
|
| pattern_(registration->pattern()),
|
| - script_url_(registration->script_url()),
|
| + script_url_(registration->GetNewestVersion()->script_url()),
|
| phase_(INITIAL),
|
| is_promise_resolved_(false),
|
| promise_resolved_status_(SERVICE_WORKER_OK),
|
| @@ -190,7 +190,7 @@ void ServiceWorkerRegisterJob::ContinueWithRegistration(
|
| existing_registration->AbortPendingClear();
|
|
|
| // "If scriptURL is equal to registration.[[ScriptURL]], then:"
|
| - if (existing_registration->script_url() == script_url_) {
|
| + if (existing_registration->GetNewestVersion()->script_url() == script_url_) {
|
| // Spec says to resolve with registration.[[GetNewestWorker]]. We come close
|
| // by resolving with the active version.
|
| set_registration(existing_registration.get());
|
| @@ -214,7 +214,7 @@ void ServiceWorkerRegisterJob::ContinueWithRegistration(
|
| // controllees.
|
| context_->storage()->DeleteRegistration(
|
| existing_registration->id(),
|
| - existing_registration->script_url().GetOrigin(),
|
| + existing_registration->pattern().GetOrigin(),
|
| base::Bind(&ServiceWorkerRegisterJob::RegisterAndContinue,
|
| weak_factory_.GetWeakPtr()));
|
| }
|
| @@ -233,6 +233,14 @@ void ServiceWorkerRegisterJob::ContinueWithUpdate(
|
| return;
|
| }
|
|
|
| + // A previous job may have unregistered or installed a new version to this
|
| + // registration.
|
| + if (registration()->is_uninstalling() ||
|
| + registration()->GetNewestVersion()->script_url() != script_url_) {
|
| + Complete(SERVICE_WORKER_ERROR_NOT_FOUND);
|
| + return;
|
| + }
|
| +
|
| // TODO(michaeln): If the last update check was less than 24 hours
|
| // ago, depending on the freshness of the cached worker script we
|
| // may be able to complete the update job right here.
|
| @@ -251,8 +259,7 @@ void ServiceWorkerRegisterJob::RegisterAndContinue(
|
| }
|
|
|
| set_registration(new ServiceWorkerRegistration(
|
| - pattern_, script_url_, context_->storage()->NewRegistrationId(),
|
| - context_));
|
| + pattern_, context_->storage()->NewRegistrationId(), context_));
|
| AssociateProviderHostsToRegistration(registration());
|
| UpdateAndContinue();
|
| }
|
| @@ -269,8 +276,10 @@ void ServiceWorkerRegisterJob::UpdateAndContinue() {
|
|
|
| // "Let serviceWorker be a newly-created ServiceWorker object..." and start
|
| // the worker.
|
| - set_new_version(new ServiceWorkerVersion(
|
| - registration(), context_->storage()->NewVersionId(), context_));
|
| + set_new_version(new ServiceWorkerVersion(registration(),
|
| + script_url_,
|
| + context_->storage()->NewVersionId(),
|
| + context_));
|
|
|
| bool pause_after_download = job_type_ == UPDATE_JOB;
|
| if (pause_after_download)
|
| @@ -387,7 +396,7 @@ void ServiceWorkerRegisterJob::CompleteInternal(
|
| registration()->NotifyRegistrationFailed();
|
| context_->storage()->DeleteRegistration(
|
| registration()->id(),
|
| - registration()->script_url().GetOrigin(),
|
| + registration()->pattern().GetOrigin(),
|
| base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
|
| }
|
| }
|
|
|