| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SetVersionId, | 94 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SetVersionId, |
| 94 OnSetHostedVersionId) | 95 OnSetHostedVersionId) |
| 95 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessage, | 96 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessage, |
| 96 OnPostMessage) | 97 OnPostMessage) |
| 97 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStarted, | 98 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStarted, |
| 98 OnWorkerStarted) | 99 OnWorkerStarted) |
| 99 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStopped, | 100 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStopped, |
| 100 OnWorkerStopped) | 101 OnWorkerStopped) |
| 101 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_SendMessageToBrowser, | 102 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_SendMessageToBrowser, |
| 102 OnSendMessageToBrowser) | 103 OnSendMessageToBrowser) |
| 104 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_ReportException, |
| 105 OnReportException) |
| 103 IPC_MESSAGE_UNHANDLED(handled = false) | 106 IPC_MESSAGE_UNHANDLED(handled = false) |
| 104 IPC_END_MESSAGE_MAP() | 107 IPC_END_MESSAGE_MAP() |
| 105 | 108 |
| 106 return handled; | 109 return handled; |
| 107 } | 110 } |
| 108 | 111 |
| 109 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( | 112 void ServiceWorkerDispatcherHost::OnRegisterServiceWorker( |
| 110 int32 thread_id, | 113 int32 thread_id, |
| 111 int32 request_id, | 114 int32 request_id, |
| 112 const GURL& pattern, | 115 const GURL& pattern, |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 void ServiceWorkerDispatcherHost::OnSendMessageToBrowser( | 287 void ServiceWorkerDispatcherHost::OnSendMessageToBrowser( |
| 285 int embedded_worker_id, | 288 int embedded_worker_id, |
| 286 int request_id, | 289 int request_id, |
| 287 const IPC::Message& message) { | 290 const IPC::Message& message) { |
| 288 if (!context_) | 291 if (!context_) |
| 289 return; | 292 return; |
| 290 context_->embedded_worker_registry()->OnSendMessageToBrowser( | 293 context_->embedded_worker_registry()->OnSendMessageToBrowser( |
| 291 embedded_worker_id, request_id, message); | 294 embedded_worker_id, request_id, message); |
| 292 } | 295 } |
| 293 | 296 |
| 297 void ServiceWorkerDispatcherHost::OnReportException( |
| 298 int embedded_worker_id, |
| 299 const base::string16& error_message, |
| 300 int line_number, |
| 301 int column_number, |
| 302 const GURL& source_url) { |
| 303 // TODO(horo, nhiroki): Show the error on serviceworker-internals |
| 304 // (http://crbug.com/359517). |
| 305 DVLOG(2) << "[Error] " << error_message << " (" << source_url |
| 306 << ":" << line_number << "," << column_number << ")"; |
| 307 } |
| 308 |
| 294 void ServiceWorkerDispatcherHost::UnregistrationComplete( | 309 void ServiceWorkerDispatcherHost::UnregistrationComplete( |
| 295 int32 thread_id, | 310 int32 thread_id, |
| 296 int32 request_id, | 311 int32 request_id, |
| 297 ServiceWorkerStatusCode status) { | 312 ServiceWorkerStatusCode status) { |
| 298 if (status != SERVICE_WORKER_OK) { | 313 if (status != SERVICE_WORKER_OK) { |
| 299 SendRegistrationError(thread_id, request_id, status); | 314 SendRegistrationError(thread_id, request_id, status); |
| 300 return; | 315 return; |
| 301 } | 316 } |
| 302 | 317 |
| 303 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(thread_id, request_id)); | 318 Send(new ServiceWorkerMsg_ServiceWorkerUnregistered(thread_id, request_id)); |
| 304 } | 319 } |
| 305 | 320 |
| 306 void ServiceWorkerDispatcherHost::SendRegistrationError( | 321 void ServiceWorkerDispatcherHost::SendRegistrationError( |
| 307 int32 thread_id, | 322 int32 thread_id, |
| 308 int32 request_id, | 323 int32 request_id, |
| 309 ServiceWorkerStatusCode status) { | 324 ServiceWorkerStatusCode status) { |
| 310 base::string16 error_message; | 325 base::string16 error_message; |
| 311 blink::WebServiceWorkerError::ErrorType error_type; | 326 blink::WebServiceWorkerError::ErrorType error_type; |
| 312 GetServiceWorkerRegistrationStatusResponse( | 327 GetServiceWorkerRegistrationStatusResponse( |
| 313 status, &error_type, &error_message); | 328 status, &error_type, &error_message); |
| 314 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 329 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 315 thread_id, request_id, error_type, error_message)); | 330 thread_id, request_id, error_type, error_message)); |
| 316 } | 331 } |
| 317 | 332 |
| 318 } // namespace content | 333 } // namespace content |
| OLD | NEW |