| 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/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "content/browser/message_port_message_filter.h" | 9 #include "content/browser/message_port_message_filter.h" |
| 10 #include "content/browser/message_port_service.h" | 10 #include "content/browser/message_port_service.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderDestroyed, | 99 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderDestroyed, |
| 100 OnProviderDestroyed) | 100 OnProviderDestroyed) |
| 101 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_AddScriptClient, | 101 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_AddScriptClient, |
| 102 OnAddScriptClient) | 102 OnAddScriptClient) |
| 103 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_RemoveScriptClient, | 103 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_RemoveScriptClient, |
| 104 OnRemoveScriptClient) | 104 OnRemoveScriptClient) |
| 105 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SetVersionId, | 105 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SetVersionId, |
| 106 OnSetHostedVersionId) | 106 OnSetHostedVersionId) |
| 107 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessage, | 107 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessage, |
| 108 OnPostMessage) | 108 OnPostMessage) |
| 109 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerScriptLoaded, |
| 110 OnWorkerScriptLoaded) |
| 111 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerScriptLoadFailed, |
| 112 OnWorkerScriptLoadFailed) |
| 109 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStarted, | 113 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStarted, |
| 110 OnWorkerStarted) | 114 OnWorkerStarted) |
| 111 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStopped, | 115 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStopped, |
| 112 OnWorkerStopped) | 116 OnWorkerStopped) |
| 113 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_ReportException, | 117 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_ReportException, |
| 114 OnReportException) | 118 OnReportException) |
| 115 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_ReportConsoleMessage, | 119 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_ReportConsoleMessage, |
| 116 OnReportConsoleMessage) | 120 OnReportConsoleMessage) |
| 117 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ServiceWorkerObjectDestroyed, | 121 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ServiceWorkerObjectDestroyed, |
| 118 OnServiceWorkerObjectDestroyed) | 122 OnServiceWorkerObjectDestroyed) |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 ServiceWorkerVersion* version = context_->GetLiveVersion(version_id); | 327 ServiceWorkerVersion* version = context_->GetLiveVersion(version_id); |
| 324 DCHECK(version); | 328 DCHECK(version); |
| 325 DCHECK_EQ(registration_id, version->registration_id()); | 329 DCHECK_EQ(registration_id, version->registration_id()); |
| 326 scoped_ptr<ServiceWorkerHandle> handle = | 330 scoped_ptr<ServiceWorkerHandle> handle = |
| 327 ServiceWorkerHandle::Create(context_, this, thread_id, version); | 331 ServiceWorkerHandle::Create(context_, this, thread_id, version); |
| 328 Send(new ServiceWorkerMsg_ServiceWorkerRegistered( | 332 Send(new ServiceWorkerMsg_ServiceWorkerRegistered( |
| 329 thread_id, request_id, handle->GetObjectInfo())); | 333 thread_id, request_id, handle->GetObjectInfo())); |
| 330 RegisterServiceWorkerHandle(handle.Pass()); | 334 RegisterServiceWorkerHandle(handle.Pass()); |
| 331 } | 335 } |
| 332 | 336 |
| 337 void ServiceWorkerDispatcherHost::OnWorkerScriptLoaded(int embedded_worker_id) { |
| 338 if (!context_) |
| 339 return; |
| 340 context_->embedded_worker_registry()->OnWorkerScriptLoaded( |
| 341 render_process_id_, embedded_worker_id); |
| 342 } |
| 343 |
| 344 void ServiceWorkerDispatcherHost::OnWorkerScriptLoadFailed( |
| 345 int embedded_worker_id) { |
| 346 if (!context_) |
| 347 return; |
| 348 context_->embedded_worker_registry()->OnWorkerScriptLoadFailed( |
| 349 render_process_id_, embedded_worker_id); |
| 350 } |
| 351 |
| 333 void ServiceWorkerDispatcherHost::OnWorkerStarted( | 352 void ServiceWorkerDispatcherHost::OnWorkerStarted( |
| 334 int thread_id, int embedded_worker_id) { | 353 int thread_id, int embedded_worker_id) { |
| 335 if (!context_) | 354 if (!context_) |
| 336 return; | 355 return; |
| 337 context_->embedded_worker_registry()->OnWorkerStarted( | 356 context_->embedded_worker_registry()->OnWorkerStarted( |
| 338 render_process_id_, thread_id, embedded_worker_id); | 357 render_process_id_, thread_id, embedded_worker_id); |
| 339 } | 358 } |
| 340 | 359 |
| 341 void ServiceWorkerDispatcherHost::OnWorkerStopped(int embedded_worker_id) { | 360 void ServiceWorkerDispatcherHost::OnWorkerStopped(int embedded_worker_id) { |
| 342 if (!context_) | 361 if (!context_) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 ServiceWorkerStatusCode status) { | 416 ServiceWorkerStatusCode status) { |
| 398 base::string16 error_message; | 417 base::string16 error_message; |
| 399 blink::WebServiceWorkerError::ErrorType error_type; | 418 blink::WebServiceWorkerError::ErrorType error_type; |
| 400 GetServiceWorkerRegistrationStatusResponse( | 419 GetServiceWorkerRegistrationStatusResponse( |
| 401 status, &error_type, &error_message); | 420 status, &error_type, &error_message); |
| 402 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 421 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
| 403 thread_id, request_id, error_type, error_message)); | 422 thread_id, request_id, error_type, error_message)); |
| 404 } | 423 } |
| 405 | 424 |
| 406 } // namespace content | 425 } // namespace content |
| OLD | NEW |