summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/worker_host/message_port_dispatcher.cc50
-rw-r--r--chrome/browser/worker_host/message_port_dispatcher.h6
-rw-r--r--chrome/browser/worker_host/worker_process_host.cc16
-rw-r--r--chrome/common/webmessageportchannel_impl.cc77
-rw-r--r--chrome/common/webmessageportchannel_impl.h11
-rw-r--r--chrome/common/worker_messages.h3
-rw-r--r--chrome/common/worker_messages_internal.h11
-rw-r--r--chrome/renderer/webworker_proxy.cc35
-rw-r--r--chrome/renderer/webworker_proxy.h6
-rw-r--r--chrome/worker/nativewebworker_impl.cc6
-rw-r--r--chrome/worker/nativewebworker_impl.h5
-rw-r--r--chrome/worker/webworkerclient_proxy.cc34
-rw-r--r--chrome/worker/webworkerclient_proxy.h10
13 files changed, 159 insertions, 111 deletions
diff --git a/chrome/browser/worker_host/message_port_dispatcher.cc b/chrome/browser/worker_host/message_port_dispatcher.cc
index 4d371de..41ebc37 100644
--- a/chrome/browser/worker_host/message_port_dispatcher.cc
+++ b/chrome/browser/worker_host/message_port_dispatcher.cc
@@ -117,9 +117,10 @@ void MessagePortDispatcher::OnEntangle(int local_message_port_id,
local_message_port_id;
}
-void MessagePortDispatcher::OnPostMessage(int sender_message_port_id,
- const string16& message,
- int sent_message_port_id) {
+void MessagePortDispatcher::OnPostMessage(
+ int sender_message_port_id,
+ const string16& message,
+ const std::vector<int>& sent_message_port_ids) {
if (!message_ports_.count(sender_message_port_id)) {
NOTREACHED();
return;
@@ -135,47 +136,52 @@ void MessagePortDispatcher::OnPostMessage(int sender_message_port_id,
return;
}
- PostMessageTo(entangled_message_port_id, message, sent_message_port_id);
+ PostMessageTo(entangled_message_port_id, message, sent_message_port_ids);
}
-void MessagePortDispatcher::PostMessageTo(int message_port_id,
- const string16& message,
- int sent_message_port_id) {
- if (!message_ports_.count(message_port_id) ||
- (sent_message_port_id != MSG_ROUTING_NONE &&
- !message_ports_.count(sent_message_port_id))) {
+void MessagePortDispatcher::PostMessageTo(
+ int message_port_id,
+ const string16& message,
+ const std::vector<int>& sent_message_port_ids) {
+ if (!message_ports_.count(message_port_id)) {
NOTREACHED();
return;
}
+ for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
+ if (!message_ports_.count(sent_message_port_ids[i])) {
+ NOTREACHED();
+ return;
+ }
+ }
MessagePort& entangled_port = message_ports_[message_port_id];
- MessagePort* sent_port = NULL;
- if (sent_message_port_id != MSG_ROUTING_NONE) {
- sent_port = &message_ports_[sent_message_port_id];
- sent_port->queue_messages = true;
+ std::vector<MessagePort*> sent_ports(sent_message_port_ids.size());
+ for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
+ sent_ports[i] = &message_ports_[sent_message_port_ids[i]];
+ sent_ports[i]->queue_messages = true;
}
if (entangled_port.queue_messages) {
entangled_port.queued_messages.push_back(
- std::make_pair(message, sent_message_port_id));
+ std::make_pair(message, sent_message_port_ids));
} else {
// If a message port was sent around, the new location will need a routing
// id. Instead of having the created port send us a sync message to get it,
// send along with the message.
- int new_routing_id = MSG_ROUTING_NONE;
- if (sent_message_port_id != MSG_ROUTING_NONE) {
- new_routing_id = entangled_port.next_routing_id->Run();
- sent_port->sender = entangled_port.sender;
+ std::vector<int> new_routing_ids(sent_message_port_ids.size());
+ for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
+ new_routing_ids[i] = entangled_port.next_routing_id->Run();
+ sent_ports[i]->sender = entangled_port.sender;
// Update the entry for the sent port as it can be in a different process.
- sent_port->route_id = new_routing_id;
+ sent_ports[i]->route_id = new_routing_ids[i];
}
// Now send the message to the entangled port.
IPC::Message* ipc_msg = new WorkerProcessMsg_Message(
- entangled_port.route_id, message, sent_message_port_id,
- new_routing_id);
+ entangled_port.route_id, message, sent_message_port_ids,
+ new_routing_ids);
entangled_port.sender->Send(ipc_msg);
}
}
diff --git a/chrome/browser/worker_host/message_port_dispatcher.h b/chrome/browser/worker_host/message_port_dispatcher.h
index ae2536b..c728f38 100644
--- a/chrome/browser/worker_host/message_port_dispatcher.h
+++ b/chrome/browser/worker_host/message_port_dispatcher.h
@@ -18,7 +18,7 @@
class MessagePortDispatcher : public NotificationObserver {
public:
- typedef std::vector<std::pair<string16, int> > QueuedMessages;
+ typedef std::vector<std::pair<string16, std::vector<int> > > QueuedMessages;
// Returns the MessagePortDispatcher singleton.
static MessagePortDispatcher* GetInstance();
@@ -48,14 +48,14 @@ class MessagePortDispatcher : public NotificationObserver {
void OnEntangle(int local_message_port_id, int remote_message_port_id);
void OnPostMessage(int sender_message_port_id,
const string16& message,
- int sent_message_port_id);
+ const std::vector<int>& sent_message_port_ids);
void OnQueueMessages(int message_port_id);
void OnSendQueuedMessages(int message_port_id,
const QueuedMessages& queued_messages);
void PostMessageTo(int message_port_id,
const string16& message,
- int sent_message_port_id);
+ const std::vector<int>& sent_message_port_ids);
// NotificationObserver interface.
void Observe(NotificationType type,
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc
index 3de362cf..69d3a96 100644
--- a/chrome/browser/worker_host/worker_process_host.cc
+++ b/chrome/browser/worker_host/worker_process_host.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/worker_host/worker_process_host.h"
#include <set>
+#include <vector>
#include "base/command_line.h"
#include "base/debug_util.h"
@@ -232,21 +233,22 @@ void WorkerProcessHost::RelayMessage(
// We want to send the receiver a routing id for the new channel, so
// crack the message first.
string16 msg;
- int sent_message_port_id = MSG_ROUTING_NONE;
- int new_routing_id = MSG_ROUTING_NONE;
+ std::vector<int> sent_message_port_ids;
+ std::vector<int> new_routing_ids;
if (!WorkerMsg_PostMessage::Read(
- &message, &msg, &sent_message_port_id, &new_routing_id)) {
+ &message, &msg, &sent_message_port_ids, &new_routing_ids)) {
return;
}
+ DCHECK(sent_message_port_ids.size() == new_routing_ids.size());
- if (sent_message_port_id != MSG_ROUTING_NONE) {
- new_routing_id = next_route_id->Run();
+ for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
+ new_routing_ids[i] = next_route_id->Run();
MessagePortDispatcher::GetInstance()->UpdateMessagePort(
- sent_message_port_id, sender, new_routing_id, next_route_id);
+ sent_message_port_ids[i], sender, new_routing_ids[i], next_route_id);
}
new_message = new WorkerMsg_PostMessage(
- route_id, msg, sent_message_port_id, new_routing_id);
+ route_id, msg, sent_message_port_ids, new_routing_ids);
} else {
new_message = new IPC::Message(message);
new_message->set_routing_id(route_id);
diff --git a/chrome/common/webmessageportchannel_impl.cc b/chrome/common/webmessageportchannel_impl.cc
index 6e1b4e1..f585355 100644
--- a/chrome/common/webmessageportchannel_impl.cc
+++ b/chrome/common/webmessageportchannel_impl.cc
@@ -11,6 +11,7 @@
#include "webkit/api/public/WebMessagePortChannelClient.h"
using WebKit::WebMessagePortChannel;
+using WebKit::WebMessagePortChannelArray;
using WebKit::WebMessagePortChannelClient;
using WebKit::WebString;
@@ -33,6 +34,16 @@ WebMessagePortChannelImpl::WebMessagePortChannelImpl(
}
WebMessagePortChannelImpl::~WebMessagePortChannelImpl() {
+ // If we have any queued messages with attached ports, manually destroy them.
+ while (!message_queue_.empty()) {
+ const std::vector<WebMessagePortChannelImpl*>& channel_array =
+ message_queue_.front().ports;
+ for (size_t i = 0; i < channel_array.size(); i++) {
+ channel_array[i]->destroy();
+ }
+ message_queue_.pop();
+ }
+
if (message_port_id_ != MSG_ROUTING_NONE)
Send(new WorkerProcessHostMsg_DestroyMessagePort(message_port_id_));
@@ -65,39 +76,46 @@ void WebMessagePortChannelImpl::entangle(WebMessagePortChannel* channel) {
void WebMessagePortChannelImpl::postMessage(
const WebString& message,
- WebMessagePortChannel* channel) {
+ WebMessagePortChannelArray* channels) {
if (MessageLoop::current() != ChildThread::current()->message_loop()) {
ChildThread::current()->message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(this, &WebMessagePortChannelImpl::postMessage,
- message, channel));
+ message, channels));
return;
}
- WebMessagePortChannelImpl* webchannel =
- static_cast<WebMessagePortChannelImpl*>(channel);
-
- int message_port_id = MSG_ROUTING_NONE;
- if (webchannel) {
- message_port_id = webchannel->message_port_id();
- webchannel->QueueMessages();
- DCHECK(message_port_id != MSG_ROUTING_NONE);
+ std::vector<int> message_port_ids(channels ? channels->size() : 0);
+ if (channels) {
+ for (size_t i = 0; i < channels->size(); ++i) {
+ WebMessagePortChannelImpl* webchannel =
+ static_cast<WebMessagePortChannelImpl*>((*channels)[i]);
+ message_port_ids[i] = webchannel->message_port_id();
+ webchannel->QueueMessages();
+ DCHECK(message_port_ids[i] != MSG_ROUTING_NONE);
+ }
}
IPC::Message* msg = new WorkerProcessHostMsg_PostMessage(
- message_port_id_, message, message_port_id);
-
+ message_port_id_, message, message_port_ids);
Send(msg);
}
bool WebMessagePortChannelImpl::tryGetMessage(
WebString* message,
- WebMessagePortChannel** channel) {
+ WebMessagePortChannelArray& channels) {
AutoLock auto_lock(lock_);
if (message_queue_.empty())
return false;
*message = message_queue_.front().message;
- *channel = message_queue_.front().port.release();
+ const std::vector<WebMessagePortChannelImpl*>& channel_array =
+ message_queue_.front().ports;
+ WebMessagePortChannelArray result_ports(channel_array.size());
+ for (size_t i = 0; i < channel_array.size(); i++) {
+ result_ports[i] = channel_array[i];
+ }
+
+ channels.swap(result_ports);
message_queue_.pop();
return true;
}
@@ -162,16 +180,19 @@ void WebMessagePortChannelImpl::OnMessageReceived(const IPC::Message& message) {
IPC_END_MESSAGE_MAP()
}
-void WebMessagePortChannelImpl::OnMessage(const string16& message,
- int sent_message_port_id,
- int new_routing_id) {
+void WebMessagePortChannelImpl::OnMessage(
+ const string16& message,
+ const std::vector<int>& sent_message_port_ids,
+ const std::vector<int>& new_routing_ids) {
AutoLock auto_lock(lock_);
Message msg;
msg.message = message;
- msg.port = NULL;
- if (sent_message_port_id != MSG_ROUTING_NONE) {
- msg.port = new WebMessagePortChannelImpl(
- new_routing_id, sent_message_port_id);
+ if (!sent_message_port_ids.empty()) {
+ msg.ports.resize(sent_message_port_ids.size());
+ for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
+ msg.ports[i] = new WebMessagePortChannelImpl(
+ new_routing_ids[i], sent_message_port_ids[i]);
+ }
}
bool was_empty = message_queue_.empty();
@@ -181,18 +202,20 @@ void WebMessagePortChannelImpl::OnMessage(const string16& message,
}
void WebMessagePortChannelImpl::OnMessagedQueued() {
- std::vector<std::pair<string16, int> > queued_messages;
+ std::vector<QueuedMessage> queued_messages;
{
AutoLock auto_lock(lock_);
queued_messages.reserve(message_queue_.size());
while (!message_queue_.empty()) {
string16 message = message_queue_.front().message;
- int port = MSG_ROUTING_NONE;
- if (message_queue_.front().port)
- port = message_queue_.front().port->message_port_id();
-
- queued_messages.push_back(std::make_pair(message, port));
+ const std::vector<WebMessagePortChannelImpl*>& channel_array =
+ message_queue_.front().ports;
+ std::vector<int> port_ids(channel_array.size());
+ for (size_t i = 0; i < channel_array.size(); ++i) {
+ port_ids[i] = channel_array[i]->message_port_id();
+ }
+ queued_messages.push_back(std::make_pair(message, port_ids));
message_queue_.pop();
}
}
diff --git a/chrome/common/webmessageportchannel_impl.h b/chrome/common/webmessageportchannel_impl.h
index ee26e66..89a36b0 100644
--- a/chrome/common/webmessageportchannel_impl.h
+++ b/chrome/common/webmessageportchannel_impl.h
@@ -6,6 +6,7 @@
#define CHROME_COMMON_WEBMESSAGEPORTCHANNEL_IMPL_H_
#include <queue>
+#include <vector>
#include "base/basictypes.h"
#include "base/lock.h"
@@ -37,9 +38,9 @@ class WebMessagePortChannelImpl
virtual void destroy();
virtual void entangle(WebKit::WebMessagePortChannel* channel);
virtual void postMessage(const WebKit::WebString& message,
- WebKit::WebMessagePortChannel* channel);
+ WebKit::WebMessagePortChannelArray* channels);
virtual bool tryGetMessage(WebKit::WebString* message,
- WebKit::WebMessagePortChannel** channel);
+ WebKit::WebMessagePortChannelArray& channels);
void Init();
void Entangle(scoped_refptr<WebMessagePortChannelImpl> channel);
@@ -49,13 +50,13 @@ class WebMessagePortChannelImpl
virtual void OnMessageReceived(const IPC::Message& message);
void OnMessage(const string16& message,
- int sent_message_port_id,
- int new_routing_id);
+ const std::vector<int>& sent_message_port_ids,
+ const std::vector<int>& new_routing_ids);
void OnMessagedQueued();
struct Message {
string16 message;
- scoped_refptr<WebMessagePortChannelImpl> port;
+ std::vector<WebMessagePortChannelImpl*> ports;
};
typedef std::queue<Message> MessageQueue;
diff --git a/chrome/common/worker_messages.h b/chrome/common/worker_messages.h
index b929d2c..4af15c4 100644
--- a/chrome/common/worker_messages.h
+++ b/chrome/common/worker_messages.h
@@ -9,12 +9,13 @@
#define CHROME_COMMON_WORKER_MESSAGES_H_
#include <string>
+#include <vector>
#include "base/basictypes.h"
#include "chrome/common/common_param_traits.h"
#include "ipc/ipc_message_utils.h"
-typedef std::pair<string16, int> QueuedMessage;
+typedef std::pair<string16, std::vector<int> > QueuedMessage;
// Parameters structure for WorkerHostMsg_PostConsoleMessageToWorkerObject,
// which has too many data parameters to be reasonably put in a predefined
diff --git a/chrome/common/worker_messages_internal.h b/chrome/common/worker_messages_internal.h
index 16dab5d..9b1cac2 100644
--- a/chrome/common/worker_messages_internal.h
+++ b/chrome/common/worker_messages_internal.h
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <utility>
+#include <vector>
#include "base/string16.h"
#include "googleurl/src/gurl.h"
#include "ipc/ipc_message_macros.h"
@@ -21,8 +22,8 @@ IPC_BEGIN_MESSAGES(WorkerProcess)
// like common_messages_internal.h
IPC_MESSAGE_ROUTED3(WorkerProcessMsg_Message,
string16 /* message */,
- int /* sent_message_port_id */,
- int /* new_routing_id */)
+ std::vector<int> /* sent_message_port_ids */,
+ std::vector<int> /* new_routing_ids */)
// Tells the Message Port Channel object that there are no more in-flight
// messages arriving.
@@ -55,7 +56,7 @@ IPC_BEGIN_MESSAGES(WorkerProcessHost)
IPC_MESSAGE_CONTROL3(WorkerProcessHostMsg_PostMessage,
int /* sender_message_port_id */,
string16 /* message */,
- int /* sent_message_port_id */)
+ std::vector<int> /* sent_message_port_ids */)
// Causes messages sent to the remote port to be delivered to this local port.
IPC_MESSAGE_CONTROL2(WorkerProcessHostMsg_Entangle,
@@ -90,8 +91,8 @@ IPC_BEGIN_MESSAGES(Worker)
IPC_MESSAGE_ROUTED3(WorkerMsg_PostMessage,
string16 /* message */,
- int /* sent_message_port_id */,
- int /* new_routing_id */)
+ std::vector<int> /* sent_message_port_ids */,
+ std::vector<int> /* new_routing_ids */)
IPC_MESSAGE_ROUTED0(WorkerMsg_WorkerObjectDestroyed)
IPC_END_MESSAGES(Worker)
diff --git a/chrome/renderer/webworker_proxy.cc b/chrome/renderer/webworker_proxy.cc
index 5552546..b350470 100644
--- a/chrome/renderer/webworker_proxy.cc
+++ b/chrome/renderer/webworker_proxy.cc
@@ -12,6 +12,7 @@
#include "webkit/api/public/WebWorkerClient.h"
using WebKit::WebMessagePortChannel;
+using WebKit::WebMessagePortChannelArray;
using WebKit::WebString;
using WebKit::WebURL;
using WebKit::WebWorkerClient;
@@ -75,18 +76,20 @@ void WebWorkerProxy::terminateWorkerContext() {
}
void WebWorkerProxy::postMessageToWorkerContext(
- const WebString& message, WebMessagePortChannel* channel) {
- int message_port_id = MSG_ROUTING_NONE;
- if (channel) {
+ const WebString& message, const WebMessagePortChannelArray& channels) {
+ std::vector<int> message_port_ids(channels.size());
+ std::vector<int> routing_ids(channels.size());
+ for (size_t i = 0; i < channels.size(); ++i) {
WebMessagePortChannelImpl* webchannel =
- static_cast<WebMessagePortChannelImpl*>(channel);
- message_port_id = webchannel->message_port_id();
+ static_cast<WebMessagePortChannelImpl*>(channels[i]);
+ message_port_ids[i] = webchannel->message_port_id();
webchannel->QueueMessages();
- DCHECK(message_port_id != MSG_ROUTING_NONE);
+ routing_ids[i] = MSG_ROUTING_NONE;
+ DCHECK(message_port_ids[i] != MSG_ROUTING_NONE);
}
Send(new WorkerMsg_PostMessage(
- route_id_, message, message_port_id, MSG_ROUTING_NONE));
+ route_id_, message, message_port_ids, routing_ids));
}
void WebWorkerProxy::workerObjectDestroyed() {
@@ -147,16 +150,18 @@ void WebWorkerProxy::OnDedicatedWorkerCreated() {
}
}
-void WebWorkerProxy::OnPostMessage(const string16& message,
- int sent_message_port_id,
- int new_routing_id) {
- WebMessagePortChannel* channel = NULL;
- if (sent_message_port_id != MSG_ROUTING_NONE) {
- channel = new WebMessagePortChannelImpl(
- new_routing_id, sent_message_port_id);
+void WebWorkerProxy::OnPostMessage(
+ const string16& message,
+ const std::vector<int>& sent_message_port_ids,
+ const std::vector<int>& new_routing_ids) {
+ DCHECK(new_routing_ids.size() == sent_message_port_ids.size());
+ WebMessagePortChannelArray channels(sent_message_port_ids.size());
+ for (size_t i = 0; i < sent_message_port_ids.size(); ++i) {
+ channels[i] = new WebMessagePortChannelImpl(
+ new_routing_ids[i], sent_message_port_ids[i]);
}
- client_->postMessageToWorkerObject(message, channel);
+ client_->postMessageToWorkerObject(message, channels);
}
void WebWorkerProxy::OnPostConsoleMessageToWorkerObject(
diff --git a/chrome/renderer/webworker_proxy.h b/chrome/renderer/webworker_proxy.h
index 5eeb416..d47f3fb 100644
--- a/chrome/renderer/webworker_proxy.h
+++ b/chrome/renderer/webworker_proxy.h
@@ -36,7 +36,7 @@ class WebWorkerProxy : public WebKit::WebWorker,
virtual void terminateWorkerContext();
virtual void postMessageToWorkerContext(
const WebKit::WebString& message,
- WebKit::WebMessagePortChannel* channel);
+ const WebKit::WebMessagePortChannelArray& channel_array);
virtual void workerObjectDestroyed();
// IPC::Channel::Listener implementation.
@@ -47,8 +47,8 @@ class WebWorkerProxy : public WebKit::WebWorker,
void OnDedicatedWorkerCreated();
void OnPostMessage(const string16& message,
- int sent_message_port_id,
- int new_routing_id);
+ const std::vector<int>& sent_message_port_ids,
+ const std::vector<int>& new_routing_ids);
void OnPostConsoleMessageToWorkerObject(
const WorkerHostMsg_PostConsoleMessageToWorkerObject_Params& params);
diff --git a/chrome/worker/nativewebworker_impl.cc b/chrome/worker/nativewebworker_impl.cc
index 5fc3ddc..9dfd739 100644
--- a/chrome/worker/nativewebworker_impl.cc
+++ b/chrome/worker/nativewebworker_impl.cc
@@ -35,7 +35,8 @@ class PostMessageTask : public Task {
}
~PostMessageTask() { }
void Run() {
- client_->postMessageToWorkerObject(message_string_, NULL);
+ WebKit::WebMessagePortChannelArray empty_array;
+ client_->postMessageToWorkerObject(message_string_, empty_array);
}
private:
@@ -147,7 +148,8 @@ void NativeWebWorkerImpl::terminateWorkerContext() {
}
void NativeWebWorkerImpl::postMessageToWorkerContext(
- const WebKit::WebString& message, WebKit::WebMessagePortChannel* channel) {
+ const WebKit::WebString& message,
+ const WebKit::WebMessagePortChannelArray& channel) {
size_t len;
char* bufp = WebStringToCharp(message, &len);
// Send a message to NaCl object
diff --git a/chrome/worker/nativewebworker_impl.h b/chrome/worker/nativewebworker_impl.h
index 7d0944c..29d85c9 100644
--- a/chrome/worker/nativewebworker_impl.h
+++ b/chrome/worker/nativewebworker_impl.h
@@ -27,8 +27,9 @@ class NativeWebWorkerImpl : public WebKit::WebWorker {
const WebKit::WebString& user_agent,
const WebKit::WebString& source_code);
void terminateWorkerContext();
- void postMessageToWorkerContext(const WebKit::WebString& message,
- WebKit::WebMessagePortChannel* channel);
+ void postMessageToWorkerContext(
+ const WebKit::WebString& message,
+ const WebKit::WebMessagePortChannelArray& channels);
void workerObjectDestroyed();
private:
diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc
index fdbaf9a..f0c6571 100644
--- a/chrome/worker/webworkerclient_proxy.cc
+++ b/chrome/worker/webworkerclient_proxy.cc
@@ -18,6 +18,7 @@
#include "webkit/api/public/WebWorker.h"
using WebKit::WebMessagePortChannel;
+using WebKit::WebMessagePortChannelArray;
using WebKit::WebString;
using WebKit::WebWorker;
using WebKit::WebWorkerClient;
@@ -81,18 +82,20 @@ WebWorkerClientProxy::~WebWorkerClientProxy() {
void WebWorkerClientProxy::postMessageToWorkerObject(
const WebString& message,
- WebMessagePortChannel* channel) {
- int message_port_id = MSG_ROUTING_NONE;
- if (channel) {
+ const WebMessagePortChannelArray& channels) {
+ std::vector<int> message_port_ids(channels.size());
+ std::vector<int> routing_ids(channels.size());
+ for (size_t i = 0; i < channels.size(); ++i) {
WebMessagePortChannelImpl* webchannel =
- static_cast<WebMessagePortChannelImpl*>(channel);
- message_port_id = webchannel->message_port_id();
+ static_cast<WebMessagePortChannelImpl*>(channels[i]);
+ message_port_ids[i] = webchannel->message_port_id();
webchannel->QueueMessages();
- DCHECK(message_port_id != MSG_ROUTING_NONE);
+ DCHECK(message_port_ids[i] != MSG_ROUTING_NONE);
+ routing_ids[i] = MSG_ROUTING_NONE;
}
Send(new WorkerMsg_PostMessage(
- route_id_, message, message_port_id, MSG_ROUTING_NONE));
+ route_id_, message, message_port_ids, routing_ids));
}
void WebWorkerClientProxy::postExceptionToWorkerObject(
@@ -179,14 +182,15 @@ void WebWorkerClientProxy::OnTerminateWorkerContext() {
new KillProcessTask(this), kMaxTimeForRunawayWorkerMs);
}
-void WebWorkerClientProxy::OnPostMessage(const string16& message,
- int sent_message_port_id,
- int new_routing_id) {
- WebMessagePortChannel* channel = NULL;
- if (sent_message_port_id != MSG_ROUTING_NONE) {
- channel = new WebMessagePortChannelImpl(
- new_routing_id, sent_message_port_id);
+void WebWorkerClientProxy::OnPostMessage(
+ const string16& message,
+ const std::vector<int>& sent_message_port_ids,
+ const std::vector<int>& new_routing_ids) {
+ WebMessagePortChannelArray channels(sent_message_port_ids.size());
+ for (size_t i = 0; i < sent_message_port_ids.size(); i++) {
+ channels[i] = new WebMessagePortChannelImpl(
+ new_routing_ids[i], sent_message_port_ids[i]);
}
- impl_->postMessageToWorkerContext(message, channel);
+ impl_->postMessageToWorkerContext(message, channels);
}
diff --git a/chrome/worker/webworkerclient_proxy.h b/chrome/worker/webworkerclient_proxy.h
index aadbe07..8807d63 100644
--- a/chrome/worker/webworkerclient_proxy.h
+++ b/chrome/worker/webworkerclient_proxy.h
@@ -5,6 +5,8 @@
#ifndef CHROME_WORKER_WEBWORKERCLIENT_PROXY_H_
#define CHROME_WORKER_WEBWORKERCLIENT_PROXY_H_
+#include <vector>
+
#include "base/basictypes.h"
#include "googleurl/src/gurl.h"
#include "ipc/ipc_channel.h"
@@ -27,7 +29,7 @@ class WebWorkerClientProxy : public WebKit::WebWorkerClient,
// WebWorkerClient implementation.
virtual void postMessageToWorkerObject(
const WebKit::WebString& message,
- WebKit::WebMessagePortChannel* channel);
+ const WebKit::WebMessagePortChannelArray& channel);
virtual void postExceptionToWorkerObject(
const WebKit::WebString& error_message,
int line_number,
@@ -49,14 +51,14 @@ class WebWorkerClientProxy : public WebKit::WebWorkerClient,
virtual void OnMessageReceived(const IPC::Message& message);
private:
- ~WebWorkerClientProxy ();
+ ~WebWorkerClientProxy();
bool Send(IPC::Message* message);
void OnTerminateWorkerContext();
void OnPostMessage(const string16& message,
- int sent_message_port_id,
- int new_routing_id);
+ const std::vector<int>& sent_message_port_ids,
+ const std::vector<int>& new_routing_ids);
// The source url for this worker.
GURL url_;