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 30 matching lines...) Expand all Loading... |
41 worker_map_[next_embedded_worker_id_++] = worker.get(); | 41 worker_map_[next_embedded_worker_id_++] = worker.get(); |
42 return worker.Pass(); | 42 return worker.Pass(); |
43 } | 43 } |
44 | 44 |
45 ServiceWorkerStatusCode EmbeddedWorkerRegistry::StopWorker( | 45 ServiceWorkerStatusCode EmbeddedWorkerRegistry::StopWorker( |
46 int process_id, int embedded_worker_id) { | 46 int process_id, int embedded_worker_id) { |
47 return Send(process_id, | 47 return Send(process_id, |
48 new EmbeddedWorkerMsg_StopWorker(embedded_worker_id)); | 48 new EmbeddedWorkerMsg_StopWorker(embedded_worker_id)); |
49 } | 49 } |
50 | 50 |
51 bool EmbeddedWorkerRegistry::OnMessageReceived(const IPC::Message& message) { | 51 bool EmbeddedWorkerRegistry::OnMessageReceived(const IPC::Message& message, |
| 52 int process_id) { |
52 // TODO(kinuko): Move all EmbeddedWorker message handling from | 53 // TODO(kinuko): Move all EmbeddedWorker message handling from |
53 // ServiceWorkerDispatcherHost. | 54 // ServiceWorkerDispatcherHost. |
54 | 55 |
55 WorkerInstanceMap::iterator found = worker_map_.find(message.routing_id()); | 56 WorkerInstanceMap::iterator found = worker_map_.find(message.routing_id()); |
56 DCHECK(found != worker_map_.end()); | 57 DCHECK(found != worker_map_.end()); |
57 if (found == worker_map_.end()) | 58 if (found == worker_map_.end() || found->second->process_id() != process_id) |
58 return false; | 59 return false; |
59 return found->second->OnMessageReceived(message); | 60 return found->second->OnMessageReceived(message); |
60 } | 61 } |
61 | 62 |
62 void EmbeddedWorkerRegistry::Shutdown() { | 63 void EmbeddedWorkerRegistry::Shutdown() { |
63 for (WorkerInstanceMap::iterator it = worker_map_.begin(); | 64 for (WorkerInstanceMap::iterator it = worker_map_.begin(); |
64 it != worker_map_.end(); | 65 it != worker_map_.end(); |
65 ++it) { | 66 ++it) { |
66 it->second->Stop(); | 67 it->second->Stop(); |
67 } | 68 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 280 } |
280 | 281 |
281 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, | 282 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, |
282 int embedded_worker_id) { | 283 int embedded_worker_id) { |
283 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 284 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
284 worker_map_.erase(embedded_worker_id); | 285 worker_map_.erase(embedded_worker_id); |
285 worker_process_map_.erase(process_id); | 286 worker_process_map_.erase(process_id); |
286 } | 287 } |
287 | 288 |
288 } // namespace content | 289 } // namespace content |
OLD | NEW |