summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-01 21:20:47 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-01 21:20:47 +0000
commitec775ef9b36dbcb5ebbd4fa550443bfa94c53a9f (patch)
tree5400ae2c5876e13aeeec2ab6ebcfc54f3f479840 /chrome/renderer
parent4b5d64ff3d7d95247ed4f078d8bf585a1726794d (diff)
downloadchromium_src-ec775ef9b36dbcb5ebbd4fa550443bfa94c53a9f.zip
chromium_src-ec775ef9b36dbcb5ebbd4fa550443bfa94c53a9f.tar.gz
chromium_src-ec775ef9b36dbcb5ebbd4fa550443bfa94c53a9f.tar.bz2
Run workers in separate processes.
Review URL: http://codereview.chromium.org/99016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_view.cc2
-rw-r--r--chrome/renderer/webworker_proxy.cc17
-rw-r--r--chrome/renderer/webworker_proxy.h11
3 files changed, 16 insertions, 14 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 4cf4fde..a8a8c41 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1910,7 +1910,7 @@ void RenderView::OnMissingPluginStatus(WebPluginDelegate* delegate,
WebWorker* RenderView::CreateWebWorker(WebWorkerClient* client) {
#if defined(OS_WIN)
- return new WebWorkerProxy(client, routing_id_);
+ return new WebWorkerProxy(client, RenderThread::current(), routing_id_);
#else
// TODO(port): out of process workers
NOTIMPLEMENTED();
diff --git a/chrome/renderer/webworker_proxy.cc b/chrome/renderer/webworker_proxy.cc
index 5e553a2..60fcebb 100644
--- a/chrome/renderer/webworker_proxy.cc
+++ b/chrome/renderer/webworker_proxy.cc
@@ -4,9 +4,9 @@
#include "chrome/renderer/webworker_proxy.h"
+#include "chrome/common/child_thread.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/worker_messages.h"
-#include "chrome/renderer/render_thread.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
#include "third_party/WebKit/WebKit/chromium/public/WebWorkerClient.h"
@@ -16,8 +16,10 @@ using WebKit::WebWorkerClient;
WebWorkerProxy::WebWorkerProxy(
WebWorkerClient* client,
+ ChildThread* child_thread,
int render_view_route_id)
: route_id_(MSG_ROUTING_NONE),
+ child_thread_(child_thread),
render_view_route_id_(render_view_route_id),
client_(client) {
}
@@ -29,13 +31,12 @@ void WebWorkerProxy::startWorkerContext(
const WebURL& script_url,
const WebString& user_agent,
const WebString& source_code) {
- RenderThread::current()->Send(
- new ViewHostMsg_CreateDedicatedWorker(
- script_url, render_view_route_id_, &route_id_));
+ child_thread_->Send(new ViewHostMsg_CreateDedicatedWorker(
+ script_url, render_view_route_id_, &route_id_));
if (route_id_ == MSG_ROUTING_NONE)
return;
- RenderThread::current()->AddRoute(route_id_, this);
+ child_thread_->AddRoute(route_id_, this);
Send(new WorkerMsg_StartWorkerContext(
route_id_, script_url, user_agent, source_code));
@@ -49,7 +50,7 @@ void WebWorkerProxy::startWorkerContext(
void WebWorkerProxy::terminateWorkerContext() {
if (route_id_ != MSG_ROUTING_NONE) {
Send(new WorkerMsg_TerminateWorkerContext(route_id_));
- RenderThread::current()->RemoveRoute(route_id_);
+ child_thread_->RemoveRoute(route_id_);
route_id_ = MSG_ROUTING_NONE;
}
}
@@ -60,8 +61,8 @@ void WebWorkerProxy::postMessageToWorkerContext(
}
void WebWorkerProxy::workerObjectDestroyed() {
- client_ = NULL;
Send(new WorkerMsg_WorkerObjectDestroyed(route_id_));
+ delete this;
}
bool WebWorkerProxy::Send(IPC::Message* message) {
@@ -75,7 +76,7 @@ bool WebWorkerProxy::Send(IPC::Message* message) {
// TODO(jabdelmalek): handle sync messages if we need them.
IPC::Message* wrapped_msg = new ViewHostMsg_ForwardToWorker(*message);
delete message;
- return RenderThread::current()->Send(wrapped_msg);
+ return child_thread_->Send(wrapped_msg);
}
void WebWorkerProxy::OnMessageReceived(const IPC::Message& message) {
diff --git a/chrome/renderer/webworker_proxy.h b/chrome/renderer/webworker_proxy.h
index 7bec251..7c44ba6 100644
--- a/chrome/renderer/webworker_proxy.h
+++ b/chrome/renderer/webworker_proxy.h
@@ -11,13 +11,10 @@
#include "chrome/common/ipc_channel.h"
#include "third_party/WebKit/WebKit/chromium/public/WebWorker.h"
+class ChildThread;
class GURL;
class RenderView;
-namespace IPC {
-class Message;
-}
-
// This class provides an implementation of WebWorker that the renderer provides
// to the glue. This class converts function calls to IPC messages that are
// dispatched in the worker process by WebWorkerClientProxy. It also receives
@@ -26,7 +23,9 @@ class Message;
class WebWorkerProxy : public WebKit::WebWorker,
public IPC::Channel::Listener {
public:
- WebWorkerProxy(WebKit::WebWorkerClient* client, int render_view_route_id);
+ WebWorkerProxy(WebKit::WebWorkerClient* client,
+ ChildThread* child_thread,
+ int render_view_route_id);
virtual ~WebWorkerProxy();
// WebWorker implementation.
@@ -46,6 +45,8 @@ class WebWorkerProxy : public WebKit::WebWorker,
// The routing id used to reach WebWorkerClientProxy in the worker process.
int route_id_;
+ ChildThread* child_thread_;
+
// The routing id for the RenderView that created this worker.
int render_view_route_id_;