| 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 "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_info.h" | 8 #include "content/browser/service_worker/service_worker_info.h" |
| 9 #include "content/browser/service_worker/service_worker_metrics.h" |
| 9 #include "content/browser/service_worker/service_worker_register_job.h" | 10 #include "content/browser/service_worker/service_worker_register_job.h" |
| 10 #include "content/browser/service_worker/service_worker_utils.h" | 11 #include "content/browser/service_worker/service_worker_utils.h" |
| 11 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 ServiceWorkerVersionInfo GetVersionInfo(ServiceWorkerVersion* version) { | 18 ServiceWorkerVersionInfo GetVersionInfo(ServiceWorkerVersion* version) { |
| 18 if (!version) | 19 if (!version) |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 activating_version->DispatchActivateEvent( | 290 activating_version->DispatchActivateEvent( |
| 290 base::Bind(&ServiceWorkerRegistration::OnActivateEventFinished, | 291 base::Bind(&ServiceWorkerRegistration::OnActivateEventFinished, |
| 291 this, activating_version)); | 292 this, activating_version)); |
| 292 } | 293 } |
| 293 | 294 |
| 294 void ServiceWorkerRegistration::OnActivateEventFinished( | 295 void ServiceWorkerRegistration::OnActivateEventFinished( |
| 295 ServiceWorkerVersion* activating_version, | 296 ServiceWorkerVersion* activating_version, |
| 296 ServiceWorkerStatusCode status) { | 297 ServiceWorkerStatusCode status) { |
| 297 if (!context_ || activating_version != active_version()) | 298 if (!context_ || activating_version != active_version()) |
| 298 return; | 299 return; |
| 300 ServiceWorkerMetrics::RecordActivateEventStatus(status); |
| 301 |
| 299 // "If activateFailed is true, then:..." | 302 // "If activateFailed is true, then:..." |
| 300 if (status != SERVICE_WORKER_OK) { | 303 if (status != SERVICE_WORKER_OK) { |
| 301 // "Set registration's active worker to null." (The spec's step order may | 304 // "Set registration's active worker to null." (The spec's step order may |
| 302 // differ. It's OK because the other steps queue a task.) | 305 // differ. It's OK because the other steps queue a task.) |
| 303 UnsetVersion(activating_version); | 306 UnsetVersion(activating_version); |
| 304 | 307 |
| 305 // "Run the Update State algorithm passing registration's active worker and | 308 // "Run the Update State algorithm passing registration's active worker and |
| 306 // 'redundant' as the arguments." | 309 // 'redundant' as the arguments." |
| 307 activating_version->SetStatus(ServiceWorkerVersion::REDUNDANT); | 310 activating_version->SetStatus(ServiceWorkerVersion::REDUNDANT); |
| 308 | 311 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 if (!context_) { | 392 if (!context_) { |
| 390 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 393 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
| 391 return; | 394 return; |
| 392 } | 395 } |
| 393 context_->storage()->NotifyDoneInstallingRegistration( | 396 context_->storage()->NotifyDoneInstallingRegistration( |
| 394 this, version.get(), status); | 397 this, version.get(), status); |
| 395 callback.Run(status); | 398 callback.Run(status); |
| 396 } | 399 } |
| 397 | 400 |
| 398 } // namespace content | 401 } // namespace content |
| OLD | NEW |