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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 const GURL& source_url) { | 175 const GURL& source_url) { |
176 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); | 176 WorkerInstanceMap::iterator found = worker_map_.find(embedded_worker_id); |
177 DCHECK(found != worker_map_.end()); | 177 DCHECK(found != worker_map_.end()); |
178 if (found == worker_map_.end()) | 178 if (found == worker_map_.end()) |
179 return; | 179 return; |
180 found->second->OnReportConsoleMessage( | 180 found->second->OnReportConsoleMessage( |
181 source_identifier, message_level, message, line_number, source_url); | 181 source_identifier, message_level, message, line_number, source_url); |
182 } | 182 } |
183 | 183 |
184 void EmbeddedWorkerRegistry::AddChildProcessSender( | 184 void EmbeddedWorkerRegistry::AddChildProcessSender( |
185 int process_id, IPC::Sender* sender) { | 185 int process_id, |
| 186 IPC::Sender* sender, |
| 187 MessagePortMessageFilter* message_port_message_filter) { |
186 process_sender_map_[process_id] = sender; | 188 process_sender_map_[process_id] = sender; |
| 189 process_message_port_message_filter_map_[process_id] = |
| 190 message_port_message_filter; |
187 DCHECK(!ContainsKey(worker_process_map_, process_id)); | 191 DCHECK(!ContainsKey(worker_process_map_, process_id)); |
188 } | 192 } |
189 | 193 |
190 void EmbeddedWorkerRegistry::RemoveChildProcessSender(int process_id) { | 194 void EmbeddedWorkerRegistry::RemoveChildProcessSender(int process_id) { |
191 process_sender_map_.erase(process_id); | 195 process_sender_map_.erase(process_id); |
| 196 process_message_port_message_filter_map_.erase(process_id); |
192 std::map<int, std::set<int> >::iterator found = | 197 std::map<int, std::set<int> >::iterator found = |
193 worker_process_map_.find(process_id); | 198 worker_process_map_.find(process_id); |
194 if (found != worker_process_map_.end()) { | 199 if (found != worker_process_map_.end()) { |
195 const std::set<int>& worker_set = worker_process_map_[process_id]; | 200 const std::set<int>& worker_set = worker_process_map_[process_id]; |
196 for (std::set<int>::const_iterator it = worker_set.begin(); | 201 for (std::set<int>::const_iterator it = worker_set.begin(); |
197 it != worker_set.end(); | 202 it != worker_set.end(); |
198 ++it) { | 203 ++it) { |
199 int embedded_worker_id = *it; | 204 int embedded_worker_id = *it; |
200 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 205 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
201 worker_map_[embedded_worker_id]->OnStopped(); | 206 worker_map_[embedded_worker_id]->OnStopped(); |
(...skipping 11 matching lines...) Expand all Loading... |
213 } | 218 } |
214 | 219 |
215 bool EmbeddedWorkerRegistry::CanHandle(int embedded_worker_id) const { | 220 bool EmbeddedWorkerRegistry::CanHandle(int embedded_worker_id) const { |
216 if (embedded_worker_id < initial_embedded_worker_id_ || | 221 if (embedded_worker_id < initial_embedded_worker_id_ || |
217 next_embedded_worker_id_ <= embedded_worker_id) { | 222 next_embedded_worker_id_ <= embedded_worker_id) { |
218 return false; | 223 return false; |
219 } | 224 } |
220 return true; | 225 return true; |
221 } | 226 } |
222 | 227 |
| 228 MessagePortMessageFilter* |
| 229 EmbeddedWorkerRegistry::MessagePortMessageFilterForProcess(int process_id) { |
| 230 return process_message_port_message_filter_map_[process_id]; |
| 231 } |
| 232 |
223 EmbeddedWorkerRegistry::EmbeddedWorkerRegistry( | 233 EmbeddedWorkerRegistry::EmbeddedWorkerRegistry( |
224 const base::WeakPtr<ServiceWorkerContextCore>& context, | 234 const base::WeakPtr<ServiceWorkerContextCore>& context, |
225 int initial_embedded_worker_id) | 235 int initial_embedded_worker_id) |
226 : context_(context), | 236 : context_(context), |
227 next_embedded_worker_id_(initial_embedded_worker_id), | 237 next_embedded_worker_id_(initial_embedded_worker_id), |
228 initial_embedded_worker_id_(initial_embedded_worker_id) { | 238 initial_embedded_worker_id_(initial_embedded_worker_id) { |
229 } | 239 } |
230 | 240 |
231 EmbeddedWorkerRegistry::~EmbeddedWorkerRegistry() { | 241 EmbeddedWorkerRegistry::~EmbeddedWorkerRegistry() { |
232 Shutdown(); | 242 Shutdown(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 279 } |
270 | 280 |
271 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, | 281 void EmbeddedWorkerRegistry::RemoveWorker(int process_id, |
272 int embedded_worker_id) { | 282 int embedded_worker_id) { |
273 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); | 283 DCHECK(ContainsKey(worker_map_, embedded_worker_id)); |
274 worker_map_.erase(embedded_worker_id); | 284 worker_map_.erase(embedded_worker_id); |
275 worker_process_map_.erase(process_id); | 285 worker_process_map_.erase(process_id); |
276 } | 286 } |
277 | 287 |
278 } // namespace content | 288 } // namespace content |
OLD | NEW |