| 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/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 8 #include "content/browser/message_port_message_filter.h" | 9 #include "content/browser/message_port_message_filter.h" |
| 9 #include "content/browser/message_port_service.h" | 10 #include "content/browser/message_port_service.h" |
| 10 #include "content/browser/service_worker/embedded_worker_registry.h" | 11 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 11 #include "content/browser/service_worker/service_worker_context_core.h" | 12 #include "content/browser/service_worker/service_worker_context_core.h" |
| 12 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 13 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 13 #include "content/browser/service_worker/service_worker_registration.h" | 14 #include "content/browser/service_worker/service_worker_registration.h" |
| 14 #include "content/browser/service_worker/service_worker_utils.h" | 15 #include "content/browser/service_worker/service_worker_utils.h" |
| 15 #include "content/common/service_worker/embedded_worker_messages.h" | 16 #include "content/common/service_worker/embedded_worker_messages.h" |
| 16 #include "content/common/service_worker/service_worker_messages.h" | 17 #include "content/common/service_worker/service_worker_messages.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 OnAddScriptClient) | 89 OnAddScriptClient) |
| 89 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_RemoveScriptClient, | 90 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_RemoveScriptClient, |
| 90 OnRemoveScriptClient) | 91 OnRemoveScriptClient) |
| 91 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessage, OnPostMessage) | 92 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessage, OnPostMessage) |
| 92 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStarted, | 93 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStarted, |
| 93 OnWorkerStarted) | 94 OnWorkerStarted) |
| 94 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStopped, | 95 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStopped, |
| 95 OnWorkerStopped) | 96 OnWorkerStopped) |
| 96 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_SendMessageToBrowser, | 97 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_SendMessageToBrowser, |
| 97 OnSendMessageToBrowser) | 98 OnSendMessageToBrowser) |
| 99 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_ReportException, |
| 100 OnReportException) |
| 98 IPC_MESSAGE_UNHANDLED(handled = false) | 101 IPC_MESSAGE_UNHANDLED(handled = false) |
| 99 IPC_END_MESSAGE_MAP() | 102 IPC_END_MESSAGE_MAP() |
| 100 | 103 |
| 101 return handled; | 104 return handled; |
| 102 } | 105 } |
| 103 | 106 |
| 104 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( | 107 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( |
| 105 int32 thread_id, | 108 int32 thread_id, |
| 106 int32 request_id, | 109 int32 request_id, |
| 107 const GURL& pattern, | 110 const GURL& pattern, |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 void ServiceWorkerDispatcherHost::OnSendMessageToBrowser( | 289 void ServiceWorkerDispatcherHost::OnSendMessageToBrowser( |
| 287 int embedded_worker_id, | 290 int embedded_worker_id, |
| 288 int request_id, | 291 int request_id, |
| 289 const IPC::Message& message) { | 292 const IPC::Message& message) { |
| 290 if (!context_) | 293 if (!context_) |
| 291 return; | 294 return; |
| 292 context_->embedded_worker_registry()->OnSendMessageToBrowser( | 295 context_->embedded_worker_registry()->OnSendMessageToBrowser( |
| 293 embedded_worker_id, request_id, message); | 296 embedded_worker_id, request_id, message); |
| 294 } | 297 } |
| 295 | 298 |
| 299 void ServiceWorkerDispatcherHost::OnReportException( |
| 300 int embedded_worker_id, |
| 301 const base::string16& error_message, |
| 302 int line_number, |
| 303 int column_number, |
| 304 const base::string16& source_url) { |
| 305 // TODO(horo, nhiroki): Show the error on serviceworker-internals |
| 306 // (http://crbug.com/359517). |
| 307 DVLOG(2) << "[Error] " << error_message << " (" << source_url |
| 308 << ":" << line_number << "," << column_number << ")"; |
| 309 } |
| 310 |
| 296 void ServiceWorkerDispatcherHost::UnregistrationComplete( | 311 void ServiceWorkerDispatcherHost::UnregistrationComplete( |
| 297 int32 thread_id, | 312 int32 thread_id, |
| 298 int32 request_id, | 313 int32 request_id, |
| 299 ServiceWorkerStatusCode status) { | 314 ServiceWorkerStatusCode status) { |
| 300 if (status != SERVICE_WORKER_OK) { | 315 if (status != SERVICE_WORKER_OK) { |
| 301 SendRegistrationError(thread_id, request_id, status); | 316 SendRegistrationError(thread_id, request_id, status); |
| 302 return; | 317 return; |
| 303 } | 318 } |
| 304 | 319 |
| 305 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(thread_id, request_id)); | 320 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(thread_id, request_id)); |
| 306 } | 321 } |
| 307 | 322 |
| 308 void ServiceWorkerDispatcherHost::SendRegistrationError( | 323 void ServiceWorkerDispatcherHost::SendRegistrationError( |
| 309 int32 thread_id, | 324 int32 thread_id, |
| 310 int32 request_id, | 325 int32 request_id, |
| 311 ServiceWorkerStatusCode status) { | 326 ServiceWorkerStatusCode status) { |
| 312 base::string16 error_message; | 327 base::string16 error_message; |
| 313 blink::WebServiceWorkerError::ErrorType error_type; | 328 blink::WebServiceWorkerError::ErrorType error_type; |
| 314 GetServiceWorkerRegistrationStatusResponse( | 329 GetServiceWorkerRegistrationStatusResponse( |
| 315 status, &error_type, &error_message); | 330 status, &error_type, &error_message); |
| 316 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 331 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 317 thread_id, request_id, error_type, error_message)); | 332 thread_id, request_id, error_type, error_message)); |
| 318 } | 333 } |
| 319 | 334 |
| 320 } // namespace content | 335 } // namespace content |
| OLD | NEW |