Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: content/browser/service_worker/service_worker_register_job.cc

Issue 443593002: ServiceWorker: Move worker candidate process knowledge to ServiceWorkerProcessManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_register_job.h" 5 #include "content/browser/service_worker/service_worker_register_job.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "content/browser/service_worker/service_worker_context_core.h" 10 #include "content/browser/service_worker/service_worker_context_core.h"
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 if (existing_registration.get() && 183 if (existing_registration.get() &&
184 existing_registration->script_url() == script_url_) { 184 existing_registration->script_url() == script_url_) {
185 set_registration(existing_registration); 185 set_registration(existing_registration);
186 // If there's no active version, go ahead to Update (this isn't in the spec 186 // If there's no active version, go ahead to Update (this isn't in the spec
187 // but seems reasonable, and without SoftUpdate implemented we can never 187 // but seems reasonable, and without SoftUpdate implemented we can never
188 // Update otherwise). 188 // Update otherwise).
189 if (!existing_registration->active_version()) { 189 if (!existing_registration->active_version()) {
190 UpdateAndContinue(); 190 UpdateAndContinue();
191 return; 191 return;
192 } 192 }
193
194 existing_registration->active_version()->AddPendingProcesses(
195 pending_process_ids_);
193 ResolvePromise( 196 ResolvePromise(
194 status, existing_registration, existing_registration->active_version()); 197 status, existing_registration, existing_registration->active_version());
195 Complete(SERVICE_WORKER_OK); 198 Complete(SERVICE_WORKER_OK);
196 return; 199 return;
197 } 200 }
198 201
199 // "If serviceWorkerRegistration is null..." create a new registration. 202 // "If serviceWorkerRegistration is null..." create a new registration.
200 if (!existing_registration.get()) { 203 if (!existing_registration.get()) {
201 RegisterAndContinue(SERVICE_WORKER_OK); 204 RegisterAndContinue(SERVICE_WORKER_OK);
202 return; 205 return;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 // TODO(falken): "If serviceWorkerRegistration.installingWorker is not null.." 261 // TODO(falken): "If serviceWorkerRegistration.installingWorker is not null.."
259 // then terminate the installing worker. It doesn't make sense to implement 262 // then terminate the installing worker. It doesn't make sense to implement
260 // yet since we always activate the worker if install completed, so there can 263 // yet since we always activate the worker if install completed, so there can
261 // be no installing worker at this point. 264 // be no installing worker at this point.
262 265
263 // "Let serviceWorker be a newly-created ServiceWorker object..." and start 266 // "Let serviceWorker be a newly-created ServiceWorker object..." and start
264 // the worker. 267 // the worker.
265 set_new_version(new ServiceWorkerVersion( 268 set_new_version(new ServiceWorkerVersion(
266 registration(), context_->storage()->NewVersionId(), context_)); 269 registration(), context_->storage()->NewVersionId(), context_));
267 270
271 new_version()->AddPendingProcesses(pending_process_ids_);
268 bool pause_after_download = job_type_ == UPDATE_JOB; 272 bool pause_after_download = job_type_ == UPDATE_JOB;
269 if (pause_after_download) 273 if (pause_after_download)
270 new_version()->embedded_worker()->AddListener(this); 274 new_version()->embedded_worker()->AddListener(this);
271 new_version()->StartWorkerWithCandidateProcesses( 275 new_version()->StartWorker(
272 pending_process_ids_,
273 pause_after_download, 276 pause_after_download,
274 base::Bind(&ServiceWorkerRegisterJob::OnStartWorkerFinished, 277 base::Bind(&ServiceWorkerRegisterJob::OnStartWorkerFinished,
275 weak_factory_.GetWeakPtr())); 278 weak_factory_.GetWeakPtr()));
276 } 279 }
277 280
278 void ServiceWorkerRegisterJob::OnStartWorkerFinished( 281 void ServiceWorkerRegisterJob::OnStartWorkerFinished(
279 ServiceWorkerStatusCode status) { 282 ServiceWorkerStatusCode status) {
280 // "If serviceWorker fails to start up..." then reject the promise with an 283 // "If serviceWorker fails to start up..." then reject the promise with an
281 // error and abort. 284 // error and abort.
282 if (status != SERVICE_WORKER_OK) { 285 if (status != SERVICE_WORKER_OK) {
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 DCHECK(context); 523 DCHECK(context);
521 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = 524 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it =
522 context->GetProviderHostIterator(); 525 context->GetProviderHostIterator();
523 !it->IsAtEnd(); it->Advance()) { 526 !it->IsAtEnd(); it->Advance()) {
524 ServiceWorkerProviderHost* host = it->GetProviderHost(); 527 ServiceWorkerProviderHost* host = it->GetProviderHost();
525 host->UnsetVersion(version); 528 host->UnsetVersion(version);
526 } 529 }
527 } 530 }
528 531
529 } // namespace content 532 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698