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 2276cf87089ee5a4bf10e858f0ae89754e971166..0af0729b1fb2c8f2991f7a3ad9f8626198aec987 100644 |
| --- a/content/browser/service_worker/service_worker_register_job.cc |
| +++ b/content/browser/service_worker/service_worker_register_job.cc |
| @@ -58,12 +58,13 @@ ServiceWorkerRegisterJob::~ServiceWorkerRegisterJob() { |
| << "Jobs should only be interrupted during shutdown."; |
| } |
| -void ServiceWorkerRegisterJob::AddCallback(const RegistrationCallback& callback, |
| - int process_id) { |
| +void ServiceWorkerRegisterJob::AddCallback( |
| + const RegistrationCallback& callback, |
| + ServiceWorkerProviderHost* provider_host) { |
| if (!is_promise_resolved_) { |
| callbacks_.push_back(callback); |
| - if (process_id != -1 && (phase_ < UPDATE || !new_version())) |
| - pending_process_ids_.push_back(process_id); |
| + if (provider_host && (phase_ < UPDATE || !new_version())) |
| + pending_provider_hosts_.push_back(provider_host->AsWeakPtr()); |
|
michaeln
2014/09/04 01:26:32
Why defer till later? Maybe we don't need the pend
xiang
2014/09/04 09:18:37
Yes, you're right, we don't need to pend it anymor
|
| return; |
| } |
| RunSoon(base::Bind( |
| @@ -322,8 +323,8 @@ void ServiceWorkerRegisterJob::UpdateAndContinue() { |
| bool pause_after_download = job_type_ == UPDATE_JOB; |
| if (pause_after_download) |
| new_version()->embedded_worker()->AddListener(this); |
| - new_version()->StartWorkerWithCandidateProcesses( |
| - pending_process_ids_, |
| + AssociateProviderHostsToPendingRegistration(registration()); |
| + new_version()->StartWorker( |
| pause_after_download, |
| base::Bind(&ServiceWorkerRegisterJob::OnStartWorkerFinished, |
| weak_factory_.GetWeakPtr())); |
| @@ -540,4 +541,15 @@ void ServiceWorkerRegisterJob::AssociateProviderHostsToRegistration( |
| } |
| } |
| +void ServiceWorkerRegisterJob::AssociateProviderHostsToPendingRegistration( |
| + ServiceWorkerRegistration* registration) { |
| + DCHECK(registration); |
| + for (std::vector<base::WeakPtr<ServiceWorkerProviderHost> >::iterator it = |
| + pending_provider_hosts_.begin(); |
| + it != pending_provider_hosts_.end(); ++it) { |
| + if (*it) |
| + (*it)->AssociatePendingRegistration(registration); |
| + } |
| +} |
| + |
| } // namespace content |