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..64e64ba797dd6a117172ef6823e94a3c0a3fdcb5 100644 |
| --- a/content/browser/service_worker/service_worker_register_job.cc |
| +++ b/content/browser/service_worker/service_worker_register_job.cc |
| @@ -247,6 +247,7 @@ void ServiceWorkerRegisterJob::RegisterAndContinue( |
| set_registration(new ServiceWorkerRegistration( |
| pattern_, script_url_, context_->storage()->NewRegistrationId(), |
| context_)); |
| + AssociateProviderHostsToRegistration(registration()); |
| UpdateAndContinue(); |
| } |
| @@ -296,7 +297,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 +346,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,11 +372,11 @@ void ServiceWorkerRegisterJob::CompleteInternal( |
| if (status != SERVICE_WORKER_OK) { |
| if (registration()) { |
| if (new_version()) { |
| - DisassociateVersionFromDocuments(context_, new_version()); |
| registration()->UnsetVersion(new_version()); |
| new_version()->Doom(); |
| } |
| if (!registration()->active_version()) { |
|
michaeln
2014/08/07 20:33:07
i think this may need to be if (!active_version()
nhiroki
2014/08/08 06:31:45
Done.
|
| + registration()->NotifyRegistrationFailed(); |
| context_->storage()->DeleteRegistration( |
| registration()->id(), |
| registration()->script_url().GetOrigin(), |
| @@ -453,77 +451,19 @@ 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::AssociateProviderHostsToRegistration( |
| + 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); |
| + if (host->CanAssociateRegistration(registration)) |
| + host->AssociateRegistration(registration); |
| } |
| } |
| } |
| -// 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 |