| 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/worker_process_host.h" | 5 #include "chrome/browser/worker_host/worker_process_host.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> |
| 8 | 9 |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/debug_util.h" | 11 #include "base/debug_util.h" |
| 11 #if defined(OS_POSIX) | 12 #if defined(OS_POSIX) |
| 12 #include "base/global_descriptors_posix.h" | 13 #include "base/global_descriptors_posix.h" |
| 13 #endif | 14 #endif |
| 14 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
| 15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 16 #include "base/process_util.h" | 17 #include "base/process_util.h" |
| 17 #include "base/string_util.h" | 18 #include "base/string_util.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 void WorkerProcessHost::RelayMessage( | 226 void WorkerProcessHost::RelayMessage( |
| 226 const IPC::Message& message, | 227 const IPC::Message& message, |
| 227 IPC::Message::Sender* sender, | 228 IPC::Message::Sender* sender, |
| 228 int route_id, | 229 int route_id, |
| 229 CallbackWithReturnValue<int>::Type* next_route_id) { | 230 CallbackWithReturnValue<int>::Type* next_route_id) { |
| 230 IPC::Message* new_message; | 231 IPC::Message* new_message; |
| 231 if (message.type() == WorkerMsg_PostMessage::ID) { | 232 if (message.type() == WorkerMsg_PostMessage::ID) { |
| 232 // We want to send the receiver a routing id for the new channel, so | 233 // We want to send the receiver a routing id for the new channel, so |
| 233 // crack the message first. | 234 // crack the message first. |
| 234 string16 msg; | 235 string16 msg; |
| 235 int sent_message_port_id = MSG_ROUTING_NONE; | 236 std::vector<int> sent_message_port_ids; |
| 236 int new_routing_id = MSG_ROUTING_NONE; | 237 std::vector<int> new_routing_ids; |
| 237 if (!WorkerMsg_PostMessage::Read( | 238 if (!WorkerMsg_PostMessage::Read( |
| 238 &message, &msg, &sent_message_port_id, &new_routing_id)) { | 239 &message, &msg, &sent_message_port_ids, &new_routing_ids)) { |
| 239 return; | 240 return; |
| 240 } | 241 } |
| 242 DCHECK(sent_message_port_ids.size() == new_routing_ids.size()); |
| 241 | 243 |
| 242 if (sent_message_port_id != MSG_ROUTING_NONE) { | 244 for (size_t i = 0; i < sent_message_port_ids.size(); ++i) { |
| 243 new_routing_id = next_route_id->Run(); | 245 new_routing_ids[i] = next_route_id->Run(); |
| 244 MessagePortDispatcher::GetInstance()->UpdateMessagePort( | 246 MessagePortDispatcher::GetInstance()->UpdateMessagePort( |
| 245 sent_message_port_id, sender, new_routing_id, next_route_id); | 247 sent_message_port_ids[i], sender, new_routing_ids[i], next_route_id); |
| 246 } | 248 } |
| 247 | 249 |
| 248 new_message = new WorkerMsg_PostMessage( | 250 new_message = new WorkerMsg_PostMessage( |
| 249 route_id, msg, sent_message_port_id, new_routing_id); | 251 route_id, msg, sent_message_port_ids, new_routing_ids); |
| 250 } else { | 252 } else { |
| 251 new_message = new IPC::Message(message); | 253 new_message = new IPC::Message(message); |
| 252 new_message->set_routing_id(route_id); | 254 new_message->set_routing_id(route_id); |
| 253 } | 255 } |
| 254 | 256 |
| 255 sender->Send(new_message); | 257 sender->Send(new_message); |
| 256 } | 258 } |
| 257 | 259 |
| 258 void WorkerProcessHost::SenderShutdown(IPC::Message::Sender* sender) { | 260 void WorkerProcessHost::SenderShutdown(IPC::Message::Sender* sender) { |
| 259 for (Instances::iterator i = instances_.begin(); i != instances_.end();) { | 261 for (Instances::iterator i = instances_.begin(); i != instances_.end();) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 304 } |
| 303 | 305 |
| 304 void WorkerProcessHost::OnCancelCreateDedicatedWorker(int route_id) { | 306 void WorkerProcessHost::OnCancelCreateDedicatedWorker(int route_id) { |
| 305 WorkerService::GetInstance()->CancelCreateDedicatedWorker( | 307 WorkerService::GetInstance()->CancelCreateDedicatedWorker( |
| 306 GetProcessId(), route_id); | 308 GetProcessId(), route_id); |
| 307 } | 309 } |
| 308 | 310 |
| 309 void WorkerProcessHost::OnForwardToWorker(const IPC::Message& message) { | 311 void WorkerProcessHost::OnForwardToWorker(const IPC::Message& message) { |
| 310 WorkerService::GetInstance()->ForwardMessage(message, GetProcessId()); | 312 WorkerService::GetInstance()->ForwardMessage(message, GetProcessId()); |
| 311 } | 313 } |
| OLD | NEW |