| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 int64 registration_id) { | 881 int64 registration_id) { |
| 882 if (!GetContext()) | 882 if (!GetContext()) |
| 883 return; | 883 return; |
| 884 | 884 |
| 885 ServiceWorkerProviderHost* provider_host = | 885 ServiceWorkerProviderHost* provider_host = |
| 886 GetContext()->GetProviderHost(render_process_id_, provider_id); | 886 GetContext()->GetProviderHost(render_process_id_, provider_id); |
| 887 if (!provider_host) | 887 if (!provider_host) |
| 888 return; // The provider has already been destroyed. | 888 return; // The provider has already been destroyed. |
| 889 | 889 |
| 890 if (status != SERVICE_WORKER_OK) { | 890 if (status != SERVICE_WORKER_OK) { |
| 891 SendRegistrationError(thread_id, request_id, status, status_message); | 891 SendUpdateError(thread_id, request_id, status, status_message); |
| 892 return; | 892 return; |
| 893 } | 893 } |
| 894 | 894 |
| 895 ServiceWorkerRegistration* registration = | 895 ServiceWorkerRegistration* registration = |
| 896 GetContext()->GetLiveRegistration(registration_id); | 896 GetContext()->GetLiveRegistration(registration_id); |
| 897 DCHECK(registration); | 897 DCHECK(registration); |
| 898 | 898 |
| 899 ServiceWorkerRegistrationObjectInfo info; | 899 ServiceWorkerRegistrationObjectInfo info; |
| 900 ServiceWorkerVersionAttributes attrs; | 900 ServiceWorkerVersionAttributes attrs; |
| 901 GetRegistrationObjectInfoAndVersionAttributes(provider_host->AsWeakPtr(), | 901 GetRegistrationObjectInfoAndVersionAttributes(provider_host->AsWeakPtr(), |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 const std::string& status_message) { | 1216 const std::string& status_message) { |
| 1217 base::string16 error_message; | 1217 base::string16 error_message; |
| 1218 blink::WebServiceWorkerError::ErrorType error_type; | 1218 blink::WebServiceWorkerError::ErrorType error_type; |
| 1219 GetServiceWorkerRegistrationStatusResponse(status, status_message, | 1219 GetServiceWorkerRegistrationStatusResponse(status, status_message, |
| 1220 &error_type, &error_message); | 1220 &error_type, &error_message); |
| 1221 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 1221 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 1222 thread_id, request_id, error_type, | 1222 thread_id, request_id, error_type, |
| 1223 base::ASCIIToUTF16(kServiceWorkerRegisterErrorPrefix) + error_message)); | 1223 base::ASCIIToUTF16(kServiceWorkerRegisterErrorPrefix) + error_message)); |
| 1224 } | 1224 } |
| 1225 | 1225 |
| 1226 void ServiceWorkerDispatcherHost::SendUpdateError( |
| 1227 int thread_id, |
| 1228 int request_id, |
| 1229 ServiceWorkerStatusCode status, |
| 1230 const std::string& status_message) { |
| 1231 base::string16 error_message; |
| 1232 blink::WebServiceWorkerError::ErrorType error_type; |
| 1233 GetServiceWorkerRegistrationStatusResponse(status, status_message, |
| 1234 &error_type, &error_message); |
| 1235 Send(new ServiceWorkerMsg_ServiceWorkerUpdateError( |
| 1236 thread_id, request_id, error_type, |
| 1237 base::ASCIIToUTF16(kServiceWorkerUpdateErrorPrefix) + error_message)); |
| 1238 } |
| 1239 |
| 1226 void ServiceWorkerDispatcherHost::SendUnregistrationError( | 1240 void ServiceWorkerDispatcherHost::SendUnregistrationError( |
| 1227 int thread_id, | 1241 int thread_id, |
| 1228 int request_id, | 1242 int request_id, |
| 1229 ServiceWorkerStatusCode status) { | 1243 ServiceWorkerStatusCode status) { |
| 1230 base::string16 error_message; | 1244 base::string16 error_message; |
| 1231 blink::WebServiceWorkerError::ErrorType error_type; | 1245 blink::WebServiceWorkerError::ErrorType error_type; |
| 1232 GetServiceWorkerRegistrationStatusResponse(status, std::string(), &error_type, | 1246 GetServiceWorkerRegistrationStatusResponse(status, std::string(), &error_type, |
| 1233 &error_message); | 1247 &error_message); |
| 1234 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( | 1248 Send(new ServiceWorkerMsg_ServiceWorkerUnregistrationError( |
| 1235 thread_id, request_id, error_type, | 1249 thread_id, request_id, error_type, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 if (!handle) { | 1289 if (!handle) { |
| 1276 bad_message::ReceivedBadMessage(this, | 1290 bad_message::ReceivedBadMessage(this, |
| 1277 bad_message::SWDH_TERMINATE_BAD_HANDLE); | 1291 bad_message::SWDH_TERMINATE_BAD_HANDLE); |
| 1278 return; | 1292 return; |
| 1279 } | 1293 } |
| 1280 handle->version()->StopWorker( | 1294 handle->version()->StopWorker( |
| 1281 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1295 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 1282 } | 1296 } |
| 1283 | 1297 |
| 1284 } // namespace content | 1298 } // namespace content |
| OLD | NEW |