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/child/service_worker/service_worker_dispatcher.h" | 5 #include "content/child/service_worker/service_worker_dispatcher.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 | 293 |
294 registration->SetInstalling( | 294 registration->SetInstalling( |
295 GetOrCreateServiceWorker(ServiceWorkerHandleReference::Create( | 295 GetOrCreateServiceWorker(ServiceWorkerHandleReference::Create( |
296 attrs.installing, thread_safe_sender_.get()))); | 296 attrs.installing, thread_safe_sender_.get()))); |
297 registration->SetWaiting( | 297 registration->SetWaiting( |
298 GetOrCreateServiceWorker(ServiceWorkerHandleReference::Create( | 298 GetOrCreateServiceWorker(ServiceWorkerHandleReference::Create( |
299 attrs.waiting, thread_safe_sender_.get()))); | 299 attrs.waiting, thread_safe_sender_.get()))); |
300 registration->SetActive( | 300 registration->SetActive( |
301 GetOrCreateServiceWorker(ServiceWorkerHandleReference::Create( | 301 GetOrCreateServiceWorker(ServiceWorkerHandleReference::Create( |
302 attrs.active, thread_safe_sender_.get()))); | 302 attrs.active, thread_safe_sender_.get()))); |
303 return registration.Pass(); | 303 return registration; |
304 } | 304 } |
305 | 305 |
306 scoped_refptr<WebServiceWorkerRegistrationImpl> | 306 scoped_refptr<WebServiceWorkerRegistrationImpl> |
307 ServiceWorkerDispatcher::GetOrAdoptRegistration( | 307 ServiceWorkerDispatcher::GetOrAdoptRegistration( |
308 const ServiceWorkerRegistrationObjectInfo& info, | 308 const ServiceWorkerRegistrationObjectInfo& info, |
309 const ServiceWorkerVersionAttributes& attrs) { | 309 const ServiceWorkerVersionAttributes& attrs) { |
310 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration_ref = | 310 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration_ref = |
311 Adopt(info); | 311 Adopt(info); |
312 scoped_ptr<ServiceWorkerHandleReference> installing_ref = | 312 scoped_ptr<ServiceWorkerHandleReference> installing_ref = |
313 Adopt(attrs.installing); | 313 Adopt(attrs.installing); |
314 scoped_ptr<ServiceWorkerHandleReference> waiting_ref = Adopt(attrs.waiting); | 314 scoped_ptr<ServiceWorkerHandleReference> waiting_ref = Adopt(attrs.waiting); |
315 scoped_ptr<ServiceWorkerHandleReference> active_ref = Adopt(attrs.active); | 315 scoped_ptr<ServiceWorkerHandleReference> active_ref = Adopt(attrs.active); |
316 | 316 |
317 RegistrationObjectMap::iterator found = registrations_.find(info.handle_id); | 317 RegistrationObjectMap::iterator found = registrations_.find(info.handle_id); |
318 if (found != registrations_.end()) | 318 if (found != registrations_.end()) |
319 return found->second; | 319 return found->second; |
320 | 320 |
321 // WebServiceWorkerRegistrationImpl constructor calls | 321 // WebServiceWorkerRegistrationImpl constructor calls |
322 // AddServiceWorkerRegistration. | 322 // AddServiceWorkerRegistration. |
323 scoped_refptr<WebServiceWorkerRegistrationImpl> registration( | 323 scoped_refptr<WebServiceWorkerRegistrationImpl> registration( |
324 new WebServiceWorkerRegistrationImpl(registration_ref.Pass())); | 324 new WebServiceWorkerRegistrationImpl(registration_ref.Pass())); |
325 registration->SetInstalling(GetOrCreateServiceWorker(installing_ref.Pass())); | 325 registration->SetInstalling(GetOrCreateServiceWorker(installing_ref.Pass())); |
326 registration->SetWaiting(GetOrCreateServiceWorker(waiting_ref.Pass())); | 326 registration->SetWaiting(GetOrCreateServiceWorker(waiting_ref.Pass())); |
327 registration->SetActive(GetOrCreateServiceWorker(active_ref.Pass())); | 327 registration->SetActive(GetOrCreateServiceWorker(active_ref.Pass())); |
328 return registration.Pass(); | 328 return registration; |
329 } | 329 } |
330 | 330 |
331 void ServiceWorkerDispatcher::OnAssociateRegistration( | 331 void ServiceWorkerDispatcher::OnAssociateRegistration( |
332 int thread_id, | 332 int thread_id, |
333 int provider_id, | 333 int provider_id, |
334 const ServiceWorkerRegistrationObjectInfo& info, | 334 const ServiceWorkerRegistrationObjectInfo& info, |
335 const ServiceWorkerVersionAttributes& attrs) { | 335 const ServiceWorkerVersionAttributes& attrs) { |
336 // Adopt the references sent from the browser process and pass them to the | 336 // Adopt the references sent from the browser process and pass them to the |
337 // provider context if it exists. | 337 // provider context if it exists. |
338 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration = | 338 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration = |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 return ServiceWorkerRegistrationHandleReference::Adopt( | 762 return ServiceWorkerRegistrationHandleReference::Adopt( |
763 info, thread_safe_sender_.get()); | 763 info, thread_safe_sender_.get()); |
764 } | 764 } |
765 | 765 |
766 scoped_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( | 766 scoped_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( |
767 const ServiceWorkerObjectInfo& info) { | 767 const ServiceWorkerObjectInfo& info) { |
768 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); | 768 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); |
769 } | 769 } |
770 | 770 |
771 } // namespace content | 771 } // namespace content |
OLD | NEW |