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 15 matching lines...) Expand all Loading... |
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() { |
| 36 DCHECK(registration_); |
36 registration_->RemoveListener(this); | 37 registration_->RemoveListener(this); |
37 } | 38 } |
38 | 39 |
39 void ServiceWorkerRegistrationHandle::IncrementRefCount() { | 40 void ServiceWorkerRegistrationHandle::IncrementRefCount() { |
40 DCHECK_GT(ref_count_, 0); | 41 DCHECK_GT(ref_count_, 0); |
41 ++ref_count_; | 42 ++ref_count_; |
42 } | 43 } |
43 | 44 |
44 void ServiceWorkerRegistrationHandle::DecrementRefCount() { | 45 void ServiceWorkerRegistrationHandle::DecrementRefCount() { |
45 DCHECK_GT(ref_count_, 0); | 46 DCHECK_GT(ref_count_, 0); |
46 --ref_count_; | 47 --ref_count_; |
47 } | 48 } |
48 | 49 |
49 void ServiceWorkerRegistrationHandle::OnVersionAttributesChanged( | 50 void ServiceWorkerRegistrationHandle::OnVersionAttributesChanged( |
50 ServiceWorkerRegistration* registration, | 51 ServiceWorkerRegistration* registration, |
51 ChangedVersionAttributesMask changed_mask, | 52 ChangedVersionAttributesMask changed_mask, |
52 const ServiceWorkerRegistrationInfo& info) { | 53 const ServiceWorkerRegistrationInfo& info) { |
53 DCHECK_EQ(registration->id(), registration_->id()); | 54 DCHECK_EQ(registration->id(), registration_->id()); |
54 SetVersionAttributes(registration->installing_version(), | 55 SetVersionAttributes(registration->installing_version(), |
55 registration->waiting_version(), | 56 registration->waiting_version(), |
56 registration->active_version()); | 57 registration->active_version()); |
57 } | 58 } |
58 | 59 |
59 void ServiceWorkerRegistrationHandle::OnRegistrationFailed( | 60 void ServiceWorkerRegistrationHandle::OnRegistrationFailed( |
60 ServiceWorkerRegistration* registration) { | 61 ServiceWorkerRegistration* registration) { |
61 DCHECK_EQ(registration->id(), registration_->id()); | 62 DCHECK_EQ(registration->id(), registration_->id()); |
62 ClearVersionAttributes(); | 63 ClearVersionAttributes(); |
63 registration_->RemoveListener(this); | |
64 registration_ = NULL; | |
65 } | 64 } |
66 | 65 |
67 void ServiceWorkerRegistrationHandle::SetVersionAttributes( | 66 void ServiceWorkerRegistrationHandle::SetVersionAttributes( |
68 ServiceWorkerVersion* installing_version, | 67 ServiceWorkerVersion* installing_version, |
69 ServiceWorkerVersion* waiting_version, | 68 ServiceWorkerVersion* waiting_version, |
70 ServiceWorkerVersion* active_version) { | 69 ServiceWorkerVersion* active_version) { |
71 ChangedVersionAttributesMask mask; | 70 ChangedVersionAttributesMask mask; |
72 | 71 |
73 if (installing_version != installing_version_) { | 72 if (installing_version != installing_version_) { |
74 installing_version_ = installing_version; | 73 installing_version_ = installing_version; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 kDocumentMainThreadId, | 121 kDocumentMainThreadId, |
123 provider_id_, | 122 provider_id_, |
124 version); | 123 version); |
125 info = handle->GetObjectInfo(); | 124 info = handle->GetObjectInfo(); |
126 dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass()); | 125 dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass()); |
127 } | 126 } |
128 return info; | 127 return info; |
129 } | 128 } |
130 | 129 |
131 } // namespace content | 130 } // namespace content |
OLD | NEW |