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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // WebServiceWorkerRegistrationImpl constructor calls | 308 // WebServiceWorkerRegistrationImpl constructor calls |
309 // AddServiceWorkerRegistration. | 309 // AddServiceWorkerRegistration. |
310 scoped_refptr<WebServiceWorkerRegistrationImpl> registration( | 310 scoped_refptr<WebServiceWorkerRegistrationImpl> registration( |
311 new WebServiceWorkerRegistrationImpl( | 311 new WebServiceWorkerRegistrationImpl( |
312 ServiceWorkerRegistrationHandleReference::Create( | 312 ServiceWorkerRegistrationHandleReference::Create( |
313 info, thread_safe_sender_.get()))); | 313 info, thread_safe_sender_.get()))); |
314 | 314 |
315 registration->SetInstalling(GetOrCreateServiceWorker(attrs.installing)); | 315 registration->SetInstalling(GetOrCreateServiceWorker(attrs.installing)); |
316 registration->SetWaiting(GetOrCreateServiceWorker(attrs.waiting)); | 316 registration->SetWaiting(GetOrCreateServiceWorker(attrs.waiting)); |
317 registration->SetActive(GetOrCreateServiceWorker(attrs.active)); | 317 registration->SetActive(GetOrCreateServiceWorker(attrs.active)); |
318 return registration.Pass(); | 318 return registration; |
319 } | 319 } |
320 | 320 |
321 scoped_refptr<WebServiceWorkerRegistrationImpl> | 321 scoped_refptr<WebServiceWorkerRegistrationImpl> |
322 ServiceWorkerDispatcher::GetOrAdoptRegistration( | 322 ServiceWorkerDispatcher::GetOrAdoptRegistration( |
323 const ServiceWorkerRegistrationObjectInfo& info, | 323 const ServiceWorkerRegistrationObjectInfo& info, |
324 const ServiceWorkerVersionAttributes& attrs) { | 324 const ServiceWorkerVersionAttributes& attrs) { |
325 RegistrationObjectMap::iterator found = registrations_.find(info.handle_id); | 325 RegistrationObjectMap::iterator found = registrations_.find(info.handle_id); |
326 if (found != registrations_.end()) { | 326 if (found != registrations_.end()) { |
327 ServiceWorkerHandleReference::Adopt(attrs.installing, | 327 ServiceWorkerHandleReference::Adopt(attrs.installing, |
328 thread_safe_sender_.get()); | 328 thread_safe_sender_.get()); |
329 ServiceWorkerHandleReference::Adopt(attrs.waiting, | 329 ServiceWorkerHandleReference::Adopt(attrs.waiting, |
330 thread_safe_sender_.get()); | 330 thread_safe_sender_.get()); |
331 ServiceWorkerHandleReference::Adopt(attrs.active, | 331 ServiceWorkerHandleReference::Adopt(attrs.active, |
332 thread_safe_sender_.get()); | 332 thread_safe_sender_.get()); |
333 ServiceWorkerRegistrationHandleReference::Adopt(info, | 333 ServiceWorkerRegistrationHandleReference::Adopt(info, |
334 thread_safe_sender_.get()); | 334 thread_safe_sender_.get()); |
335 return found->second; | 335 return found->second; |
336 } | 336 } |
337 | 337 |
338 // WebServiceWorkerRegistrationImpl constructor calls | 338 // WebServiceWorkerRegistrationImpl constructor calls |
339 // AddServiceWorkerRegistration. | 339 // AddServiceWorkerRegistration. |
340 scoped_refptr<WebServiceWorkerRegistrationImpl> registration( | 340 scoped_refptr<WebServiceWorkerRegistrationImpl> registration( |
341 new WebServiceWorkerRegistrationImpl( | 341 new WebServiceWorkerRegistrationImpl( |
342 ServiceWorkerRegistrationHandleReference::Adopt( | 342 ServiceWorkerRegistrationHandleReference::Adopt( |
343 info, thread_safe_sender_.get()))); | 343 info, thread_safe_sender_.get()))); |
344 | 344 |
345 registration->SetInstalling(GetOrAdoptServiceWorker(attrs.installing)); | 345 registration->SetInstalling(GetOrAdoptServiceWorker(attrs.installing)); |
346 registration->SetWaiting(GetOrAdoptServiceWorker(attrs.waiting)); | 346 registration->SetWaiting(GetOrAdoptServiceWorker(attrs.waiting)); |
347 registration->SetActive(GetOrAdoptServiceWorker(attrs.active)); | 347 registration->SetActive(GetOrAdoptServiceWorker(attrs.active)); |
348 return registration.Pass(); | 348 return registration; |
349 } | 349 } |
350 | 350 |
351 void ServiceWorkerDispatcher::OnAssociateRegistration( | 351 void ServiceWorkerDispatcher::OnAssociateRegistration( |
352 int thread_id, | 352 int thread_id, |
353 int provider_id, | 353 int provider_id, |
354 const ServiceWorkerRegistrationObjectInfo& info, | 354 const ServiceWorkerRegistrationObjectInfo& info, |
355 const ServiceWorkerVersionAttributes& attrs) { | 355 const ServiceWorkerVersionAttributes& attrs) { |
356 // Adopt the references sent from the browser process and pass them to the | 356 // Adopt the references sent from the browser process and pass them to the |
357 // provider context if it exists. | 357 // provider context if it exists. |
358 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration = | 358 scoped_ptr<ServiceWorkerRegistrationHandleReference> registration = |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 return ServiceWorkerRegistrationHandleReference::Adopt( | 773 return ServiceWorkerRegistrationHandleReference::Adopt( |
774 info, thread_safe_sender_.get()); | 774 info, thread_safe_sender_.get()); |
775 } | 775 } |
776 | 776 |
777 scoped_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( | 777 scoped_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( |
778 const ServiceWorkerObjectInfo& info) { | 778 const ServiceWorkerObjectInfo& info) { |
779 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); | 779 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); |
780 } | 780 } |
781 | 781 |
782 } // namespace content | 782 } // namespace content |
OLD | NEW |