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..41c150b9c1ab532363b6c6a90b752cb4099c681c 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_)); |
+ AssociateProviderHostToRegistration(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,7 +372,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 +450,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::AssociateProviderHostToRegistration( |
falken
2014/08/06 16:09:35
nit: it's multiple hosts, so s/ProviderHost/Provid
nhiroki
2014/08/07 02:57:27
Done.
|
+ 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->SetRegistration(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 |