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/child/service_worker/service_worker_provider_context.h" | 5 #include "content/child/service_worker/service_worker_provider_context.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
9 #include "content/child/child_thread_impl.h" | 11 #include "content/child/child_thread_impl.h" |
10 #include "content/child/service_worker/service_worker_dispatcher.h" | 12 #include "content/child/service_worker/service_worker_dispatcher.h" |
11 #include "content/child/service_worker/service_worker_handle_reference.h" | 13 #include "content/child/service_worker/service_worker_handle_reference.h" |
12 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" | 14 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" |
13 #include "content/child/thread_safe_sender.h" | 15 #include "content/child/thread_safe_sender.h" |
14 #include "content/child/worker_thread_registry.h" | 16 #include "content/child/worker_thread_registry.h" |
15 | 17 |
16 namespace content { | 18 namespace content { |
(...skipping 23 matching lines...) Expand all Loading... |
40 public: | 42 public: |
41 ControlleeDelegate() {} | 43 ControlleeDelegate() {} |
42 ~ControlleeDelegate() override {} | 44 ~ControlleeDelegate() override {} |
43 | 45 |
44 void AssociateRegistration( | 46 void AssociateRegistration( |
45 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration, | 47 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration, |
46 scoped_ptr<ServiceWorkerHandleReference> installing, | 48 scoped_ptr<ServiceWorkerHandleReference> installing, |
47 scoped_ptr<ServiceWorkerHandleReference> waiting, | 49 scoped_ptr<ServiceWorkerHandleReference> waiting, |
48 scoped_ptr<ServiceWorkerHandleReference> active) override { | 50 scoped_ptr<ServiceWorkerHandleReference> active) override { |
49 DCHECK(!registration_); | 51 DCHECK(!registration_); |
50 registration_ = registration.Pass(); | 52 registration_ = std::move(registration); |
51 } | 53 } |
52 | 54 |
53 void DisassociateRegistration() override { | 55 void DisassociateRegistration() override { |
54 controller_.reset(); | 56 controller_.reset(); |
55 registration_.reset(); | 57 registration_.reset(); |
56 } | 58 } |
57 | 59 |
58 void SetController( | 60 void SetController( |
59 scoped_ptr<ServiceWorkerHandleReference> controller) override { | 61 scoped_ptr<ServiceWorkerHandleReference> controller) override { |
60 DCHECK(registration_); | 62 DCHECK(registration_); |
61 DCHECK(!controller || | 63 DCHECK(!controller || |
62 controller->handle_id() != kInvalidServiceWorkerHandleId); | 64 controller->handle_id() != kInvalidServiceWorkerHandleId); |
63 controller_ = controller.Pass(); | 65 controller_ = std::move(controller); |
64 } | 66 } |
65 | 67 |
66 void GetAssociatedRegistration( | 68 void GetAssociatedRegistration( |
67 ServiceWorkerRegistrationObjectInfo* info, | 69 ServiceWorkerRegistrationObjectInfo* info, |
68 ServiceWorkerVersionAttributes* attrs) override { | 70 ServiceWorkerVersionAttributes* attrs) override { |
69 NOTREACHED(); | 71 NOTREACHED(); |
70 } | 72 } |
71 | 73 |
72 ServiceWorkerHandleReference* controller() override { | 74 ServiceWorkerHandleReference* controller() override { |
73 return controller_.get(); | 75 return controller_.get(); |
(...skipping 13 matching lines...) Expand all Loading... |
87 public: | 89 public: |
88 ControllerDelegate() {} | 90 ControllerDelegate() {} |
89 ~ControllerDelegate() override {} | 91 ~ControllerDelegate() override {} |
90 | 92 |
91 void AssociateRegistration( | 93 void AssociateRegistration( |
92 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration, | 94 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration, |
93 scoped_ptr<ServiceWorkerHandleReference> installing, | 95 scoped_ptr<ServiceWorkerHandleReference> installing, |
94 scoped_ptr<ServiceWorkerHandleReference> waiting, | 96 scoped_ptr<ServiceWorkerHandleReference> waiting, |
95 scoped_ptr<ServiceWorkerHandleReference> active) override { | 97 scoped_ptr<ServiceWorkerHandleReference> active) override { |
96 DCHECK(!registration_); | 98 DCHECK(!registration_); |
97 registration_ = registration.Pass(); | 99 registration_ = std::move(registration); |
98 installing_ = installing.Pass(); | 100 installing_ = std::move(installing); |
99 waiting_ = waiting.Pass(); | 101 waiting_ = std::move(waiting); |
100 active_ = active.Pass(); | 102 active_ = std::move(active); |
101 } | 103 } |
102 | 104 |
103 void DisassociateRegistration() override { | 105 void DisassociateRegistration() override { |
104 // ServiceWorkerGlobalScope is never disassociated. | 106 // ServiceWorkerGlobalScope is never disassociated. |
105 NOTREACHED(); | 107 NOTREACHED(); |
106 } | 108 } |
107 | 109 |
108 void SetController( | 110 void SetController( |
109 scoped_ptr<ServiceWorkerHandleReference> controller) override { | 111 scoped_ptr<ServiceWorkerHandleReference> controller) override { |
110 NOTREACHED(); | 112 NOTREACHED(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 dispatcher->RemoveProviderContext(this); | 164 dispatcher->RemoveProviderContext(this); |
163 } | 165 } |
164 } | 166 } |
165 | 167 |
166 void ServiceWorkerProviderContext::OnAssociateRegistration( | 168 void ServiceWorkerProviderContext::OnAssociateRegistration( |
167 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration, | 169 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration, |
168 scoped_ptr<ServiceWorkerHandleReference> installing, | 170 scoped_ptr<ServiceWorkerHandleReference> installing, |
169 scoped_ptr<ServiceWorkerHandleReference> waiting, | 171 scoped_ptr<ServiceWorkerHandleReference> waiting, |
170 scoped_ptr<ServiceWorkerHandleReference> active) { | 172 scoped_ptr<ServiceWorkerHandleReference> active) { |
171 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 173 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
172 delegate_->AssociateRegistration(registration.Pass(), installing.Pass(), | 174 delegate_->AssociateRegistration(std::move(registration), |
173 waiting.Pass(), active.Pass()); | 175 std::move(installing), std::move(waiting), |
| 176 std::move(active)); |
174 } | 177 } |
175 | 178 |
176 void ServiceWorkerProviderContext::OnDisassociateRegistration() { | 179 void ServiceWorkerProviderContext::OnDisassociateRegistration() { |
177 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 180 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
178 delegate_->DisassociateRegistration(); | 181 delegate_->DisassociateRegistration(); |
179 } | 182 } |
180 | 183 |
181 void ServiceWorkerProviderContext::OnSetControllerServiceWorker( | 184 void ServiceWorkerProviderContext::OnSetControllerServiceWorker( |
182 scoped_ptr<ServiceWorkerHandleReference> controller) { | 185 scoped_ptr<ServiceWorkerHandleReference> controller) { |
183 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 186 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
184 delegate_->SetController(controller.Pass()); | 187 delegate_->SetController(std::move(controller)); |
185 } | 188 } |
186 | 189 |
187 void ServiceWorkerProviderContext::GetAssociatedRegistration( | 190 void ServiceWorkerProviderContext::GetAssociatedRegistration( |
188 ServiceWorkerRegistrationObjectInfo* info, | 191 ServiceWorkerRegistrationObjectInfo* info, |
189 ServiceWorkerVersionAttributes* attrs) { | 192 ServiceWorkerVersionAttributes* attrs) { |
190 DCHECK(!main_thread_task_runner_->RunsTasksOnCurrentThread()); | 193 DCHECK(!main_thread_task_runner_->RunsTasksOnCurrentThread()); |
191 delegate_->GetAssociatedRegistration(info, attrs); | 194 delegate_->GetAssociatedRegistration(info, attrs); |
192 } | 195 } |
193 | 196 |
194 ServiceWorkerHandleReference* ServiceWorkerProviderContext::controller() { | 197 ServiceWorkerHandleReference* ServiceWorkerProviderContext::controller() { |
195 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 198 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
196 return delegate_->controller(); | 199 return delegate_->controller(); |
197 } | 200 } |
198 | 201 |
199 void ServiceWorkerProviderContext::DestructOnMainThread() const { | 202 void ServiceWorkerProviderContext::DestructOnMainThread() const { |
200 if (!main_thread_task_runner_->RunsTasksOnCurrentThread() && | 203 if (!main_thread_task_runner_->RunsTasksOnCurrentThread() && |
201 main_thread_task_runner_->DeleteSoon(FROM_HERE, this)) { | 204 main_thread_task_runner_->DeleteSoon(FROM_HERE, this)) { |
202 return; | 205 return; |
203 } | 206 } |
204 delete this; | 207 delete this; |
205 } | 208 } |
206 | 209 |
207 } // namespace content | 210 } // namespace content |
OLD | NEW |