| 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_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "content/browser/service_worker/embedded_worker_instance.h" | 8 #include "content/browser/service_worker/embedded_worker_instance.h" |
| 9 #include "content/browser/service_worker/embedded_worker_registry.h" | 9 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 10 #include "content/browser/service_worker/service_worker_context_core.h" | 10 #include "content/browser/service_worker/service_worker_context_core.h" |
| 11 #include "content/browser/service_worker/service_worker_registration.h" | 11 #include "content/browser/service_worker/service_worker_registration.h" |
| 12 #include "content/common/service_worker/service_worker_messages.h" |
| 12 | 13 |
| 13 namespace content { | 14 namespace content { |
| 14 | 15 |
| 15 ServiceWorkerVersion::ServiceWorkerVersion( | 16 ServiceWorkerVersion::ServiceWorkerVersion( |
| 16 ServiceWorkerRegistration* registration, | 17 ServiceWorkerRegistration* registration, |
| 17 EmbeddedWorkerRegistry* worker_registry, | 18 EmbeddedWorkerRegistry* worker_registry, |
| 18 int64 version_id) | 19 int64 version_id) |
| 19 : version_id_(version_id), | 20 : version_id_(version_id), |
| 20 is_shutdown_(false), | 21 is_shutdown_(false), |
| 21 registration_(registration) { | 22 registration_(registration) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 35 DCHECK(!is_shutdown_); | 36 DCHECK(!is_shutdown_); |
| 36 DCHECK(registration_); | 37 DCHECK(registration_); |
| 37 embedded_worker_->Start(version_id_, registration_->script_url()); | 38 embedded_worker_->Start(version_id_, registration_->script_url()); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void ServiceWorkerVersion::StopWorker() { | 41 void ServiceWorkerVersion::StopWorker() { |
| 41 DCHECK(!is_shutdown_); | 42 DCHECK(!is_shutdown_); |
| 42 embedded_worker_->Stop(); | 43 embedded_worker_->Stop(); |
| 43 } | 44 } |
| 44 | 45 |
| 46 bool ServiceWorkerVersion::DispatchFetchEvent( |
| 47 const ServiceWorkerFetchRequest& request) { |
| 48 if (embedded_worker_->status() != EmbeddedWorkerInstance::RUNNING) |
| 49 return false; |
| 50 return embedded_worker_->SendMessage( |
| 51 ServiceWorkerMsg_FetchEvent(request)); |
| 52 } |
| 53 |
| 45 void ServiceWorkerVersion::OnAssociateProvider( | 54 void ServiceWorkerVersion::OnAssociateProvider( |
| 46 ServiceWorkerProviderHost* provider_host) { | 55 ServiceWorkerProviderHost* provider_host) { |
| 47 DCHECK(!is_shutdown_); | 56 DCHECK(!is_shutdown_); |
| 48 embedded_worker_->AddProcessReference(provider_host->process_id()); | 57 embedded_worker_->AddProcessReference(provider_host->process_id()); |
| 49 } | 58 } |
| 50 | 59 |
| 51 void ServiceWorkerVersion::OnUnassociateProvider( | 60 void ServiceWorkerVersion::OnUnassociateProvider( |
| 52 ServiceWorkerProviderHost* provider_host) { | 61 ServiceWorkerProviderHost* provider_host) { |
| 53 embedded_worker_->ReleaseProcessReference(provider_host->process_id()); | 62 embedded_worker_->ReleaseProcessReference(provider_host->process_id()); |
| 54 } | 63 } |
| 55 | 64 |
| 56 } // namespace content | 65 } // namespace content |
| OLD | NEW |