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/browser/service_worker/service_worker_dispatcher_host.h" | 5 #include "content/browser/service_worker/service_worker_dispatcher_host.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/browser/message_port_message_filter.h" | 10 #include "content/browser/message_port_message_filter.h" |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 registration->waiting_version()); | 586 registration->waiting_version()); |
587 attrs->active = CreateAndRegisterServiceWorkerHandle( | 587 attrs->active = CreateAndRegisterServiceWorkerHandle( |
588 registration->active_version()); | 588 registration->active_version()); |
589 } | 589 } |
590 | 590 |
591 void ServiceWorkerDispatcherHost::RegistrationComplete( | 591 void ServiceWorkerDispatcherHost::RegistrationComplete( |
592 int thread_id, | 592 int thread_id, |
593 int provider_id, | 593 int provider_id, |
594 int request_id, | 594 int request_id, |
595 ServiceWorkerStatusCode status, | 595 ServiceWorkerStatusCode status, |
| 596 const std::string& status_message, |
596 int64 registration_id) { | 597 int64 registration_id) { |
597 if (!GetContext()) | 598 if (!GetContext()) |
598 return; | 599 return; |
599 | 600 |
600 if (status != SERVICE_WORKER_OK) { | 601 if (status != SERVICE_WORKER_OK) { |
601 SendRegistrationError(thread_id, request_id, status); | 602 SendRegistrationError(thread_id, request_id, status, status_message); |
602 return; | 603 return; |
603 } | 604 } |
604 | 605 |
605 ServiceWorkerRegistration* registration = | 606 ServiceWorkerRegistration* registration = |
606 GetContext()->GetLiveRegistration(registration_id); | 607 GetContext()->GetLiveRegistration(registration_id); |
607 DCHECK(registration); | 608 DCHECK(registration); |
608 | 609 |
609 ServiceWorkerRegistrationObjectInfo info; | 610 ServiceWorkerRegistrationObjectInfo info; |
610 ServiceWorkerVersionAttributes attrs; | 611 ServiceWorkerVersionAttributes attrs; |
611 GetRegistrationObjectInfoAndVersionAttributes( | 612 GetRegistrationObjectInfoAndVersionAttributes( |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 } | 847 } |
847 } | 848 } |
848 | 849 |
849 Send(new ServiceWorkerMsg_DidGetRegistration( | 850 Send(new ServiceWorkerMsg_DidGetRegistration( |
850 thread_id, request_id, info, attrs)); | 851 thread_id, request_id, info, attrs)); |
851 } | 852 } |
852 | 853 |
853 void ServiceWorkerDispatcherHost::SendRegistrationError( | 854 void ServiceWorkerDispatcherHost::SendRegistrationError( |
854 int thread_id, | 855 int thread_id, |
855 int request_id, | 856 int request_id, |
856 ServiceWorkerStatusCode status) { | 857 ServiceWorkerStatusCode status, |
| 858 const std::string& status_message) { |
857 base::string16 error_message; | 859 base::string16 error_message; |
858 blink::WebServiceWorkerError::ErrorType error_type; | 860 blink::WebServiceWorkerError::ErrorType error_type; |
859 GetServiceWorkerRegistrationStatusResponse( | 861 GetServiceWorkerRegistrationStatusResponse(status, status_message, |
860 status, &error_type, &error_message); | 862 &error_type, &error_message); |
861 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 863 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
862 thread_id, request_id, error_type, | 864 thread_id, request_id, error_type, |
863 base::ASCIIToUTF16(kServiceWorkerRegisterErrorPrefix) + error_message)); | 865 base::ASCIIToUTF16(kServiceWorkerRegisterErrorPrefix) + error_message)); |
864 } | 866 } |
865 | 867 |
866 void ServiceWorkerDispatcherHost::SendUnregistrationError( | 868 void ServiceWorkerDispatcherHost::SendUnregistrationError( |
867 int thread_id, | 869 int thread_id, |
868 int request_id, | 870 int request_id, |
869 ServiceWorkerStatusCode status) { | 871 ServiceWorkerStatusCode status) { |
870 base::string16 error_message; | 872 base::string16 error_message; |
871 blink::WebServiceWorkerError::ErrorType error_type; | 873 blink::WebServiceWorkerError::ErrorType error_type; |
872 GetServiceWorkerRegistrationStatusResponse( | 874 GetServiceWorkerRegistrationStatusResponse(status, std::string(), &error_type, |
873 status, &error_type, &error_message); | 875 &error_message); |
874 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( | 876 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( |
875 thread_id, request_id, error_type, | 877 thread_id, request_id, error_type, |
876 base::ASCIIToUTF16(kServiceWorkerUnregisterErrorPrefix) + error_message)); | 878 base::ASCIIToUTF16(kServiceWorkerUnregisterErrorPrefix) + error_message)); |
877 } | 879 } |
878 | 880 |
879 void ServiceWorkerDispatcherHost::SendGetRegistrationError( | 881 void ServiceWorkerDispatcherHost::SendGetRegistrationError( |
880 int thread_id, | 882 int thread_id, |
881 int request_id, | 883 int request_id, |
882 ServiceWorkerStatusCode status) { | 884 ServiceWorkerStatusCode status) { |
883 base::string16 error_message; | 885 base::string16 error_message; |
884 blink::WebServiceWorkerError::ErrorType error_type; | 886 blink::WebServiceWorkerError::ErrorType error_type; |
885 GetServiceWorkerRegistrationStatusResponse( | 887 GetServiceWorkerRegistrationStatusResponse(status, std::string(), &error_type, |
886 status, &error_type, &error_message); | 888 &error_message); |
887 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( | 889 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( |
888 thread_id, request_id, error_type, | 890 thread_id, request_id, error_type, |
889 base::ASCIIToUTF16(kServiceWorkerGetRegistrationErrorPrefix) + | 891 base::ASCIIToUTF16(kServiceWorkerGetRegistrationErrorPrefix) + |
890 error_message)); | 892 error_message)); |
891 } | 893 } |
892 | 894 |
893 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() { | 895 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() { |
894 if (!context_wrapper_.get()) | 896 if (!context_wrapper_.get()) |
895 return nullptr; | 897 return nullptr; |
896 return context_wrapper_->context(); | 898 return context_wrapper_->context(); |
(...skipping 15 matching lines...) Expand all Loading... |
912 handles_.AddWithID(handle.release(), handle_id); | 914 handles_.AddWithID(handle.release(), handle_id); |
913 } | 915 } |
914 | 916 |
915 void ServiceWorkerDispatcherHost::RegisterServiceWorkerRegistrationHandle( | 917 void ServiceWorkerDispatcherHost::RegisterServiceWorkerRegistrationHandle( |
916 scoped_ptr<ServiceWorkerRegistrationHandle> handle) { | 918 scoped_ptr<ServiceWorkerRegistrationHandle> handle) { |
917 int handle_id = handle->handle_id(); | 919 int handle_id = handle->handle_id(); |
918 registration_handles_.AddWithID(handle.release(), handle_id); | 920 registration_handles_.AddWithID(handle.release(), handle_id); |
919 } | 921 } |
920 | 922 |
921 } // namespace content | 923 } // namespace content |
OLD | NEW |