OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/worker_host/message_port_dispatcher.h" | 5 #include "chrome/browser/worker_host/message_port_dispatcher.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
9 #include "chrome/browser/renderer_host/resource_message_filter.h" | 9 #include "chrome/browser/renderer_host/render_message_filter.h" |
10 #include "chrome/browser/worker_host/worker_process_host.h" | 10 #include "chrome/browser/worker_host/worker_process_host.h" |
11 #include "chrome/common/notification_service.h" | 11 #include "chrome/common/notification_service.h" |
12 #include "chrome/common/worker_messages.h" | 12 #include "chrome/common/worker_messages.h" |
13 | 13 |
14 struct MessagePortDispatcher::MessagePort { | 14 struct MessagePortDispatcher::MessagePort { |
15 // sender and route_id are what we need to send messages to the port. | 15 // sender and route_id are what we need to send messages to the port. |
16 IPC::Message::Sender* sender; | 16 IPC::Message::Sender* sender; |
17 int route_id; | 17 int route_id; |
18 // A function pointer to generate a new route id for the sender above. | 18 // A function pointer to generate a new route id for the sender above. |
19 // Owned by "sender" above, so don't delete. | 19 // Owned by "sender" above, so don't delete. |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 PostMessageTo(message_port_id, iter->first, iter->second); | 251 PostMessageTo(message_port_id, iter->first, iter->second); |
252 } | 252 } |
253 port.queued_messages.clear(); | 253 port.queued_messages.clear(); |
254 } | 254 } |
255 | 255 |
256 void MessagePortDispatcher::Observe(NotificationType type, | 256 void MessagePortDispatcher::Observe(NotificationType type, |
257 const NotificationSource& source, | 257 const NotificationSource& source, |
258 const NotificationDetails& details) { | 258 const NotificationDetails& details) { |
259 IPC::Message::Sender* sender = NULL; | 259 IPC::Message::Sender* sender = NULL; |
260 if (type.value == NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN) { | 260 if (type.value == NotificationType::RESOURCE_MESSAGE_FILTER_SHUTDOWN) { |
261 sender = Source<ResourceMessageFilter>(source).ptr(); | 261 sender = Source<RenderMessageFilter>(source).ptr(); |
262 } else if (type.value == NotificationType::WORKER_PROCESS_HOST_SHUTDOWN) { | 262 } else if (type.value == NotificationType::WORKER_PROCESS_HOST_SHUTDOWN) { |
263 sender = Source<WorkerProcessHost>(source).ptr(); | 263 sender = Source<WorkerProcessHost>(source).ptr(); |
264 } else { | 264 } else { |
265 NOTREACHED(); | 265 NOTREACHED(); |
266 } | 266 } |
267 | 267 |
268 // Check if the (possibly) crashed process had any message ports. | 268 // Check if the (possibly) crashed process had any message ports. |
269 for (MessagePorts::iterator iter = message_ports_.begin(); | 269 for (MessagePorts::iterator iter = message_ports_.begin(); |
270 iter != message_ports_.end();) { | 270 iter != message_ports_.end();) { |
271 MessagePorts::iterator cur_item = iter++; | 271 MessagePorts::iterator cur_item = iter++; |
(...skipping 10 matching lines...) Expand all Loading... |
282 int entangled_id = erase_item->second.entangled_message_port_id; | 282 int entangled_id = erase_item->second.entangled_message_port_id; |
283 if (entangled_id != MSG_ROUTING_NONE) { | 283 if (entangled_id != MSG_ROUTING_NONE) { |
284 // Do the disentanglement (and be paranoid about the other side existing | 284 // Do the disentanglement (and be paranoid about the other side existing |
285 // just in case something unusual happened during entanglement). | 285 // just in case something unusual happened during entanglement). |
286 if (message_ports_.count(entangled_id)) { | 286 if (message_ports_.count(entangled_id)) { |
287 message_ports_[entangled_id].entangled_message_port_id = MSG_ROUTING_NONE; | 287 message_ports_[entangled_id].entangled_message_port_id = MSG_ROUTING_NONE; |
288 } | 288 } |
289 } | 289 } |
290 message_ports_.erase(erase_item); | 290 message_ports_.erase(erase_item); |
291 } | 291 } |
OLD | NEW |