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 "content/browser/service_worker/service_worker_job_coordinator.h" | 9 #include "content/browser/service_worker/service_worker_job_coordinator.h" |
10 #include "content/browser/service_worker/service_worker_registration.h" | 10 #include "content/browser/service_worker/service_worker_registration.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 pending_version_->StartWorker(base::Bind(&ServiceWorkerRegisterJob::Complete, | 137 pending_version_->StartWorker(base::Bind(&ServiceWorkerRegisterJob::Complete, |
138 weak_factory_.GetWeakPtr())); | 138 weak_factory_.GetWeakPtr())); |
139 | 139 |
140 // TODO(falken): Don't set the active version until just before | 140 // TODO(falken): Don't set the active version until just before |
141 // the activate event is dispatched. | 141 // the activate event is dispatched. |
142 pending_version_->SetStatus(ServiceWorkerVersion::ACTIVE); | 142 pending_version_->SetStatus(ServiceWorkerVersion::ACTIVE); |
143 registration_->set_active_version(pending_version_); | 143 registration_->set_active_version(pending_version_); |
144 } | 144 } |
145 | 145 |
146 void ServiceWorkerRegisterJob::Complete(ServiceWorkerStatusCode status) { | 146 void ServiceWorkerRegisterJob::Complete(ServiceWorkerStatusCode status) { |
| 147 if (status == SERVICE_WORKER_OK) |
| 148 DCHECK(registration_); |
| 149 else |
| 150 registration_ = NULL; |
| 151 |
147 for (std::vector<RegistrationCallback>::iterator it = callbacks_.begin(); | 152 for (std::vector<RegistrationCallback>::iterator it = callbacks_.begin(); |
148 it != callbacks_.end(); | 153 it != callbacks_.end(); |
149 ++it) { | 154 ++it) { |
150 it->Run(status, registration_); | 155 it->Run(status, registration_); |
151 } | 156 } |
152 coordinator_->FinishJob(pattern_, this); | 157 coordinator_->FinishJob(pattern_, this); |
153 } | 158 } |
154 | 159 |
155 } // namespace content | 160 } // namespace content |
OLD | NEW |