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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 request_id, | 416 request_id, |
417 "OnUnregistered"); | 417 "OnUnregistered"); |
418 TRACE_EVENT_ASYNC_END0("ServiceWorker", | 418 TRACE_EVENT_ASYNC_END0("ServiceWorker", |
419 "ServiceWorkerDispatcher::UnregisterServiceWorker", | 419 "ServiceWorkerDispatcher::UnregisterServiceWorker", |
420 request_id); | 420 request_id); |
421 WebServiceWorkerUnregistrationCallbacks* callbacks = | 421 WebServiceWorkerUnregistrationCallbacks* callbacks = |
422 pending_unregistration_callbacks_.Lookup(request_id); | 422 pending_unregistration_callbacks_.Lookup(request_id); |
423 DCHECK(callbacks); | 423 DCHECK(callbacks); |
424 if (!callbacks) | 424 if (!callbacks) |
425 return; | 425 return; |
426 callbacks->onSuccess(&is_success); | 426 callbacks->onSuccess(is_success); |
427 pending_unregistration_callbacks_.Remove(request_id); | 427 pending_unregistration_callbacks_.Remove(request_id); |
428 } | 428 } |
429 | 429 |
430 void ServiceWorkerDispatcher::OnDidGetRegistration( | 430 void ServiceWorkerDispatcher::OnDidGetRegistration( |
431 int thread_id, | 431 int thread_id, |
432 int request_id, | 432 int request_id, |
433 const ServiceWorkerRegistrationObjectInfo& info, | 433 const ServiceWorkerRegistrationObjectInfo& info, |
434 const ServiceWorkerVersionAttributes& attrs) { | 434 const ServiceWorkerVersionAttributes& attrs) { |
435 TRACE_EVENT_ASYNC_STEP_INTO0( | 435 TRACE_EVENT_ASYNC_STEP_INTO0( |
436 "ServiceWorker", | 436 "ServiceWorker", |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 request_id, "OnUpdateError"); | 550 request_id, "OnUpdateError"); |
551 TRACE_EVENT_ASYNC_END0("ServiceWorker", | 551 TRACE_EVENT_ASYNC_END0("ServiceWorker", |
552 "ServiceWorkerDispatcher::UpdateServiceWorker", | 552 "ServiceWorkerDispatcher::UpdateServiceWorker", |
553 request_id); | 553 request_id); |
554 WebServiceWorkerUpdateCallbacks* callbacks = | 554 WebServiceWorkerUpdateCallbacks* callbacks = |
555 pending_update_callbacks_.Lookup(request_id); | 555 pending_update_callbacks_.Lookup(request_id); |
556 DCHECK(callbacks); | 556 DCHECK(callbacks); |
557 if (!callbacks) | 557 if (!callbacks) |
558 return; | 558 return; |
559 | 559 |
560 callbacks->onError(new WebServiceWorkerError(error_type, message)); | 560 callbacks->onError(WebServiceWorkerError(error_type, message)); |
561 pending_update_callbacks_.Remove(request_id); | 561 pending_update_callbacks_.Remove(request_id); |
562 } | 562 } |
563 | 563 |
564 void ServiceWorkerDispatcher::OnUnregistrationError( | 564 void ServiceWorkerDispatcher::OnUnregistrationError( |
565 int thread_id, | 565 int thread_id, |
566 int request_id, | 566 int request_id, |
567 WebServiceWorkerError::ErrorType error_type, | 567 WebServiceWorkerError::ErrorType error_type, |
568 const base::string16& message) { | 568 const base::string16& message) { |
569 TRACE_EVENT_ASYNC_STEP_INTO0( | 569 TRACE_EVENT_ASYNC_STEP_INTO0( |
570 "ServiceWorker", | 570 "ServiceWorker", |
571 "ServiceWorkerDispatcher::UnregisterServiceWorker", | 571 "ServiceWorkerDispatcher::UnregisterServiceWorker", |
572 request_id, | 572 request_id, |
573 "OnUnregistrationError"); | 573 "OnUnregistrationError"); |
574 TRACE_EVENT_ASYNC_END0("ServiceWorker", | 574 TRACE_EVENT_ASYNC_END0("ServiceWorker", |
575 "ServiceWorkerDispatcher::UnregisterServiceWorker", | 575 "ServiceWorkerDispatcher::UnregisterServiceWorker", |
576 request_id); | 576 request_id); |
577 WebServiceWorkerUnregistrationCallbacks* callbacks = | 577 WebServiceWorkerUnregistrationCallbacks* callbacks = |
578 pending_unregistration_callbacks_.Lookup(request_id); | 578 pending_unregistration_callbacks_.Lookup(request_id); |
579 DCHECK(callbacks); | 579 DCHECK(callbacks); |
580 if (!callbacks) | 580 if (!callbacks) |
581 return; | 581 return; |
582 | 582 |
583 scoped_ptr<WebServiceWorkerError> error( | 583 callbacks->onError(WebServiceWorkerError(error_type, message)); |
584 new WebServiceWorkerError(error_type, message)); | |
585 callbacks->onError(error.release()); | |
586 pending_unregistration_callbacks_.Remove(request_id); | 584 pending_unregistration_callbacks_.Remove(request_id); |
587 } | 585 } |
588 | 586 |
589 void ServiceWorkerDispatcher::OnGetRegistrationError( | 587 void ServiceWorkerDispatcher::OnGetRegistrationError( |
590 int thread_id, | 588 int thread_id, |
591 int request_id, | 589 int request_id, |
592 WebServiceWorkerError::ErrorType error_type, | 590 WebServiceWorkerError::ErrorType error_type, |
593 const base::string16& message) { | 591 const base::string16& message) { |
594 TRACE_EVENT_ASYNC_STEP_INTO0( | 592 TRACE_EVENT_ASYNC_STEP_INTO0( |
595 "ServiceWorker", | 593 "ServiceWorker", |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 bool adopt_handle = true; | 803 bool adopt_handle = true; |
806 WebServiceWorkerRegistrationImpl* registration = | 804 WebServiceWorkerRegistrationImpl* registration = |
807 CreateServiceWorkerRegistration(info, adopt_handle); | 805 CreateServiceWorkerRegistration(info, adopt_handle); |
808 registration->SetInstalling(GetServiceWorker(attrs.installing, adopt_handle)); | 806 registration->SetInstalling(GetServiceWorker(attrs.installing, adopt_handle)); |
809 registration->SetWaiting(GetServiceWorker(attrs.waiting, adopt_handle)); | 807 registration->SetWaiting(GetServiceWorker(attrs.waiting, adopt_handle)); |
810 registration->SetActive(GetServiceWorker(attrs.active, adopt_handle)); | 808 registration->SetActive(GetServiceWorker(attrs.active, adopt_handle)); |
811 return registration; | 809 return registration; |
812 } | 810 } |
813 | 811 |
814 } // namespace content | 812 } // namespace content |
OLD | NEW |