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 135a114c1f98e8e164c8d3c7e2d026a1f673e32c..ee2809687d5dca943903da80f004ef150a5c195e 100644 |
| --- a/content/browser/service_worker/service_worker_register_job.cc |
| +++ b/content/browser/service_worker/service_worker_register_job.cc |
| @@ -45,7 +45,7 @@ void ServiceWorkerRegisterJob::AddCallback(const RegistrationCallback& callback, |
| int process_id) { |
| if (!is_promise_resolved_) { |
| callbacks_.push_back(callback); |
| - if (process_id != -1 && (phase_ < UPDATE || !pending_version())) |
| + if (process_id != -1 && (phase_ < UPDATE || !waiting_version())) |
| pending_process_ids_.push_back(process_id); |
| return; |
| } |
| @@ -92,16 +92,16 @@ ServiceWorkerRegistration* ServiceWorkerRegisterJob::registration() { |
| return internal_.registration; |
| } |
| -void ServiceWorkerRegisterJob::set_pending_version( |
| +void ServiceWorkerRegisterJob::set_waiting_version( |
| ServiceWorkerVersion* version) { |
| DCHECK(phase_ == UPDATE) << phase_; |
| - DCHECK(!internal_.pending_version); |
| - internal_.pending_version = version; |
| + DCHECK(!internal_.waiting_version); |
| + internal_.waiting_version = version; |
| } |
| -ServiceWorkerVersion* ServiceWorkerRegisterJob::pending_version() { |
| +ServiceWorkerVersion* ServiceWorkerRegisterJob::waiting_version() { |
| DCHECK(phase_ >= UPDATE) << phase_; |
| - return internal_.pending_version; |
| + return internal_.waiting_version; |
| } |
| void ServiceWorkerRegisterJob::SetPhase(Phase phase) { |
| @@ -176,7 +176,7 @@ void ServiceWorkerRegisterJob::HandleExistingRegistrationAndContinue( |
| // 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 |
| - // pending_version_ of the existing registration, which isn't in the spec. |
| + // waiting_version_ of the existing registration, which isn't in the spec. |
| // TODO(michaeln): Deactivate the live existing_registration object and |
| // eventually call storage->DeleteVersionResources() |
| // when it no longer has any controllees. |
| @@ -214,20 +214,20 @@ void ServiceWorkerRegisterJob::UpdateAndContinue( |
| return; |
| } |
| - // TODO(falken): "If serviceWorkerRegistration.pendingWorker is not null..." |
| - // then terminate the pending worker. It doesn't make sense to implement yet |
| + // TODO(falken): "If serviceWorkerRegistration.waitingWorker is not null..." |
|
falken
2014/05/29 07:23:34
this is "installingWorker" in the spec
nhiroki
2014/05/30 00:38:20
Done.
|
| + // then terminate the waiting worker. It doesn't make sense to implement yet |
| // since we always activate the worker if install completed, so there can be |
| - // no pending worker at this point. |
| - DCHECK(!registration()->pending_version()); |
| + // no waiting worker at this point. |
| + DCHECK(!registration()->waiting_version()); |
| // "Let serviceWorker be a newly-created ServiceWorker object..." and start |
| // the worker. |
| - set_pending_version(new ServiceWorkerVersion( |
| + set_waiting_version(new ServiceWorkerVersion( |
| registration(), context_->storage()->NewVersionId(), context_)); |
| // TODO(michaeln): Start the worker into a paused state where the |
| // script resource is downloaded but not yet evaluated. |
| - pending_version()->StartWorkerWithCandidateProcesses( |
| + waiting_version()->StartWorkerWithCandidateProcesses( |
| pending_process_ids_, |
| base::Bind(&ServiceWorkerRegisterJob::OnStartWorkerFinished, |
| weak_factory_.GetWeakPtr())); |
| @@ -249,14 +249,14 @@ void ServiceWorkerRegisterJob::OnStartWorkerFinished( |
| // since there's nothing new. |
| // "Resolve promise with serviceWorker." |
| - // Although the spec doesn't set pendingWorker until after resolving the |
| + // Although the spec doesn't set waitingWorker until after resolving the |
| // promise, our system's resolving works by passing ServiceWorkerRegistration |
| - // to the callbacks, so pendingWorker must be set first. |
| - DCHECK(!registration()->pending_version()); |
| - registration()->set_pending_version(pending_version()); |
| - ResolvePromise(status, registration(), pending_version()); |
| + // to the callbacks, so waitingWorker must be set first. |
| + DCHECK(!registration()->waiting_version()); |
| + registration()->set_waiting_version(waiting_version()); |
| + ResolvePromise(status, registration(), waiting_version()); |
| - AssociatePendingVersionToDocuments(pending_version()); |
| + AssociateWaitingVersionToDocuments(waiting_version()); |
| InstallAndContinue(); |
| } |
| @@ -264,9 +264,9 @@ void ServiceWorkerRegisterJob::OnStartWorkerFinished( |
| // This function corresponds to the spec's _Install algorithm. |
| void ServiceWorkerRegisterJob::InstallAndContinue() { |
| SetPhase(INSTALL); |
| - // "Set serviceWorkerRegistration.pendingWorker._state to installing." |
| + // "Set serviceWorkerRegistration.waitingWorker._state to installing." |
|
falken
2014/05/29 07:23:34
the spec now reads "installingWorker.state"
nhiroki
2014/05/30 00:38:20
Done.
|
| // "Fire install event on the associated ServiceWorkerGlobalScope object." |
| - pending_version()->DispatchInstallEvent( |
| + waiting_version()->DispatchInstallEvent( |
| -1, |
| base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished, |
| weak_factory_.GetWeakPtr())); |
| @@ -286,7 +286,7 @@ void ServiceWorkerRegisterJob::OnInstallFinished( |
| SetPhase(STORE); |
| context_->storage()->StoreRegistration( |
| registration(), |
| - pending_version(), |
| + waiting_version(), |
| base::Bind(&ServiceWorkerRegisterJob::OnStoreRegistrationComplete, |
| weak_factory_.GetWeakPtr())); |
| } |
| @@ -323,17 +323,17 @@ void ServiceWorkerRegisterJob::ActivateAndContinue() { |
| return; |
| } |
| - // "Set serviceWorkerRegistration.pendingWorker to null." |
| + // "Set serviceWorkerRegistration.waitingWorker to null." |
| // "Set serviceWorkerRegistration.activeWorker to activatingWorker." |
| - registration()->set_pending_version(NULL); |
| - AssociatePendingVersionToDocuments(NULL); |
| + registration()->set_waiting_version(NULL); |
| + AssociateWaitingVersionToDocuments(NULL); |
| DCHECK(!registration()->active_version()); |
| - registration()->set_active_version(pending_version()); |
| + registration()->set_active_version(waiting_version()); |
| // "Set serviceWorkerRegistration.activeWorker._state to activating." |
| // "Fire activate event on the associated ServiceWorkerGlobalScope object." |
| // "Set serviceWorkerRegistration.activeWorker._state to active." |
| - pending_version()->DispatchActivateEvent( |
| + waiting_version()->DispatchActivateEvent( |
| base::Bind(&ServiceWorkerRegisterJob::OnActivateFinished, |
| weak_factory_.GetWeakPtr())); |
| } |
| @@ -358,9 +358,9 @@ void ServiceWorkerRegisterJob::OnActivateFinished( |
| void ServiceWorkerRegisterJob::Complete(ServiceWorkerStatusCode status) { |
| SetPhase(COMPLETE); |
| if (status != SERVICE_WORKER_OK) { |
| - if (registration() && registration()->pending_version()) { |
| - AssociatePendingVersionToDocuments(NULL); |
| - registration()->set_pending_version(NULL); |
| + if (registration() && registration()->waiting_version()) { |
| + AssociateWaitingVersionToDocuments(NULL); |
| + registration()->set_waiting_version(NULL); |
| } |
| if (registration() && !registration()->active_version()) { |
| context_->storage()->DeleteRegistration( |
| @@ -374,7 +374,7 @@ void ServiceWorkerRegisterJob::Complete(ServiceWorkerStatusCode status) { |
| DCHECK(callbacks_.empty()); |
| if (registration()) { |
| context_->storage()->NotifyDoneInstallingRegistration( |
| - registration(), pending_version(), status); |
| + registration(), waiting_version(), status); |
| } |
| context_->job_coordinator()->FinishJob(pattern_, this); |
| } |
| @@ -396,7 +396,7 @@ void ServiceWorkerRegisterJob::ResolvePromise( |
| callbacks_.clear(); |
| } |
| -void ServiceWorkerRegisterJob::AssociatePendingVersionToDocuments( |
| +void ServiceWorkerRegisterJob::AssociateWaitingVersionToDocuments( |
| ServiceWorkerVersion* version) { |
| // TODO(michaeln): This needs to respect the longest prefix wins |
| // when it comes to finding a registration for a document url. |
| @@ -408,7 +408,7 @@ void ServiceWorkerRegisterJob::AssociatePendingVersionToDocuments( |
| ServiceWorkerProviderHost* provider_host = it->GetProviderHost(); |
| if (ServiceWorkerUtils::ScopeMatches(pattern_, |
| provider_host->document_url())) |
| - provider_host->SetPendingVersion(version); |
| + provider_host->SetWaitingVersion(version); |
|
michaeln1
2014/05/29 21:16:52
Can you put a todo here about how this should be h
nhiroki
2014/05/30 00:38:20
Done.
|
| } |
| } |