Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 2537953003: WebString: makes string16 conversions explicit (part 1: blink, content) (Closed)
Patch Set: fix Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 "OnRegistrationError"); 615 "OnRegistrationError");
616 TRACE_EVENT_ASYNC_END0("ServiceWorker", 616 TRACE_EVENT_ASYNC_END0("ServiceWorker",
617 "ServiceWorkerDispatcher::RegisterServiceWorker", 617 "ServiceWorkerDispatcher::RegisterServiceWorker",
618 request_id); 618 request_id);
619 WebServiceWorkerRegistrationCallbacks* callbacks = 619 WebServiceWorkerRegistrationCallbacks* callbacks =
620 pending_registration_callbacks_.Lookup(request_id); 620 pending_registration_callbacks_.Lookup(request_id);
621 DCHECK(callbacks); 621 DCHECK(callbacks);
622 if (!callbacks) 622 if (!callbacks)
623 return; 623 return;
624 624
625 callbacks->onError(WebServiceWorkerError(error_type, message)); 625 callbacks->onError(
626 WebServiceWorkerError(error_type, blink::WebString::fromUTF16(message)));
626 pending_registration_callbacks_.Remove(request_id); 627 pending_registration_callbacks_.Remove(request_id);
627 } 628 }
628 629
629 void ServiceWorkerDispatcher::OnUpdateError( 630 void ServiceWorkerDispatcher::OnUpdateError(
630 int thread_id, 631 int thread_id,
631 int request_id, 632 int request_id,
632 WebServiceWorkerError::ErrorType error_type, 633 WebServiceWorkerError::ErrorType error_type,
633 const base::string16& message) { 634 const base::string16& message) {
634 TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker", 635 TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker",
635 "ServiceWorkerDispatcher::UpdateServiceWorker", 636 "ServiceWorkerDispatcher::UpdateServiceWorker",
636 request_id, "OnUpdateError"); 637 request_id, "OnUpdateError");
637 TRACE_EVENT_ASYNC_END0("ServiceWorker", 638 TRACE_EVENT_ASYNC_END0("ServiceWorker",
638 "ServiceWorkerDispatcher::UpdateServiceWorker", 639 "ServiceWorkerDispatcher::UpdateServiceWorker",
639 request_id); 640 request_id);
640 WebServiceWorkerUpdateCallbacks* callbacks = 641 WebServiceWorkerUpdateCallbacks* callbacks =
641 pending_update_callbacks_.Lookup(request_id); 642 pending_update_callbacks_.Lookup(request_id);
642 DCHECK(callbacks); 643 DCHECK(callbacks);
643 if (!callbacks) 644 if (!callbacks)
644 return; 645 return;
645 646
646 callbacks->onError(WebServiceWorkerError(error_type, message)); 647 callbacks->onError(
648 WebServiceWorkerError(error_type, blink::WebString::fromUTF16(message)));
647 pending_update_callbacks_.Remove(request_id); 649 pending_update_callbacks_.Remove(request_id);
648 } 650 }
649 651
650 void ServiceWorkerDispatcher::OnUnregistrationError( 652 void ServiceWorkerDispatcher::OnUnregistrationError(
651 int thread_id, 653 int thread_id,
652 int request_id, 654 int request_id,
653 WebServiceWorkerError::ErrorType error_type, 655 WebServiceWorkerError::ErrorType error_type,
654 const base::string16& message) { 656 const base::string16& message) {
655 TRACE_EVENT_ASYNC_STEP_INTO0( 657 TRACE_EVENT_ASYNC_STEP_INTO0(
656 "ServiceWorker", 658 "ServiceWorker",
657 "ServiceWorkerDispatcher::UnregisterServiceWorker", 659 "ServiceWorkerDispatcher::UnregisterServiceWorker",
658 request_id, 660 request_id,
659 "OnUnregistrationError"); 661 "OnUnregistrationError");
660 TRACE_EVENT_ASYNC_END0("ServiceWorker", 662 TRACE_EVENT_ASYNC_END0("ServiceWorker",
661 "ServiceWorkerDispatcher::UnregisterServiceWorker", 663 "ServiceWorkerDispatcher::UnregisterServiceWorker",
662 request_id); 664 request_id);
663 WebServiceWorkerUnregistrationCallbacks* callbacks = 665 WebServiceWorkerUnregistrationCallbacks* callbacks =
664 pending_unregistration_callbacks_.Lookup(request_id); 666 pending_unregistration_callbacks_.Lookup(request_id);
665 DCHECK(callbacks); 667 DCHECK(callbacks);
666 if (!callbacks) 668 if (!callbacks)
667 return; 669 return;
668 670
669 callbacks->onError(WebServiceWorkerError(error_type, message)); 671 callbacks->onError(
672 WebServiceWorkerError(error_type, blink::WebString::fromUTF16(message)));
670 pending_unregistration_callbacks_.Remove(request_id); 673 pending_unregistration_callbacks_.Remove(request_id);
671 } 674 }
672 675
673 void ServiceWorkerDispatcher::OnGetRegistrationError( 676 void ServiceWorkerDispatcher::OnGetRegistrationError(
674 int thread_id, 677 int thread_id,
675 int request_id, 678 int request_id,
676 WebServiceWorkerError::ErrorType error_type, 679 WebServiceWorkerError::ErrorType error_type,
677 const base::string16& message) { 680 const base::string16& message) {
678 TRACE_EVENT_ASYNC_STEP_INTO0( 681 TRACE_EVENT_ASYNC_STEP_INTO0(
679 "ServiceWorker", 682 "ServiceWorker",
680 "ServiceWorkerDispatcher::GetRegistration", 683 "ServiceWorkerDispatcher::GetRegistration",
681 request_id, 684 request_id,
682 "OnGetRegistrationError"); 685 "OnGetRegistrationError");
683 TRACE_EVENT_ASYNC_END0("ServiceWorker", 686 TRACE_EVENT_ASYNC_END0("ServiceWorker",
684 "ServiceWorkerDispatcher::GetRegistration", 687 "ServiceWorkerDispatcher::GetRegistration",
685 request_id); 688 request_id);
686 WebServiceWorkerGetRegistrationCallbacks* callbacks = 689 WebServiceWorkerGetRegistrationCallbacks* callbacks =
687 pending_get_registration_callbacks_.Lookup(request_id); 690 pending_get_registration_callbacks_.Lookup(request_id);
688 DCHECK(callbacks); 691 DCHECK(callbacks);
689 if (!callbacks) 692 if (!callbacks)
690 return; 693 return;
691 694
692 callbacks->onError(WebServiceWorkerError(error_type, message)); 695 callbacks->onError(
696 WebServiceWorkerError(error_type, blink::WebString::fromUTF16(message)));
693 pending_get_registration_callbacks_.Remove(request_id); 697 pending_get_registration_callbacks_.Remove(request_id);
694 } 698 }
695 699
696 void ServiceWorkerDispatcher::OnGetRegistrationsError( 700 void ServiceWorkerDispatcher::OnGetRegistrationsError(
697 int thread_id, 701 int thread_id,
698 int request_id, 702 int request_id,
699 WebServiceWorkerError::ErrorType error_type, 703 WebServiceWorkerError::ErrorType error_type,
700 const base::string16& message) { 704 const base::string16& message) {
701 TRACE_EVENT_ASYNC_STEP_INTO0( 705 TRACE_EVENT_ASYNC_STEP_INTO0(
702 "ServiceWorker", 706 "ServiceWorker",
703 "ServiceWorkerDispatcher::GetRegistrations", 707 "ServiceWorkerDispatcher::GetRegistrations",
704 request_id, 708 request_id,
705 "OnGetRegistrationsError"); 709 "OnGetRegistrationsError");
706 TRACE_EVENT_ASYNC_END0("ServiceWorker", 710 TRACE_EVENT_ASYNC_END0("ServiceWorker",
707 "ServiceWorkerDispatcher::GetRegistrations", 711 "ServiceWorkerDispatcher::GetRegistrations",
708 request_id); 712 request_id);
709 WebServiceWorkerGetRegistrationsCallbacks* callbacks = 713 WebServiceWorkerGetRegistrationsCallbacks* callbacks =
710 pending_get_registrations_callbacks_.Lookup(request_id); 714 pending_get_registrations_callbacks_.Lookup(request_id);
711 DCHECK(callbacks); 715 DCHECK(callbacks);
712 if (!callbacks) 716 if (!callbacks)
713 return; 717 return;
714 718
715 callbacks->onError(WebServiceWorkerError(error_type, message)); 719 callbacks->onError(
720 WebServiceWorkerError(error_type, blink::WebString::fromUTF16(message)));
716 pending_get_registrations_callbacks_.Remove(request_id); 721 pending_get_registrations_callbacks_.Remove(request_id);
717 } 722 }
718 723
719 void ServiceWorkerDispatcher::OnEnableNavigationPreloadError( 724 void ServiceWorkerDispatcher::OnEnableNavigationPreloadError(
720 int thread_id, 725 int thread_id,
721 int request_id, 726 int request_id,
722 WebServiceWorkerError::ErrorType error_type, 727 WebServiceWorkerError::ErrorType error_type,
723 const std::string& message) { 728 const std::string& message) {
724 WebEnableNavigationPreloadCallbacks* callbacks = 729 WebEnableNavigationPreloadCallbacks* callbacks =
725 enable_navigation_preload_callbacks_.Lookup(request_id); 730 enable_navigation_preload_callbacks_.Lookup(request_id);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 // client. 869 // client.
865 return; 870 return;
866 } 871 }
867 872
868 blink::WebMessagePortChannelArray ports = 873 blink::WebMessagePortChannelArray ports =
869 WebMessagePortChannelImpl::CreatePorts( 874 WebMessagePortChannelImpl::CreatePorts(
870 params.message_ports, params.new_routing_ids, 875 params.message_ports, params.new_routing_ids,
871 base::ThreadTaskRunnerHandle::Get()); 876 base::ThreadTaskRunnerHandle::Get());
872 877
873 found->second->dispatchMessageEvent( 878 found->second->dispatchMessageEvent(
874 WebServiceWorkerImpl::CreateHandle(worker), params.message, ports); 879 WebServiceWorkerImpl::CreateHandle(worker),
880 blink::WebString::fromUTF16(params.message), ports);
875 } 881 }
876 882
877 void ServiceWorkerDispatcher::AddServiceWorker( 883 void ServiceWorkerDispatcher::AddServiceWorker(
878 int handle_id, WebServiceWorkerImpl* worker) { 884 int handle_id, WebServiceWorkerImpl* worker) {
879 DCHECK(!base::ContainsKey(service_workers_, handle_id)); 885 DCHECK(!base::ContainsKey(service_workers_, handle_id));
880 service_workers_[handle_id] = worker; 886 service_workers_[handle_id] = worker;
881 } 887 }
882 888
883 void ServiceWorkerDispatcher::RemoveServiceWorker(int handle_id) { 889 void ServiceWorkerDispatcher::RemoveServiceWorker(int handle_id) {
884 DCHECK(base::ContainsKey(service_workers_, handle_id)); 890 DCHECK(base::ContainsKey(service_workers_, handle_id));
(...skipping 19 matching lines...) Expand all
904 return ServiceWorkerRegistrationHandleReference::Adopt( 910 return ServiceWorkerRegistrationHandleReference::Adopt(
905 info, thread_safe_sender_.get()); 911 info, thread_safe_sender_.get());
906 } 912 }
907 913
908 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( 914 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt(
909 const ServiceWorkerObjectInfo& info) { 915 const ServiceWorkerObjectInfo& info) {
910 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); 916 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get());
911 } 917 }
912 918
913 } // namespace content 919 } // namespace content
OLDNEW
« no previous file with comments | « content/child/notifications/notification_manager.cc ('k') | content/child/service_worker/web_service_worker_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698