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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); | 410 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); |
411 | 411 |
412 // "Fire a simple event named updatefound..." | 412 // "Fire a simple event named updatefound..." |
413 registration()->NotifyUpdateFound(); | 413 registration()->NotifyUpdateFound(); |
414 | 414 |
415 // "Fire an event named install..." | 415 // "Fire an event named install..." |
416 new_version()->RunAfterStartWorker( | 416 new_version()->RunAfterStartWorker( |
417 base::Bind(&ServiceWorkerRegisterJob::DispatchInstallEvent, | 417 base::Bind(&ServiceWorkerRegisterJob::DispatchInstallEvent, |
418 weak_factory_.GetWeakPtr()), | 418 weak_factory_.GetWeakPtr()), |
419 base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished, | 419 base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished, |
420 weak_factory_.GetWeakPtr())); | 420 weak_factory_.GetWeakPtr()), |
| 421 ServiceWorkerMetrics::EventType::INSTALL); |
421 | 422 |
422 // A subsequent registration job may terminate our installing worker. It can | 423 // A subsequent registration job may terminate our installing worker. It can |
423 // only do so after we've started the worker and dispatched the install | 424 // only do so after we've started the worker and dispatched the install |
424 // event, as those are atomic substeps in the [[Install]] algorithm. | 425 // event, as those are atomic substeps in the [[Install]] algorithm. |
425 if (doom_installing_worker_) | 426 if (doom_installing_worker_) |
426 Complete(SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED); | 427 Complete(SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED); |
427 } | 428 } |
428 | 429 |
429 void ServiceWorkerRegisterJob::DispatchInstallEvent() { | 430 void ServiceWorkerRegisterJob::DispatchInstallEvent() { |
430 DCHECK_EQ(ServiceWorkerVersion::INSTALLING, new_version()->status()) | 431 DCHECK_EQ(ServiceWorkerVersion::INSTALLING, new_version()->status()) |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); | 591 ResolvePromise(SERVICE_WORKER_OK, std::string(), registration()); |
591 Complete(SERVICE_WORKER_ERROR_EXISTS, | 592 Complete(SERVICE_WORKER_ERROR_EXISTS, |
592 "The updated worker is identical to the incumbent."); | 593 "The updated worker is identical to the incumbent."); |
593 return; | 594 return; |
594 } | 595 } |
595 | 596 |
596 new_version()->embedded_worker()->ResumeAfterDownload(); | 597 new_version()->embedded_worker()->ResumeAfterDownload(); |
597 } | 598 } |
598 | 599 |
599 } // namespace content | 600 } // namespace content |
OLD | NEW |