| 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" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "content/browser/service_worker/embedded_worker_status.h" |
| 12 #include "content/browser/service_worker/service_worker_context_core.h" | 13 #include "content/browser/service_worker/service_worker_context_core.h" |
| 13 #include "content/browser/service_worker/service_worker_job_coordinator.h" | 14 #include "content/browser/service_worker/service_worker_job_coordinator.h" |
| 14 #include "content/browser/service_worker/service_worker_metrics.h" | 15 #include "content/browser/service_worker/service_worker_metrics.h" |
| 15 #include "content/browser/service_worker/service_worker_registration.h" | 16 #include "content/browser/service_worker/service_worker_registration.h" |
| 16 #include "content/browser/service_worker/service_worker_storage.h" | 17 #include "content/browser/service_worker/service_worker_storage.h" |
| 17 #include "content/browser/service_worker/service_worker_write_to_cache_job.h" | 18 #include "content/browser/service_worker/service_worker_write_to_cache_job.h" |
| 18 #include "content/common/service_worker/service_worker_messages.h" | 19 #include "content/common/service_worker/service_worker_messages.h" |
| 19 #include "content/common/service_worker/service_worker_types.h" | 20 #include "content/common/service_worker/service_worker_types.h" |
| 20 #include "content/common/service_worker/service_worker_utils.h" | 21 #include "content/common/service_worker/service_worker_utils.h" |
| 21 #include "content/public/browser/browser_thread.h" | 22 #include "content/public/browser/browser_thread.h" |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 // A subsequent registration job may terminate our installing worker. It can | 417 // A subsequent registration job may terminate our installing worker. It can |
| 417 // only do so after we've started the worker and dispatched the install | 418 // only do so after we've started the worker and dispatched the install |
| 418 // event, as those are atomic substeps in the [[Install]] algorithm. | 419 // event, as those are atomic substeps in the [[Install]] algorithm. |
| 419 if (doom_installing_worker_) | 420 if (doom_installing_worker_) |
| 420 Complete(SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED); | 421 Complete(SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED); |
| 421 } | 422 } |
| 422 | 423 |
| 423 void ServiceWorkerRegisterJob::DispatchInstallEvent() { | 424 void ServiceWorkerRegisterJob::DispatchInstallEvent() { |
| 424 DCHECK_EQ(ServiceWorkerVersion::INSTALLING, new_version()->status()) | 425 DCHECK_EQ(ServiceWorkerVersion::INSTALLING, new_version()->status()) |
| 425 << new_version()->status(); | 426 << new_version()->status(); |
| 426 DCHECK_EQ(ServiceWorkerVersion::RUNNING, new_version()->running_status()) | 427 DCHECK_EQ(EmbeddedWorkerStatus::RUNNING, new_version()->running_status()) |
| 427 << "Worker stopped too soon after it was started."; | 428 << "Worker stopped too soon after it was started."; |
| 428 int request_id = new_version()->StartRequest( | 429 int request_id = new_version()->StartRequest( |
| 429 ServiceWorkerMetrics::EventType::INSTALL, | 430 ServiceWorkerMetrics::EventType::INSTALL, |
| 430 base::Bind(&ServiceWorkerRegisterJob::OnInstallFailed, | 431 base::Bind(&ServiceWorkerRegisterJob::OnInstallFailed, |
| 431 weak_factory_.GetWeakPtr())); | 432 weak_factory_.GetWeakPtr())); |
| 432 new_version()->DispatchEvent<ServiceWorkerHostMsg_InstallEventFinished>( | 433 new_version()->DispatchEvent<ServiceWorkerHostMsg_InstallEventFinished>( |
| 433 request_id, ServiceWorkerMsg_InstallEvent(request_id), | 434 request_id, ServiceWorkerMsg_InstallEvent(request_id), |
| 434 base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished, | 435 base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished, |
| 435 weak_factory_.GetWeakPtr())); | 436 weak_factory_.GetWeakPtr())); |
| 436 } | 437 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 new_version()->force_bypass_cache_for_scripts() || | 632 new_version()->force_bypass_cache_for_scripts() || |
| 632 registration()->last_update_check().is_null()) { | 633 registration()->last_update_check().is_null()) { |
| 633 registration()->set_last_update_check(base::Time::Now()); | 634 registration()->set_last_update_check(base::Time::Now()); |
| 634 | 635 |
| 635 if (registration()->has_installed_version()) | 636 if (registration()->has_installed_version()) |
| 636 context_->storage()->UpdateLastUpdateCheckTime(registration()); | 637 context_->storage()->UpdateLastUpdateCheckTime(registration()); |
| 637 } | 638 } |
| 638 } | 639 } |
| 639 | 640 |
| 640 } // namespace content | 641 } // namespace content |
| OLD | NEW |