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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SetVersionId, | 157 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_SetVersionId, |
158 OnSetHostedVersionId) | 158 OnSetHostedVersionId) |
159 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessageToWorker, | 159 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_PostMessageToWorker, |
160 OnPostMessageToWorker) | 160 OnPostMessageToWorker) |
161 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerReadyForInspection, | 161 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerReadyForInspection, |
162 OnWorkerReadyForInspection) | 162 OnWorkerReadyForInspection) |
163 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerScriptLoaded, | 163 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerScriptLoaded, |
164 OnWorkerScriptLoaded) | 164 OnWorkerScriptLoaded) |
165 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerScriptLoadFailed, | 165 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerScriptLoadFailed, |
166 OnWorkerScriptLoadFailed) | 166 OnWorkerScriptLoadFailed) |
| 167 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerScriptEvaluated, |
| 168 OnWorkerScriptEvaluated) |
167 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStarted, | 169 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStarted, |
168 OnWorkerStarted) | 170 OnWorkerStarted) |
169 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStopped, | 171 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStopped, |
170 OnWorkerStopped) | 172 OnWorkerStopped) |
171 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_DidPauseAfterDownload, | 173 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_DidPauseAfterDownload, |
172 OnPausedAfterDownload) | 174 OnPausedAfterDownload) |
173 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_ReportException, | 175 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_ReportException, |
174 OnReportException) | 176 OnReportException) |
175 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_ReportConsoleMessage, | 177 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_ReportConsoleMessage, |
176 OnReportConsoleMessage) | 178 OnReportConsoleMessage) |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 TRACE_EVENT0("ServiceWorker", | 610 TRACE_EVENT0("ServiceWorker", |
609 "ServiceWorkerDispatcherHost::OnWorkerScriptLoadFailed"); | 611 "ServiceWorkerDispatcherHost::OnWorkerScriptLoadFailed"); |
610 if (!GetContext()) | 612 if (!GetContext()) |
611 return; | 613 return; |
612 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); | 614 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); |
613 if (!registry->CanHandle(embedded_worker_id)) | 615 if (!registry->CanHandle(embedded_worker_id)) |
614 return; | 616 return; |
615 registry->OnWorkerScriptLoadFailed(render_process_id_, embedded_worker_id); | 617 registry->OnWorkerScriptLoadFailed(render_process_id_, embedded_worker_id); |
616 } | 618 } |
617 | 619 |
| 620 void ServiceWorkerDispatcherHost::OnWorkerScriptEvaluated( |
| 621 int embedded_worker_id, |
| 622 bool success) { |
| 623 TRACE_EVENT0("ServiceWorker", |
| 624 "ServiceWorkerDispatcherHost::OnWorkerScriptEvaluated"); |
| 625 if (!GetContext()) |
| 626 return; |
| 627 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); |
| 628 if (!registry->CanHandle(embedded_worker_id)) |
| 629 return; |
| 630 registry->OnWorkerScriptEvaluated( |
| 631 render_process_id_, embedded_worker_id, success); |
| 632 } |
| 633 |
618 void ServiceWorkerDispatcherHost::OnWorkerStarted(int embedded_worker_id) { | 634 void ServiceWorkerDispatcherHost::OnWorkerStarted(int embedded_worker_id) { |
619 TRACE_EVENT0("ServiceWorker", | 635 TRACE_EVENT0("ServiceWorker", |
620 "ServiceWorkerDispatcherHost::OnWorkerStarted"); | 636 "ServiceWorkerDispatcherHost::OnWorkerStarted"); |
621 if (!GetContext()) | 637 if (!GetContext()) |
622 return; | 638 return; |
623 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); | 639 EmbeddedWorkerRegistry* registry = GetContext()->embedded_worker_registry(); |
624 if (!registry->CanHandle(embedded_worker_id)) | 640 if (!registry->CanHandle(embedded_worker_id)) |
625 return; | 641 return; |
626 registry->OnWorkerStarted(render_process_id_, embedded_worker_id); | 642 registry->OnWorkerStarted(render_process_id_, embedded_worker_id); |
627 } | 643 } |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
823 status, &error_type, &error_message); | 839 status, &error_type, &error_message); |
824 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( | 840 Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError( |
825 thread_id, request_id, error_type, error_message)); | 841 thread_id, request_id, error_type, error_message)); |
826 } | 842 } |
827 | 843 |
828 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() { | 844 ServiceWorkerContextCore* ServiceWorkerDispatcherHost::GetContext() { |
829 return context_wrapper_->context(); | 845 return context_wrapper_->context(); |
830 } | 846 } |
831 | 847 |
832 } // namespace content | 848 } // namespace content |
OLD | NEW |