summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/webworker_proxy.cc
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-06 20:20:22 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-06 20:20:22 +0000
commite18e7ad1c60f6472c25bc4af2554f471e55a85a6 (patch)
tree4240f999b4a49da982a2ba91324416db381412f0 /chrome/renderer/webworker_proxy.cc
parent63b397506f70501d8089eecf28f50e17417fdd48 (diff)
downloadchromium_src-e18e7ad1c60f6472c25bc4af2554f471e55a85a6.zip
chromium_src-e18e7ad1c60f6472c25bc4af2554f471e55a85a6.tar.gz
chromium_src-e18e7ad1c60f6472c25bc4af2554f471e55a85a6.tar.bz2
Enable message ports for workers.
TEST=included ui test Review URL: http://codereview.chromium.org/160576 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22653 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/webworker_proxy.cc')
-rw-r--r--chrome/renderer/webworker_proxy.cc32
1 files changed, 27 insertions, 5 deletions
diff --git a/chrome/renderer/webworker_proxy.cc b/chrome/renderer/webworker_proxy.cc
index 54fcd47..5552546 100644
--- a/chrome/renderer/webworker_proxy.cc
+++ b/chrome/renderer/webworker_proxy.cc
@@ -6,10 +6,12 @@
#include "chrome/common/child_thread.h"
#include "chrome/common/render_messages.h"
+#include "chrome/common/webmessageportchannel_impl.h"
#include "chrome/common/worker_messages.h"
#include "webkit/api/public/WebURL.h"
#include "webkit/api/public/WebWorkerClient.h"
+using WebKit::WebMessagePortChannel;
using WebKit::WebString;
using WebKit::WebURL;
using WebKit::WebWorkerClient;
@@ -73,8 +75,18 @@ void WebWorkerProxy::terminateWorkerContext() {
}
void WebWorkerProxy::postMessageToWorkerContext(
- const WebString& message) {
- Send(new WorkerMsg_PostMessageToWorkerContext(route_id_, message));
+ const WebString& message, WebMessagePortChannel* channel) {
+ int message_port_id = MSG_ROUTING_NONE;
+ if (channel) {
+ WebMessagePortChannelImpl* webchannel =
+ static_cast<WebMessagePortChannelImpl*>(channel);
+ message_port_id = webchannel->message_port_id();
+ webchannel->QueueMessages();
+ DCHECK(message_port_id != MSG_ROUTING_NONE);
+ }
+
+ Send(new WorkerMsg_PostMessage(
+ route_id_, message, message_port_id, MSG_ROUTING_NONE));
}
void WebWorkerProxy::workerObjectDestroyed() {
@@ -107,9 +119,7 @@ void WebWorkerProxy::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(WebWorkerProxy, message)
IPC_MESSAGE_HANDLER(ViewMsg_DedicatedWorkerCreated,
OnDedicatedWorkerCreated)
- IPC_MESSAGE_FORWARD(WorkerHostMsg_PostMessageToWorkerObject,
- client_,
- WebWorkerClient::postMessageToWorkerObject)
+ IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage)
IPC_MESSAGE_FORWARD(WorkerHostMsg_PostExceptionToWorkerObject,
client_,
WebWorkerClient::postExceptionToWorkerObject)
@@ -137,6 +147,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);
+ }
+
+ client_->postMessageToWorkerObject(message, channel);
+}
+
void WebWorkerProxy::OnPostConsoleMessageToWorkerObject(
const WorkerHostMsg_PostConsoleMessageToWorkerObject_Params& params) {
client_->postConsoleMessageToWorkerObject(params.destination_identifier,