| 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 "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
| 8 #include "content/child/child_thread_impl.h" | 8 #include "content/child/child_thread_impl.h" |
| 9 #include "content/child/service_worker/service_worker_dispatcher.h" | 9 #include "content/child/service_worker/service_worker_dispatcher.h" |
| 10 #include "content/child/service_worker/service_worker_handle_reference.h" | 10 #include "content/child/service_worker/service_worker_handle_reference.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 | 156 |
| 157 ServiceWorkerProviderContext::~ServiceWorkerProviderContext() { | 157 ServiceWorkerProviderContext::~ServiceWorkerProviderContext() { |
| 158 if (ServiceWorkerDispatcher* dispatcher = | 158 if (ServiceWorkerDispatcher* dispatcher = |
| 159 ServiceWorkerDispatcher::GetThreadSpecificInstance()) { | 159 ServiceWorkerDispatcher::GetThreadSpecificInstance()) { |
| 160 // Remove this context from the dispatcher living on the main thread. | 160 // Remove this context from the dispatcher living on the main thread. |
| 161 dispatcher->RemoveProviderContext(this); | 161 dispatcher->RemoveProviderContext(this); |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 void ServiceWorkerProviderContext::OnAssociateRegistration( | 165 void ServiceWorkerProviderContext::OnAssociateRegistration( |
| 166 const ServiceWorkerRegistrationObjectInfo& info, | 166 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration, |
| 167 const ServiceWorkerVersionAttributes& attrs) { | 167 scoped_ptr<ServiceWorkerHandleReference> installing, |
| 168 scoped_ptr<ServiceWorkerHandleReference> waiting, |
| 169 scoped_ptr<ServiceWorkerHandleReference> active) { |
| 168 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 170 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
| 169 delegate_->AssociateRegistration( | 171 delegate_->AssociateRegistration(registration.Pass(), installing.Pass(), |
| 170 ServiceWorkerRegistrationHandleReference::Adopt( | 172 waiting.Pass(), active.Pass()); |
| 171 info, thread_safe_sender_.get()), | |
| 172 ServiceWorkerHandleReference::Adopt(attrs.installing, | |
| 173 thread_safe_sender_.get()), | |
| 174 ServiceWorkerHandleReference::Adopt(attrs.waiting, | |
| 175 thread_safe_sender_.get()), | |
| 176 ServiceWorkerHandleReference::Adopt(attrs.active, | |
| 177 thread_safe_sender_.get())); | |
| 178 } | 173 } |
| 179 | 174 |
| 180 void ServiceWorkerProviderContext::OnDisassociateRegistration() { | 175 void ServiceWorkerProviderContext::OnDisassociateRegistration() { |
| 181 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 176 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
| 182 delegate_->DisassociateRegistration(); | 177 delegate_->DisassociateRegistration(); |
| 183 } | 178 } |
| 184 | 179 |
| 185 void ServiceWorkerProviderContext::OnSetControllerServiceWorker( | 180 void ServiceWorkerProviderContext::OnSetControllerServiceWorker( |
| 186 scoped_ptr<ServiceWorkerHandleReference> controller) { | 181 scoped_ptr<ServiceWorkerHandleReference> controller) { |
| 187 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); | 182 DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 202 | 197 |
| 203 void ServiceWorkerProviderContext::DestructOnMainThread() const { | 198 void ServiceWorkerProviderContext::DestructOnMainThread() const { |
| 204 if (!main_thread_task_runner_->RunsTasksOnCurrentThread() && | 199 if (!main_thread_task_runner_->RunsTasksOnCurrentThread() && |
| 205 main_thread_task_runner_->DeleteSoon(FROM_HERE, this)) { | 200 main_thread_task_runner_->DeleteSoon(FROM_HERE, this)) { |
| 206 return; | 201 return; |
| 207 } | 202 } |
| 208 delete this; | 203 delete this; |
| 209 } | 204 } |
| 210 | 205 |
| 211 } // namespace content | 206 } // namespace content |
| OLD | NEW |