Chromium Code Reviews| 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" | |
| 8 #include "content/browser/service_worker/embedded_worker_instance.h" | |
| 9 #include "content/browser/service_worker/embedded_worker_registry.h" | |
| 10 #include "content/browser/service_worker/service_worker_context_core.h" | |
| 7 #include "content/browser/service_worker/service_worker_registration.h" | 11 #include "content/browser/service_worker/service_worker_registration.h" |
| 8 | 12 |
| 9 namespace content { | 13 namespace content { |
| 10 | 14 |
| 11 ServiceWorkerVersion::ServiceWorkerVersion( | 15 ServiceWorkerVersion::ServiceWorkerVersion( |
| 12 ServiceWorkerRegistration* registration) | 16 ServiceWorkerRegistration* registration, |
| 13 : is_shutdown_(false), registration_(registration) {} | 17 EmbeddedWorkerRegistry* worker_registry, |
| 18 int version_id) | |
| 19 : version_id_(version_id), | |
| 20 is_shutdown_(false), | |
| 21 registration_(registration) { | |
| 22 if (worker_registry) | |
| 23 embedded_worker_ = worker_registry->CreateWorker(); | |
| 24 } | |
| 14 | 25 |
| 15 ServiceWorkerVersion::~ServiceWorkerVersion() { DCHECK(is_shutdown_); } | 26 ServiceWorkerVersion::~ServiceWorkerVersion() { |
|
alecflett
2013/12/05 05:18:42
I've been 'git cl format'ing my CL's before review
kinuko
2013/12/09 14:07:42
Ok, reverted.
| |
| 27 DCHECK(is_shutdown_); | |
| 28 } | |
| 16 | 29 |
| 17 void ServiceWorkerVersion::Shutdown() { | 30 void ServiceWorkerVersion::Shutdown() { |
| 18 is_shutdown_ = true; | 31 is_shutdown_ = true; |
| 19 registration_ = NULL; | 32 registration_ = NULL; |
| 33 embedded_worker_.reset(); | |
| 34 } | |
| 35 | |
| 36 void ServiceWorkerVersion::StartWorker() { | |
| 37 DCHECK(!is_shutdown_); | |
| 38 DCHECK(registration_); | |
| 39 embedded_worker_->Start(version_id_, registration_->script_url()); | |
| 40 } | |
| 41 | |
| 42 void ServiceWorkerVersion::StopWorker() { | |
| 43 DCHECK(!is_shutdown_); | |
| 44 embedded_worker_->Stop(); | |
| 45 } | |
| 46 | |
| 47 void ServiceWorkerVersion::OnAssociateProvider( | |
| 48 ServiceWorkerProviderHost* provider_host) { | |
| 49 DCHECK(!is_shutdown_); | |
| 50 embedded_worker_->AddProcessReference(provider_host->process_id()); | |
| 51 } | |
| 52 | |
| 53 void ServiceWorkerVersion::OnUnassociateProvider( | |
| 54 ServiceWorkerProviderHost* provider_host) { | |
| 55 embedded_worker_->ReleaseProcessReference(provider_host->process_id()); | |
| 20 } | 56 } |
| 21 | 57 |
| 22 } // namespace content | 58 } // namespace content |
| OLD | NEW |