Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_handle.h" | 5 #include "content/browser/service_worker/service_worker_registration_handle.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_dispatcher_host.h" | 8 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
| 9 #include "content/browser/service_worker/service_worker_handle.h" | 9 #include "content/browser/service_worker/service_worker_handle.h" |
| 10 #include "content/common/service_worker/service_worker_messages.h" | 10 #include "content/common/service_worker/service_worker_messages.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 : kInvalidServiceWorkerRegistrationHandleId), | 25 : kInvalidServiceWorkerRegistrationHandleId), |
| 26 ref_count_(1), | 26 ref_count_(1), |
| 27 registration_(registration) { | 27 registration_(registration) { |
| 28 DCHECK(registration_); | 28 DCHECK(registration_); |
| 29 SetVersionAttributes(registration->installing_version(), | 29 SetVersionAttributes(registration->installing_version(), |
| 30 registration->waiting_version(), | 30 registration->waiting_version(), |
| 31 registration->active_version()); | 31 registration->active_version()); |
| 32 registration_->AddListener(this); | 32 registration_->AddListener(this); |
| 33 } | 33 } |
| 34 | 34 |
| 35 ServiceWorkerRegistrationHandle::~ServiceWorkerRegistrationHandle() { | 35 ServiceWorkerRegistrationHandle::~ServiceWorkerRegistrationHandle() { |
|
nhiroki
2014/08/14 08:39:07
Can we have DCHECK for |registration_| here?
falken
2014/08/14 09:07:21
Done.
| |
| 36 registration_->RemoveListener(this); | 36 registration_->RemoveListener(this); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void ServiceWorkerRegistrationHandle::IncrementRefCount() { | 39 void ServiceWorkerRegistrationHandle::IncrementRefCount() { |
| 40 DCHECK_GT(ref_count_, 0); | 40 DCHECK_GT(ref_count_, 0); |
| 41 ++ref_count_; | 41 ++ref_count_; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void ServiceWorkerRegistrationHandle::DecrementRefCount() { | 44 void ServiceWorkerRegistrationHandle::DecrementRefCount() { |
| 45 DCHECK_GT(ref_count_, 0); | 45 DCHECK_GT(ref_count_, 0); |
| 46 --ref_count_; | 46 --ref_count_; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ServiceWorkerRegistrationHandle::OnVersionAttributesChanged( | 49 void ServiceWorkerRegistrationHandle::OnVersionAttributesChanged( |
| 50 ServiceWorkerRegistration* registration, | 50 ServiceWorkerRegistration* registration, |
| 51 ChangedVersionAttributesMask changed_mask, | 51 ChangedVersionAttributesMask changed_mask, |
| 52 const ServiceWorkerRegistrationInfo& info) { | 52 const ServiceWorkerRegistrationInfo& info) { |
| 53 DCHECK_EQ(registration->id(), registration_->id()); | 53 DCHECK_EQ(registration->id(), registration_->id()); |
| 54 SetVersionAttributes(registration->installing_version(), | 54 SetVersionAttributes(registration->installing_version(), |
| 55 registration->waiting_version(), | 55 registration->waiting_version(), |
| 56 registration->active_version()); | 56 registration->active_version()); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void ServiceWorkerRegistrationHandle::OnRegistrationFailed( | 59 void ServiceWorkerRegistrationHandle::OnRegistrationFailed( |
| 60 ServiceWorkerRegistration* registration) { | 60 ServiceWorkerRegistration* registration) { |
| 61 DCHECK_EQ(registration->id(), registration_->id()); | 61 DCHECK_EQ(registration->id(), registration_->id()); |
| 62 ClearVersionAttributes(); | 62 ClearVersionAttributes(); |
| 63 registration_->RemoveListener(this); | |
| 64 registration_ = NULL; | |
| 65 } | 63 } |
| 66 | 64 |
| 67 void ServiceWorkerRegistrationHandle::SetVersionAttributes( | 65 void ServiceWorkerRegistrationHandle::SetVersionAttributes( |
| 68 ServiceWorkerVersion* installing_version, | 66 ServiceWorkerVersion* installing_version, |
| 69 ServiceWorkerVersion* waiting_version, | 67 ServiceWorkerVersion* waiting_version, |
| 70 ServiceWorkerVersion* active_version) { | 68 ServiceWorkerVersion* active_version) { |
| 71 ChangedVersionAttributesMask mask; | 69 ChangedVersionAttributesMask mask; |
| 72 | 70 |
| 73 if (installing_version != installing_version_) { | 71 if (installing_version != installing_version_) { |
| 74 installing_version_ = installing_version; | 72 installing_version_ = installing_version; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 kDocumentMainThreadId, | 120 kDocumentMainThreadId, |
| 123 provider_id_, | 121 provider_id_, |
| 124 version); | 122 version); |
| 125 info = handle->GetObjectInfo(); | 123 info = handle->GetObjectInfo(); |
| 126 dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass()); | 124 dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass()); |
| 127 } | 125 } |
| 128 return info; | 126 return info; |
| 129 } | 127 } |
| 130 | 128 |
| 131 } // namespace content | 129 } // namespace content |
| OLD | NEW |