summaryrefslogtreecommitdiffstats
path: root/chrome/worker
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/worker
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/worker')
-rw-r--r--chrome/worker/nativewebworker_impl.cc4
-rw-r--r--chrome/worker/nativewebworker_impl.h3
-rw-r--r--chrome/worker/webworkerclient_proxy.cc32
-rw-r--r--chrome/worker/webworkerclient_proxy.h7
-rw-r--r--chrome/worker/worker_uitest.cc3
5 files changed, 40 insertions, 9 deletions
diff --git a/chrome/worker/nativewebworker_impl.cc b/chrome/worker/nativewebworker_impl.cc
index 5f12041..5fc3ddc 100644
--- a/chrome/worker/nativewebworker_impl.cc
+++ b/chrome/worker/nativewebworker_impl.cc
@@ -35,7 +35,7 @@ class PostMessageTask : public Task {
}
~PostMessageTask() { }
void Run() {
- client_->postMessageToWorkerObject(message_string_);
+ client_->postMessageToWorkerObject(message_string_, NULL);
}
private:
@@ -147,7 +147,7 @@ void NativeWebWorkerImpl::terminateWorkerContext() {
}
void NativeWebWorkerImpl::postMessageToWorkerContext(
- const WebKit::WebString& message) {
+ const WebKit::WebString& message, WebKit::WebMessagePortChannel* 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 6e280cb..7d0944c 100644
--- a/chrome/worker/nativewebworker_impl.h
+++ b/chrome/worker/nativewebworker_impl.h
@@ -27,7 +27,8 @@ class NativeWebWorkerImpl : public WebKit::WebWorker {
const WebKit::WebString& user_agent,
const WebKit::WebString& source_code);
void terminateWorkerContext();
- void postMessageToWorkerContext(const WebKit::WebString& message);
+ void postMessageToWorkerContext(const WebKit::WebString& message,
+ WebKit::WebMessagePortChannel* channel);
void workerObjectDestroyed();
private:
diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc
index 79ba379..fdbaf9a 100644
--- a/chrome/worker/webworkerclient_proxy.cc
+++ b/chrome/worker/webworkerclient_proxy.cc
@@ -7,6 +7,7 @@
#include "base/command_line.h"
#include "chrome/common/child_process.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/webmessageportchannel_impl.h"
#include "chrome/common/worker_messages.h"
#include "chrome/renderer/webworker_proxy.h"
#include "chrome/worker/worker_thread.h"
@@ -16,6 +17,7 @@
#include "webkit/api/public/WebURL.h"
#include "webkit/api/public/WebWorker.h"
+using WebKit::WebMessagePortChannel;
using WebKit::WebString;
using WebKit::WebWorker;
using WebKit::WebWorkerClient;
@@ -78,8 +80,19 @@ WebWorkerClientProxy::~WebWorkerClientProxy() {
}
void WebWorkerClientProxy::postMessageToWorkerObject(
- const WebString& message) {
- Send(new WorkerHostMsg_PostMessageToWorkerObject(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 WebWorkerClientProxy::postExceptionToWorkerObject(
@@ -144,8 +157,7 @@ void WebWorkerClientProxy::OnMessageReceived(const IPC::Message& message) {
WebWorker::startWorkerContext)
IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext,
OnTerminateWorkerContext)
- IPC_MESSAGE_FORWARD(WorkerMsg_PostMessageToWorkerContext, impl_,
- WebWorker::postMessageToWorkerContext)
+ IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage)
IPC_MESSAGE_FORWARD(WorkerMsg_WorkerObjectDestroyed, impl_,
WebWorker::workerObjectDestroyed)
IPC_END_MESSAGE_MAP()
@@ -166,3 +178,15 @@ void WebWorkerClientProxy::OnTerminateWorkerContext() {
MessageLoop::current()->PostDelayedTask(FROM_HERE,
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);
+ }
+
+ impl_->postMessageToWorkerContext(message, channel);
+}
diff --git a/chrome/worker/webworkerclient_proxy.h b/chrome/worker/webworkerclient_proxy.h
index 0e74e41..aadbe07 100644
--- a/chrome/worker/webworkerclient_proxy.h
+++ b/chrome/worker/webworkerclient_proxy.h
@@ -25,7 +25,9 @@ class WebWorkerClientProxy : public WebKit::WebWorkerClient,
WebWorkerClientProxy(const GURL& url, int route_id);
// WebWorkerClient implementation.
- virtual void postMessageToWorkerObject(const WebKit::WebString& message);
+ virtual void postMessageToWorkerObject(
+ const WebKit::WebString& message,
+ WebKit::WebMessagePortChannel* channel);
virtual void postExceptionToWorkerObject(
const WebKit::WebString& error_message,
int line_number,
@@ -52,6 +54,9 @@ class WebWorkerClientProxy : public WebKit::WebWorkerClient,
bool Send(IPC::Message* message);
void OnTerminateWorkerContext();
+ void OnPostMessage(const string16& message,
+ int sent_message_port_id,
+ int new_routing_id);
// The source url for this worker.
GURL url_;
diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc
index cd94fd4..965036d 100644
--- a/chrome/worker/worker_uitest.cc
+++ b/chrome/worker/worker_uitest.cc
@@ -46,6 +46,7 @@ TEST_F(WorkerTest, WorkerFastLayoutTests) {
"worker-event-listener.html",
"worker-gc.html",
"worker-location.html",
+ "worker-messageport.html",
"worker-navigator.html",
"worker-replace-global-constructor.html",
"worker-replace-self.html",
@@ -113,7 +114,7 @@ TEST_F(WorkerTest, WorkerXhrHttpLayoutTests) {
StopHttpServer();
}
-TEST_F(WorkerTest, DISABLED_MessagePorts) {
+TEST_F(WorkerTest, MessagePorts) {
static const char* kLayoutTestFiles[] = {
"message-channel-gc.html",
"message-channel-gc-2.html",