| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_unregister_job.h" | 5 #include "content/browser/service_worker/service_worker_unregister_job.h" |
| 6 | 6 |
| 7 #include "content/browser/service_worker/service_worker_context_core.h" | 7 #include "content/browser/service_worker/service_worker_context_core.h" |
| 8 #include "content/browser/service_worker/service_worker_job_coordinator.h" | 8 #include "content/browser/service_worker/service_worker_job_coordinator.h" |
| 9 #include "content/browser/service_worker/service_worker_registration.h" | 9 #include "content/browser/service_worker/service_worker_registration.h" |
| 10 #include "content/browser/service_worker/service_worker_storage.h" | 10 #include "content/browser/service_worker/service_worker_storage.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 64 |
| 65 DCHECK(registration); | 65 DCHECK(registration); |
| 66 DeleteRegistration(registration); | 66 DeleteRegistration(registration); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void ServiceWorkerUnregisterJob::DeleteRegistration( | 69 void ServiceWorkerUnregisterJob::DeleteRegistration( |
| 70 const scoped_refptr<ServiceWorkerRegistration>& registration) { | 70 const scoped_refptr<ServiceWorkerRegistration>& registration) { |
| 71 // TODO(nhiroki): When we've implemented the installing version, terminate and | 71 // TODO(nhiroki): When we've implemented the installing version, terminate and |
| 72 // set it to redundant here as per spec. | 72 // set it to redundant here as per spec. |
| 73 | 73 |
| 74 if (registration->active_version()) { |
| 75 registration->active_version()->SetStatus( |
| 76 ServiceWorkerVersion::REDUNDANT); |
| 77 } |
| 78 |
| 74 if (registration->waiting_version()) { | 79 if (registration->waiting_version()) { |
| 75 registration->waiting_version()->SetStatus( | 80 registration->waiting_version()->SetStatus( |
| 76 ServiceWorkerVersion::REDUNDANT); | 81 ServiceWorkerVersion::REDUNDANT); |
| 77 } | 82 } |
| 78 | 83 |
| 79 // TODO(michaeln): Eventually call storage->DeleteVersionResources() when the | 84 // TODO(michaeln): Eventually call storage->DeleteVersionResources() when the |
| 80 // version no longer has any controllees. | 85 // version no longer has any controllees. |
| 81 context_->storage()->DeleteRegistration( | 86 context_->storage()->DeleteRegistration( |
| 82 registration->id(), | 87 registration->id(), |
| 83 registration->script_url().GetOrigin(), | 88 registration->script_url().GetOrigin(), |
| 84 base::Bind(&ServiceWorkerUnregisterJob::Complete, | 89 base::Bind(&ServiceWorkerUnregisterJob::Complete, |
| 85 weak_factory_.GetWeakPtr())); | 90 weak_factory_.GetWeakPtr())); |
| 86 } | 91 } |
| 87 | 92 |
| 88 void ServiceWorkerUnregisterJob::Complete(ServiceWorkerStatusCode status) { | 93 void ServiceWorkerUnregisterJob::Complete(ServiceWorkerStatusCode status) { |
| 89 CompleteInternal(status); | 94 CompleteInternal(status); |
| 90 context_->job_coordinator()->FinishJob(pattern_, this); | 95 context_->job_coordinator()->FinishJob(pattern_, this); |
| 91 } | 96 } |
| 92 | 97 |
| 93 void ServiceWorkerUnregisterJob::CompleteInternal( | 98 void ServiceWorkerUnregisterJob::CompleteInternal( |
| 94 ServiceWorkerStatusCode status) { | 99 ServiceWorkerStatusCode status) { |
| 95 for (std::vector<UnregistrationCallback>::iterator it = callbacks_.begin(); | 100 for (std::vector<UnregistrationCallback>::iterator it = callbacks_.begin(); |
| 96 it != callbacks_.end(); | 101 it != callbacks_.end(); |
| 97 ++it) { | 102 ++it) { |
| 98 it->Run(status); | 103 it->Run(status); |
| 99 } | 104 } |
| 100 } | 105 } |
| 101 | 106 |
| 102 } // namespace content | 107 } // namespace content |
| OLD | NEW |