| 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_registration.h" | 5 #include "content/browser/service_worker/service_worker_registration.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "content/browser/service_worker/embedded_worker_status.h" | 9 #include "content/browser/service_worker/embedded_worker_status.h" |
| 10 #include "content/browser/service_worker/service_worker_context_core.h" | 10 #include "content/browser/service_worker/service_worker_context_core.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 resources_total_size_bytes_(0), | 42 resources_total_size_bytes_(0), |
| 43 context_(context), | 43 context_(context), |
| 44 task_runner_(base::ThreadTaskRunnerHandle::Get()) { | 44 task_runner_(base::ThreadTaskRunnerHandle::Get()) { |
| 45 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 45 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 46 DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); | 46 DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); |
| 47 DCHECK(context_); | 47 DCHECK(context_); |
| 48 context_->AddLiveRegistration(this); | 48 context_->AddLiveRegistration(this); |
| 49 } | 49 } |
| 50 | 50 |
| 51 ServiceWorkerRegistration::~ServiceWorkerRegistration() { | 51 ServiceWorkerRegistration::~ServiceWorkerRegistration() { |
| 52 // Can be false during shutdown, in which case the DCHECK_CURRENTLY_ON below | |
| 53 // would cry. | |
| 54 if (!BrowserThread::IsThreadInitialized(BrowserThread::IO)) | |
| 55 return; | |
| 56 | |
| 57 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 52 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 58 DCHECK(!listeners_.might_have_observers()); | 53 DCHECK(!listeners_.might_have_observers()); |
| 59 if (context_) | 54 if (context_) |
| 60 context_->RemoveLiveRegistration(registration_id_); | 55 context_->RemoveLiveRegistration(registration_id_); |
| 61 if (active_version()) | 56 if (active_version()) |
| 62 active_version()->RemoveListener(this); | 57 active_version()->RemoveListener(this); |
| 63 } | 58 } |
| 64 | 59 |
| 65 ServiceWorkerVersion* ServiceWorkerRegistration::GetNewestVersion() const { | 60 ServiceWorkerVersion* ServiceWorkerRegistration::GetNewestVersion() const { |
| 66 if (installing_version()) | 61 if (installing_version()) |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 if (!context_) { | 510 if (!context_) { |
| 516 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 511 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
| 517 return; | 512 return; |
| 518 } | 513 } |
| 519 context_->storage()->NotifyDoneInstallingRegistration( | 514 context_->storage()->NotifyDoneInstallingRegistration( |
| 520 this, version.get(), status); | 515 this, version.get(), status); |
| 521 callback.Run(status); | 516 callback.Run(status); |
| 522 } | 517 } |
| 523 | 518 |
| 524 } // namespace content | 519 } // namespace content |
| OLD | NEW |