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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/browser/service_worker/embedded_worker_registry.h" | 8 #include "content/browser/service_worker/embedded_worker_registry.h" |
9 #include "content/browser/service_worker/service_worker_context_core.h" | 9 #include "content/browser/service_worker/service_worker_context_core.h" |
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 IPC_BEGIN_MESSAGE_MAP_EX( | 73 IPC_BEGIN_MESSAGE_MAP_EX( |
74 ServiceWorkerDispatcherHost, message, *message_was_ok) | 74 ServiceWorkerDispatcherHost, message, *message_was_ok) |
75 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_RegisterServiceWorker, | 75 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_RegisterServiceWorker, |
76 OnRegisterServiceWorker) | 76 OnRegisterServiceWorker) |
77 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_UnregisterServiceWorker, | 77 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_UnregisterServiceWorker, |
78 OnUnregisterServiceWorker) | 78 OnUnregisterServiceWorker) |
79 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderCreated, | 79 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderCreated, |
80 OnProviderCreated) | 80 OnProviderCreated) |
81 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderDestroyed, | 81 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderDestroyed, |
82 OnProviderDestroyed) | 82 OnProviderDestroyed) |
| 83 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_AddScriptClient, |
| 84 OnAddScriptClient) |
| 85 IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_RemoveScriptClient, |
| 86 OnRemoveScriptClient) |
83 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStarted, | 87 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStarted, |
84 OnWorkerStarted) | 88 OnWorkerStarted) |
85 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStopped, | 89 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_WorkerStopped, |
86 OnWorkerStopped) | 90 OnWorkerStopped) |
87 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_SendMessageToBrowser, | 91 IPC_MESSAGE_HANDLER(EmbeddedWorkerHostMsg_SendMessageToBrowser, |
88 OnSendMessageToBrowser) | 92 OnSendMessageToBrowser) |
89 IPC_MESSAGE_UNHANDLED(handled = false) | 93 IPC_MESSAGE_UNHANDLED(handled = false) |
90 IPC_END_MESSAGE_MAP() | 94 IPC_END_MESSAGE_MAP() |
91 | 95 |
92 return handled; | 96 return handled; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { | 172 void ServiceWorkerDispatcherHost::OnProviderDestroyed(int provider_id) { |
169 if (!context_) | 173 if (!context_) |
170 return; | 174 return; |
171 if (!context_->GetProviderHost(render_process_id_, provider_id)) { | 175 if (!context_->GetProviderHost(render_process_id_, provider_id)) { |
172 BadMessageReceived(); | 176 BadMessageReceived(); |
173 return; | 177 return; |
174 } | 178 } |
175 context_->RemoveProviderHost(render_process_id_, provider_id); | 179 context_->RemoveProviderHost(render_process_id_, provider_id); |
176 } | 180 } |
177 | 181 |
| 182 void ServiceWorkerDispatcherHost::OnAddScriptClient( |
| 183 int thread_id, int provider_id) { |
| 184 if (!context_) |
| 185 return; |
| 186 ServiceWorkerProviderHost* provider_host = |
| 187 context_->GetProviderHost(render_process_id_, provider_id); |
| 188 if (!provider_host) |
| 189 return; |
| 190 provider_host->AddScriptClient(thread_id); |
| 191 } |
| 192 |
| 193 void ServiceWorkerDispatcherHost::OnRemoveScriptClient( |
| 194 int thread_id, int provider_id) { |
| 195 if (!context_) |
| 196 return; |
| 197 ServiceWorkerProviderHost* provider_host = |
| 198 context_->GetProviderHost(render_process_id_, provider_id); |
| 199 if (!provider_host) |
| 200 return; |
| 201 provider_host->RemoveScriptClient(thread_id); |
| 202 } |
| 203 |
178 void ServiceWorkerDispatcherHost::RegistrationComplete( | 204 void ServiceWorkerDispatcherHost::RegistrationComplete( |
179 int32 thread_id, | 205 int32 thread_id, |
180 int32 request_id, | 206 int32 request_id, |
181 ServiceWorkerStatusCode status, | 207 ServiceWorkerStatusCode status, |
182 int64 registration_id) { | 208 int64 registration_id) { |
183 if (status != SERVICE_WORKER_OK) { | 209 if (status != SERVICE_WORKER_OK) { |
184 SendRegistrationError(thread_id, request_id, status); | 210 SendRegistrationError(thread_id, request_id, status); |
185 return; | 211 return; |
186 } | 212 } |
187 | 213 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 ServiceWorkerStatusCode status) { | 258 ServiceWorkerStatusCode status) { |
233 base::string16 error_message; | 259 base::string16 error_message; |
234 blink::WebServiceWorkerError::ErrorType error_type; | 260 blink::WebServiceWorkerError::ErrorType error_type; |
235 GetServiceWorkerRegistrationStatusResponse( | 261 GetServiceWorkerRegistrationStatusResponse( |
236 status, &error_type, &error_message); | 262 status, &error_type, &error_message); |
237 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( | 263 Send(new ServiceWorkerMsg_ServiceWorkerRegistrationError( |
238 thread_id, request_id, error_type, error_message)); | 264 thread_id, request_id, error_type, error_message)); |
239 } | 265 } |
240 | 266 |
241 } // namespace content | 267 } // namespace content |
OLD | NEW |