Chromium Code Reviews| 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 9d1a83d3101eee6415372ca52400865016b61039..b601ea12f5739428f7168b2669d2cd4bb480da1d 100644 |
| --- a/content/browser/service_worker/service_worker_register_job.cc |
| +++ b/content/browser/service_worker/service_worker_register_job.cc |
| @@ -183,6 +183,7 @@ void ServiceWorkerRegisterJob::ContinueWithRegistration( |
| if (existing_registration.get() && |
| existing_registration->script_url() == script_url_) { |
| set_registration(existing_registration); |
| + AssociateProviderHostToRegistration(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). |
| @@ -247,6 +248,7 @@ void ServiceWorkerRegisterJob::RegisterAndContinue( |
| set_registration(new ServiceWorkerRegistration( |
| pattern_, script_url_, context_->storage()->NewRegistrationId(), |
| context_)); |
| + AssociateProviderHostToRegistration(registration()); |
| UpdateAndContinue(); |
| } |
| @@ -296,7 +298,6 @@ void ServiceWorkerRegisterJob::InstallAndContinue() { |
| // "3. Set registration.installingWorker to worker." |
| registration()->SetInstallingVersion(new_version()); |
| - AssociateInstallingVersionToDocuments(context_, new_version()); |
| // "4. Run the [[UpdateState]] algorithm passing registration.installingWorker |
| // and "installing" as the arguments." |
| @@ -346,9 +347,7 @@ void ServiceWorkerRegisterJob::OnStoreRegistrationComplete( |
| // "10. Set registration.waitingWorker to registration.installingWorker." |
| // "11. Set registration.installingWorker to null." |
| - DisassociateVersionFromDocuments(context_, new_version()); |
| registration()->SetWaitingVersion(new_version()); |
| - AssociateWaitingVersionToDocuments(context_, new_version()); |
| // "12. Run the [[UpdateState]] algorithm passing registration.waitingWorker |
| // and "installed" as the arguments." |
| @@ -374,7 +373,6 @@ void ServiceWorkerRegisterJob::CompleteInternal( |
| if (status != SERVICE_WORKER_OK) { |
| if (registration()) { |
| if (new_version()) { |
| - DisassociateVersionFromDocuments(context_, new_version()); |
| registration()->UnsetVersion(new_version()); |
| new_version()->Doom(); |
| } |
| @@ -453,77 +451,18 @@ void ServiceWorkerRegisterJob::OnCompareScriptResourcesComplete( |
| new_version()->embedded_worker()->RemoveListener(this); |
| } |
| -// static |
| -void ServiceWorkerRegisterJob::AssociateInstallingVersionToDocuments( |
| - base::WeakPtr<ServiceWorkerContextCore> context, |
| - ServiceWorkerVersion* version) { |
| - DCHECK(context); |
| - DCHECK(version); |
| - |
| - for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = |
| - context->GetProviderHostIterator(); |
| - !it->IsAtEnd(); it->Advance()) { |
| - ServiceWorkerProviderHost* host = it->GetProviderHost(); |
| - if (ServiceWorkerUtils::ScopeMatches(version->scope(), |
| - host->document_url())) { |
| - if (!host->CanAssociateVersion(version)) |
| - continue; |
| - host->SetInstallingVersion(version); |
| - } |
| - } |
| -} |
| - |
| -// static |
| -void ServiceWorkerRegisterJob::AssociateWaitingVersionToDocuments( |
| - base::WeakPtr<ServiceWorkerContextCore> context, |
| - ServiceWorkerVersion* version) { |
| - DCHECK(context); |
| - DCHECK(version); |
| - |
| - for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = |
| - context->GetProviderHostIterator(); |
| - !it->IsAtEnd(); it->Advance()) { |
| - ServiceWorkerProviderHost* host = it->GetProviderHost(); |
| - if (ServiceWorkerUtils::ScopeMatches(version->scope(), |
| - host->document_url())) { |
| - if (!host->CanAssociateVersion(version)) |
| - continue; |
| - host->SetWaitingVersion(version); |
| - } |
| - } |
| -} |
| - |
| -// static |
| -void ServiceWorkerRegisterJob::AssociateActiveVersionToDocuments( |
| - base::WeakPtr<ServiceWorkerContextCore> context, |
| - ServiceWorkerVersion* version) { |
| - DCHECK(context); |
| - DCHECK(version); |
| - |
| +void ServiceWorkerRegisterJob::AssociateProviderHostToRegistration( |
| + ServiceWorkerRegistration* registration) { |
| + DCHECK(registration); |
| for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = |
| - context->GetProviderHostIterator(); |
| + context_->GetProviderHostIterator(); |
| !it->IsAtEnd(); it->Advance()) { |
| ServiceWorkerProviderHost* host = it->GetProviderHost(); |
| - if (ServiceWorkerUtils::ScopeMatches(version->scope(), |
| + if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), |
| host->document_url())) { |
| - if (!host->CanAssociateVersion(version)) |
| - continue; |
| - host->SetActiveVersion(version); |
| + host->AssociateRegistration(registration); |
|
falken
2014/08/05 02:41:28
I wonder what happens in cases like register(), lo
nhiroki
2014/08/05 15:51:13
Thank you for sharing the issue. Yes, this is alre
|
| } |
| } |
| } |
| -// static |
| -void ServiceWorkerRegisterJob::DisassociateVersionFromDocuments( |
| - base::WeakPtr<ServiceWorkerContextCore> context, |
| - ServiceWorkerVersion* version) { |
| - DCHECK(context); |
| - for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = |
| - context->GetProviderHostIterator(); |
| - !it->IsAtEnd(); it->Advance()) { |
| - ServiceWorkerProviderHost* host = it->GetProviderHost(); |
| - host->UnsetVersion(version); |
| - } |
| -} |
| - |
| } // namespace content |