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/embedded_worker_registry.h" | 5 #include "content/browser/service_worker/embedded_worker_registry.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "content/browser/renderer_host/render_widget_helper.h" | 9 #include "content/browser/renderer_host/render_widget_helper.h" |
10 #include "content/browser/service_worker/embedded_worker_instance.h" | 10 #include "content/browser/service_worker/embedded_worker_instance.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 return; | 242 return; |
243 } | 243 } |
244 // The ServiceWorkerDispatcherHost is supposed to be created when the process | 244 // The ServiceWorkerDispatcherHost is supposed to be created when the process |
245 // is created, and keep an entry in process_sender_map_ for its whole | 245 // is created, and keep an entry in process_sender_map_ for its whole |
246 // lifetime. | 246 // lifetime. |
247 DCHECK(ContainsKey(process_sender_map_, process_id)); | 247 DCHECK(ContainsKey(process_sender_map_, process_id)); |
248 callback.Run(Send(process_id, new EmbeddedWorkerMsg_StartWorker(*params))); | 248 callback.Run(Send(process_id, new EmbeddedWorkerMsg_StartWorker(*params))); |
249 } | 249 } |
250 | 250 |
251 ServiceWorkerStatusCode EmbeddedWorkerRegistry::Send( | 251 ServiceWorkerStatusCode EmbeddedWorkerRegistry::Send( |
252 int process_id, IPC::Message* message) { | 252 int process_id, IPC::Message* message_ptr) { |
| 253 scoped_ptr<IPC::Message> message(message_ptr); |
253 if (!context_) | 254 if (!context_) |
254 return SERVICE_WORKER_ERROR_ABORT; | 255 return SERVICE_WORKER_ERROR_ABORT; |
255 ProcessToSenderMap::iterator found = process_sender_map_.find(process_id); | 256 ProcessToSenderMap::iterator found = process_sender_map_.find(process_id); |
256 if (found == process_sender_map_.end()) | 257 if (found == process_sender_map_.end()) |
257 return SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND; | 258 return SERVICE_WORKER_ERROR_PROCESS_NOT_FOUND; |
258 if (!found->second->Send(message)) | 259 if (!found->second->Send(message.release())) |
259 return SERVICE_WORKER_ERROR_IPC_FAILED; | 260 return SERVICE_WORKER_ERROR_IPC_FAILED; |
260 return SERVICE_WORKER_OK; | 261 return SERVICE_WORKER_OK; |
261 } | 262 } |
262 | 263 |
263 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, | 264 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, |
264 int embedded_worker_id) { | 265 int embedded_worker_id) { |
265 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 266 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
266 worker_map_.erase(embedded_worker_id); | 267 worker_map_.erase(embedded_worker_id); |
267 worker_process_map_.erase(process_id); | 268 worker_process_map_.erase(process_id); |
268 } | 269 } |
269 | 270 |
270 } // namespace content | 271 } // namespace content |
OLD | NEW |