OLD | NEW |
---|---|
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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
385 } | 385 } |
386 | 386 |
387 void ServiceWorkerRegisterJob::CompleteInternal( | 387 void ServiceWorkerRegisterJob::CompleteInternal( |
388 ServiceWorkerStatusCode status) { | 388 ServiceWorkerStatusCode status) { |
389 SetPhase(COMPLETE); | 389 SetPhase(COMPLETE); |
390 if (status != SERVICE_WORKER_OK) { | 390 if (status != SERVICE_WORKER_OK) { |
391 if (registration()) { | 391 if (registration()) { |
392 if (new_version()) { | 392 if (new_version()) { |
393 new_version()->SetStatus(ServiceWorkerVersion::REDUNDANT); | 393 new_version()->SetStatus(ServiceWorkerVersion::REDUNDANT); |
394 DisassociateVersionFromDocuments(context_, new_version()); | 394 DisassociateVersionFromDocuments(context_, new_version()); |
395 registration()->UnsetVersion(new_version()); | 395 registration()->UnsetVersion(new_version()); |
michaeln
2014/07/11 01:16:05
I think the call to Doom() could go in here.
falken
2014/07/11 12:08:12
I think you're right. We can't have new_version()
| |
396 } | 396 } |
397 if (!registration()->active_version()) { | 397 if (!registration()->active_version()) { |
398 context_->storage()->DeleteRegistration( | 398 context_->storage()->DeleteRegistration( |
399 registration()->id(), | 399 registration()->id(), |
400 registration()->script_url().GetOrigin(), | 400 registration()->script_url().GetOrigin(), |
401 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 401 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
402 } | 402 } |
403 } | 403 } |
404 if (!is_promise_resolved_) | 404 if (!is_promise_resolved_) |
405 ResolvePromise(status, NULL, NULL); | 405 ResolvePromise(status, NULL, NULL); |
406 } | 406 } |
407 DCHECK(callbacks_.empty()); | 407 DCHECK(callbacks_.empty()); |
408 if (registration()) { | 408 if (registration()) { |
409 context_->storage()->NotifyDoneInstallingRegistration( | 409 context_->storage()->NotifyDoneInstallingRegistration( |
410 registration(), new_version(), status); | 410 registration(), new_version(), status); |
411 } | 411 } |
412 if (new_version()) | 412 if (new_version()) { |
413 new_version()->embedded_worker()->RemoveListener(this); | 413 new_version()->embedded_worker()->RemoveListener(this); |
414 if (status != SERVICE_WORKER_OK) | |
415 new_version()->Doom(); | |
416 } | |
414 } | 417 } |
415 | 418 |
416 void ServiceWorkerRegisterJob::ResolvePromise( | 419 void ServiceWorkerRegisterJob::ResolvePromise( |
417 ServiceWorkerStatusCode status, | 420 ServiceWorkerStatusCode status, |
418 ServiceWorkerRegistration* registration, | 421 ServiceWorkerRegistration* registration, |
419 ServiceWorkerVersion* version) { | 422 ServiceWorkerVersion* version) { |
420 DCHECK(!is_promise_resolved_); | 423 DCHECK(!is_promise_resolved_); |
421 is_promise_resolved_ = true; | 424 is_promise_resolved_ = true; |
422 promise_resolved_status_ = status; | 425 promise_resolved_status_ = status; |
423 promise_resolved_registration_ = registration; | 426 promise_resolved_registration_ = registration; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 DCHECK(context); | 514 DCHECK(context); |
512 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = | 515 for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it = |
513 context->GetProviderHostIterator(); | 516 context->GetProviderHostIterator(); |
514 !it->IsAtEnd(); it->Advance()) { | 517 !it->IsAtEnd(); it->Advance()) { |
515 ServiceWorkerProviderHost* host = it->GetProviderHost(); | 518 ServiceWorkerProviderHost* host = it->GetProviderHost(); |
516 host->UnsetVersion(version); | 519 host->UnsetVersion(version); |
517 } | 520 } |
518 } | 521 } |
519 | 522 |
520 } // namespace content | 523 } // namespace content |
OLD | NEW |