summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authoratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 08:04:18 +0000
committeratwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 08:04:18 +0000
commitf94ead7d53296e14f1254ad1cdd4b73f3d6b9130 (patch)
tree9a69ebed813f36d6f410f5a99193c40edd6aac07 /chrome
parente796881505363ef53a4082bb0450cd169f1d8d44 (diff)
downloadchromium_src-f94ead7d53296e14f1254ad1cdd4b73f3d6b9130.zip
chromium_src-f94ead7d53296e14f1254ad1cdd4b73f3d6b9130.tar.gz
chromium_src-f94ead7d53296e14f1254ad1cdd4b73f3d6b9130.tar.bz2
Revert "Added beginnings of browser-process support for shared workers."
This reverts commit 31077. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31080 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc15
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h8
-rw-r--r--chrome/browser/worker_host/worker_process_host.cc21
-rw-r--r--chrome/browser/worker_host/worker_process_host.h10
-rw-r--r--chrome/browser/worker_host/worker_service.cc16
-rw-r--r--chrome/browser/worker_host/worker_service.h14
-rwxr-xr-xchrome/chrome.gyp10
-rw-r--r--chrome/common/render_messages_internal.h12
-rw-r--r--chrome/common/worker_messages_internal.h4
-rw-r--r--chrome/renderer/websharedworker_impl.cc (renamed from chrome/renderer/websharedworker_proxy.cc)28
-rw-r--r--chrome/renderer/websharedworker_impl.h (renamed from chrome/renderer/websharedworker_proxy.h)23
-rw-r--r--chrome/renderer/webworker_base.cc8
-rw-r--r--chrome/renderer/webworker_base.h5
-rw-r--r--chrome/renderer/webworker_proxy.cc9
-rw-r--r--chrome/renderer/webworker_proxy.h1
-rw-r--r--chrome/worker/websharedworker_stub.cc52
-rw-r--r--chrome/worker/websharedworker_stub.h40
-rw-r--r--chrome/worker/webworker_stub.cc84
-rw-r--r--chrome/worker/webworker_stub.h38
-rw-r--r--chrome/worker/webworker_stub_base.cc32
-rw-r--r--chrome/worker/webworker_stub_base.h36
-rw-r--r--chrome/worker/webworkerclient_proxy.cc76
-rw-r--r--chrome/worker/webworkerclient_proxy.h26
-rw-r--r--chrome/worker/worker_thread.cc15
-rw-r--r--chrome/worker/worker_thread.h3
25 files changed, 179 insertions, 407 deletions
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index e386edc..f817a9b 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -308,7 +308,8 @@ bool ResourceMessageFilter::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_OpenChannelToPlugin,
OnOpenChannelToPlugin)
IPC_MESSAGE_HANDLER(ViewHostMsg_LaunchNaCl, OnLaunchNaCl)
- IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWorker, OnCreateWorker)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_CreateDedicatedWorker,
+ OnCreateDedicatedWorker)
IPC_MESSAGE_HANDLER(ViewHostMsg_CancelCreateDedicatedWorker,
OnCancelCreateDedicatedWorker)
IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToWorker,
@@ -646,14 +647,12 @@ void ResourceMessageFilter::OnLaunchNaCl(const std::wstring& url,
nacl_process_id);
}
-void ResourceMessageFilter::OnCreateWorker(const GURL& url,
- bool is_shared,
- const string16& name,
- int render_view_route_id,
- int* route_id) {
+void ResourceMessageFilter::OnCreateDedicatedWorker(const GURL& url,
+ int render_view_route_id,
+ int* route_id) {
*route_id = render_widget_helper_->GetNextRoutingID();
- WorkerService::GetInstance()->CreateWorker(
- url, is_shared, name, id(), render_view_route_id, this, id(), *route_id);
+ WorkerService::GetInstance()->CreateDedicatedWorker(
+ url, id(), render_view_route_id, this, id(), *route_id);
}
void ResourceMessageFilter::OnCancelCreateDedicatedWorker(int route_id) {
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 9d21a4f..82a9383 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -166,11 +166,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
nacl::FileDescriptor* handle,
base::ProcessHandle* nacl_process_handle,
base::ProcessId* nacl_process_id);
- void OnCreateWorker(const GURL& url,
- bool is_shared,
- const string16& name,
- int render_view_route_id,
- int* route_id);
+ void OnCreateDedicatedWorker(const GURL& url,
+ int render_view_route_id,
+ int* route_id);
void OnCancelCreateDedicatedWorker(int route_id);
void OnForwardToWorker(const IPC::Message& msg);
void OnDownloadUrl(const IPC::Message& message,
diff --git a/chrome/browser/worker_host/worker_process_host.cc b/chrome/browser/worker_host/worker_process_host.cc
index 02e3cc6..eb6d2fe 100644
--- a/chrome/browser/worker_host/worker_process_host.cc
+++ b/chrome/browser/worker_host/worker_process_host.cc
@@ -139,10 +139,8 @@ void WorkerProcessHost::CreateWorker(const WorkerInstance& instance) {
id(), instance.url);
instances_.push_back(instance);
- Send(new WorkerProcessMsg_CreateWorker(instance.url,
- instance.is_shared,
- instance.name,
- instance.worker_route_id));
+ Send(new WorkerProcessMsg_CreateWorker(
+ instance.url, instance.worker_route_id));
UpdateTitle();
instances_.back().sender->Send(
@@ -177,7 +175,8 @@ void WorkerProcessHost::OnMessageReceived(const IPC::Message& message) {
if (!handled) {
handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(WorkerProcessHost, message, msg_is_ok)
- IPC_MESSAGE_HANDLER(ViewHostMsg_CreateWorker, OnCreateWorker)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_CreateDedicatedWorker,
+ OnCreateDedicatedWorker)
IPC_MESSAGE_HANDLER(ViewHostMsg_CancelCreateDedicatedWorker,
OnCancelCreateDedicatedWorker)
IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardToWorker,
@@ -322,15 +321,13 @@ void WorkerProcessHost::UpdateTitle() {
set_name(ASCIIToWide(display_title));
}
-void WorkerProcessHost::OnCreateWorker(const GURL& url,
- bool is_shared,
- const string16& name,
- int render_view_route_id,
- int* route_id) {
+void WorkerProcessHost::OnCreateDedicatedWorker(const GURL& url,
+ int render_view_route_id,
+ int* route_id) {
DCHECK(instances_.size() == 1); // Only called when one process per worker.
*route_id = WorkerService::GetInstance()->next_worker_route_id();
- WorkerService::GetInstance()->CreateWorker(
- url, is_shared, name, instances_.front().renderer_id,
+ WorkerService::GetInstance()->CreateDedicatedWorker(
+ url, instances_.front().renderer_id,
instances_.front().render_view_route_id, this, id(), *route_id);
}
diff --git a/chrome/browser/worker_host/worker_process_host.h b/chrome/browser/worker_host/worker_process_host.h
index 1fae373..65f4999 100644
--- a/chrome/browser/worker_host/worker_process_host.h
+++ b/chrome/browser/worker_host/worker_process_host.h
@@ -19,8 +19,6 @@ class WorkerProcessHost : public ChildProcessHost {
// between the renderer and worker processes.
struct WorkerInstance {
GURL url;
- bool is_shared;
- string16 name;
int renderer_id;
int render_view_route_id;
int worker_route_id;
@@ -75,11 +73,9 @@ class WorkerProcessHost : public ChildProcessHost {
// Updates the title shown in the task manager.
void UpdateTitle();
- void OnCreateWorker(const GURL& url,
- bool is_shared,
- const string16& name,
- int render_view_route_id,
- int* route_id);
+ void OnCreateDedicatedWorker(const GURL& url,
+ int render_view_route_id,
+ int* route_id);
void OnCancelCreateDedicatedWorker(int route_id);
void OnForwardToWorker(const IPC::Message& message);
diff --git a/chrome/browser/worker_host/worker_service.cc b/chrome/browser/worker_host/worker_service.cc
index 334917f..a54bb2a 100644
--- a/chrome/browser/worker_host/worker_service.cc
+++ b/chrome/browser/worker_host/worker_service.cc
@@ -44,28 +44,24 @@ void WorkerService::Initialize(ResourceDispatcherHost* rdh) {
WorkerService::~WorkerService() {
}
-bool WorkerService::CreateWorker(const GURL &url,
- bool is_shared,
- const string16& name,
- int renderer_id,
- int render_view_route_id,
- IPC::Message::Sender* sender,
- int sender_id,
- int sender_route_id) {
+bool WorkerService::CreateDedicatedWorker(const GURL &url,
+ int renderer_id,
+ int render_view_route_id,
+ IPC::Message::Sender* sender,
+ int sender_id,
+ int sender_route_id) {
// Generate a unique route id for the browser-worker communication that's
// unique among all worker processes. That way when the worker process sends
// a wrapped IPC message through us, we know which WorkerProcessHost to give
// it to.
WorkerProcessHost::WorkerInstance instance;
instance.url = url;
- instance.name = name;
instance.renderer_id = renderer_id;
instance.render_view_route_id = render_view_route_id;
instance.worker_route_id = next_worker_route_id();
instance.sender = sender;
instance.sender_id = sender_id;
instance.sender_route_id = sender_route_id;
- instance.is_shared = is_shared;
WorkerProcessHost* worker = NULL;
if (CommandLine::ForCurrentProcess()->HasSwitch(
diff --git a/chrome/browser/worker_host/worker_service.h b/chrome/browser/worker_host/worker_service.h
index 40267aa..0bd6f58 100644
--- a/chrome/browser/worker_host/worker_service.h
+++ b/chrome/browser/worker_host/worker_service.h
@@ -26,14 +26,12 @@ class WorkerService : public NotificationObserver {
void Initialize(ResourceDispatcherHost* rdh);
// Creates a dedicated worker. Returns true on success.
- bool CreateWorker(const GURL &url,
- bool is_shared,
- const string16& name,
- int renderer_pid,
- int render_view_route_id,
- IPC::Message::Sender* sender,
- int sender_id,
- int sender_route_id);
+ bool CreateDedicatedWorker(const GURL &url,
+ int renderer_pid,
+ int render_view_route_id,
+ IPC::Message::Sender* sender,
+ int sender_id,
+ int sender_route_id);
// Cancel creation of a dedicated worker that hasn't started yet.
void CancelCreateDedicatedWorker(int sender_id, int sender_route_id);
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index cd7c9ed..c81b650 100755
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -3324,8 +3324,8 @@
'renderer/webplugin_delegate_proxy.h',
'renderer/webplugin_delegate_pepper.cc',
'renderer/webplugin_delegate_pepper.h',
- 'renderer/websharedworker_proxy.cc',
- 'renderer/websharedworker_proxy.h',
+ 'renderer/websharedworker_impl.cc',
+ 'renderer/websharedworker_impl.h',
'renderer/websharedworkerrepository_impl.cc',
'renderer/websharedworkerrepository_impl.h',
'renderer/webworker_base.cc',
@@ -3414,12 +3414,6 @@
'worker/nativewebworker_impl.h',
'worker/nativewebworker_stub.cc',
'worker/nativewebworker_stub.h',
- 'worker/websharedworker_stub.cc',
- 'worker/websharedworker_stub.h',
- 'worker/webworker_stub_base.cc',
- 'worker/webworker_stub_base.h',
- 'worker/webworker_stub.cc',
- 'worker/webworker_stub.h',
'worker/webworkerclient_proxy.cc',
'worker/webworkerclient_proxy.h',
'worker/worker_main.cc',
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index c7a050c..38694f3 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1712,9 +1712,17 @@ IPC_BEGIN_MESSAGES(ViewHost)
// A renderer sends this to the browser process when it wants to create a
// worker. The browser will create the worker process if necessary, and
// will return the route id on success. On error returns MSG_ROUTING_NONE.
- IPC_SYNC_MESSAGE_CONTROL4_1(ViewHostMsg_CreateWorker,
+ IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_CreateDedicatedWorker,
+ GURL /* url */,
+ int /* render_view_route_id */,
+ int /* route_id */)
+
+ // A renderer sends this to the browser process when it wants to create a
+ // shared worker. The browser will create the worker process if necessary,
+ // and will return the route id on success. On error returns
+ // MSG_ROUTING_NONE.
+ IPC_SYNC_MESSAGE_CONTROL3_1(ViewHostMsg_CreateSharedWorker,
GURL /* url */,
- bool /* is_shared */,
string16 /* name */,
int /* render_view_route_id */,
int /* route_id */)
diff --git a/chrome/common/worker_messages_internal.h b/chrome/common/worker_messages_internal.h
index 04c983c..6ed4d09 100644
--- a/chrome/common/worker_messages_internal.h
+++ b/chrome/common/worker_messages_internal.h
@@ -13,10 +13,8 @@
// WorkerProcess messages
// These are messages sent from the browser to the worker process.
IPC_BEGIN_MESSAGES(WorkerProcess)
- IPC_MESSAGE_CONTROL4(WorkerProcessMsg_CreateWorker,
+ IPC_MESSAGE_CONTROL2(WorkerProcessMsg_CreateWorker,
GURL /* url */,
- bool /* is_shared */,
- string16 /* name */,
int /* route_id */)
// Note: these Message Port related messages can also be sent to the
diff --git a/chrome/renderer/websharedworker_proxy.cc b/chrome/renderer/websharedworker_impl.cc
index ee08901..f5e20ce 100644
--- a/chrome/renderer/websharedworker_proxy.cc
+++ b/chrome/renderer/websharedworker_impl.cc
@@ -2,32 +2,38 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/renderer/websharedworker_proxy.h"
+#include "chrome/renderer/websharedworker_impl.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"
-WebSharedWorkerProxy::WebSharedWorkerProxy(ChildThread* child_thread,
+WebSharedWorkerImpl::WebSharedWorkerImpl(const GURL& url,
+ const string16& name,
+ ChildThread* child_thread,
int route_id,
int render_view_route_id)
- : WebWorkerBase(child_thread, route_id, render_view_route_id) {
+ : WebWorkerBase(child_thread, route_id, render_view_route_id),
+ url_(url),
+ name_(name) {
}
-bool WebSharedWorkerProxy::isStarted() {
+bool WebSharedWorkerImpl::isStarted() {
return IsStarted();
}
-void WebSharedWorkerProxy::startWorkerContext(
+void WebSharedWorkerImpl::startWorkerContext(
const WebKit::WebURL& script_url,
- const WebKit::WebString& name,
const WebKit::WebString& user_agent,
const WebKit::WebString& source_code) {
- CreateWorkerContext(script_url, true, name, user_agent, source_code);
+ DCHECK(url_ == script_url);
+ IPC::Message* create_message = new ViewHostMsg_CreateSharedWorker(
+ url_, name_, render_view_route_id_, &route_id_);
+ CreateWorkerContext(create_message, script_url, user_agent, source_code);
}
-void WebSharedWorkerProxy::connect(WebKit::WebMessagePortChannel* channel) {
+void WebSharedWorkerImpl::connect(WebKit::WebMessagePortChannel* channel) {
WebMessagePortChannelImpl* webchannel =
static_cast<WebMessagePortChannelImpl*>(channel);
@@ -38,13 +44,13 @@ void WebSharedWorkerProxy::connect(WebKit::WebMessagePortChannel* channel) {
Send(new WorkerMsg_Connect(route_id_, message_port_id, MSG_ROUTING_NONE));
}
-void WebSharedWorkerProxy::OnMessageReceived(const IPC::Message& message) {
- IPC_BEGIN_MESSAGE_MAP(WebSharedWorkerProxy, message)
+void WebSharedWorkerImpl::OnMessageReceived(const IPC::Message& message) {
+ IPC_BEGIN_MESSAGE_MAP(WebSharedWorkerImpl, message)
IPC_MESSAGE_HANDLER(ViewMsg_WorkerCreated, OnWorkerCreated)
IPC_END_MESSAGE_MAP()
}
-void WebSharedWorkerProxy::OnWorkerCreated() {
+void WebSharedWorkerImpl::OnWorkerCreated() {
// The worker is created - now send off the CreateWorkerContext message and
// any other queued messages
SendQueuedMessages();
diff --git a/chrome/renderer/websharedworker_proxy.h b/chrome/renderer/websharedworker_impl.h
index 8ffe63c..14d122d89 100644
--- a/chrome/renderer/websharedworker_proxy.h
+++ b/chrome/renderer/websharedworker_impl.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_RENDERER_WEBSHAREDWORKER_PROXY_H_
-#define CHROME_RENDERER_WEBSHAREDWORKER_PROXY_H_
+#ifndef CHROME_RENDERER_WEBSHAREDWORKER_IMPL_H_
+#define CHROME_RENDERER_WEBSHAREDWORKER_IMPL_H_
#include "base/basictypes.h"
#include "chrome/renderer/webworker_base.h"
@@ -17,10 +17,12 @@ class ChildThread;
// thread. Once the connect event has been sent, all future communication will
// happen via the WebMessagePortChannel, and the WebSharedWorker instance will
// be freed.
-class WebSharedWorkerProxy : public WebKit::WebSharedWorker,
- private WebWorkerBase {
+class WebSharedWorkerImpl : public WebKit::WebSharedWorker,
+ private WebWorkerBase {
public:
- WebSharedWorkerProxy(ChildThread* child_thread,
+ WebSharedWorkerImpl(const GURL& url,
+ const string16& name,
+ ChildThread* child_thread,
int route_id,
int render_view_route_id);
@@ -28,17 +30,20 @@ class WebSharedWorkerProxy : public WebKit::WebSharedWorker,
virtual bool isStarted();
virtual void connect(WebKit::WebMessagePortChannel* channel);
virtual void startWorkerContext(const WebKit::WebURL& script_url,
- const WebKit::WebString& name,
const WebKit::WebString& user_agent,
const WebKit::WebString& source_code);
- // IPC::Channel::Listener proxyementation.
+ // IPC::Channel::Listener implementation.
void OnMessageReceived(const IPC::Message& message);
private:
void OnWorkerCreated();
- DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerProxy);
+ // The name and URL that uniquely identify this worker.
+ GURL url_;
+ string16 name_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerImpl);
};
-#endif // CHROME_RENDERER_WEBSHAREDWORKER_PROXY_H_
+#endif // CHROME_RENDERER_WEBSHAREDWORKER_IMPL_H_
diff --git a/chrome/renderer/webworker_base.cc b/chrome/renderer/webworker_base.cc
index 1364e7a..98365cd 100644
--- a/chrome/renderer/webworker_base.cc
+++ b/chrome/renderer/webworker_base.cc
@@ -48,14 +48,12 @@ void WebWorkerBase::Disconnect() {
route_id_ = MSG_ROUTING_NONE;
}
-void WebWorkerBase::CreateWorkerContext(const GURL& script_url,
- bool is_shared,
- const string16& name,
+void WebWorkerBase::CreateWorkerContext(IPC::Message* create_message,
+ const GURL& script_url,
const string16& user_agent,
const string16& source_code) {
DCHECK(route_id_ == MSG_ROUTING_NONE);
- IPC::Message* create_message = new ViewHostMsg_CreateWorker(
- script_url, is_shared, name, render_view_route_id_, &route_id_);
+ // create_message is a sync message that sets route_id_
child_thread_->Send(create_message);
if (route_id_ == MSG_ROUTING_NONE)
return;
diff --git a/chrome/renderer/webworker_base.h b/chrome/renderer/webworker_base.h
index 12ee84a..c7c6c62 100644
--- a/chrome/renderer/webworker_base.h
+++ b/chrome/renderer/webworker_base.h
@@ -26,9 +26,8 @@ class WebWorkerBase : public IPC::Channel::Listener {
virtual ~WebWorkerBase();
// Creates and initializes a new worker context.
- void CreateWorkerContext(const GURL& script_url,
- bool is_shared,
- const string16& name,
+ void CreateWorkerContext(IPC::Message* create_message,
+ const GURL& script_url,
const string16& user_agent,
const string16& source_code);
diff --git a/chrome/renderer/webworker_proxy.cc b/chrome/renderer/webworker_proxy.cc
index e8a5b9d..5a24c41 100644
--- a/chrome/renderer/webworker_proxy.cc
+++ b/chrome/renderer/webworker_proxy.cc
@@ -11,7 +11,6 @@
#include "webkit/api/public/WebURL.h"
#include "webkit/api/public/WebWorkerClient.h"
-using WebKit::WebCommonWorkerClient;
using WebKit::WebMessagePortChannel;
using WebKit::WebMessagePortChannelArray;
using WebKit::WebString;
@@ -42,7 +41,9 @@ void WebWorkerProxy::startWorkerContext(
const WebURL& script_url,
const WebString& user_agent,
const WebString& source_code) {
- CreateWorkerContext(script_url, false, string16(), user_agent, source_code);
+ IPC::Message* create_message = new ViewHostMsg_CreateDedicatedWorker(
+ script_url, render_view_route_id_, &route_id_);
+ CreateWorkerContext(create_message, script_url, user_agent, source_code);
}
void WebWorkerProxy::terminateWorkerContext() {
@@ -96,8 +97,8 @@ void WebWorkerProxy::OnMessageReceived(const IPC::Message& message) {
client_,
WebWorkerClient::reportPendingActivity)
IPC_MESSAGE_FORWARD(WorkerHostMsg_WorkerContextDestroyed,
- static_cast<WebCommonWorkerClient*>(client_),
- WebCommonWorkerClient::workerContextDestroyed)
+ client_,
+ WebWorkerClient::workerContextDestroyed)
IPC_END_MESSAGE_MAP()
}
diff --git a/chrome/renderer/webworker_proxy.h b/chrome/renderer/webworker_proxy.h
index 48487c0..686669a 100644
--- a/chrome/renderer/webworker_proxy.h
+++ b/chrome/renderer/webworker_proxy.h
@@ -46,7 +46,6 @@ class WebWorkerProxy : public WebKit::WebWorker, private WebWorkerBase {
virtual void Disconnect();
void OnWorkerCreated();
- void OnWorkerContextDestroyed();
void OnPostMessage(const string16& message,
const std::vector<int>& sent_message_port_ids,
const std::vector<int>& new_routing_ids);
diff --git a/chrome/worker/websharedworker_stub.cc b/chrome/worker/websharedworker_stub.cc
deleted file mode 100644
index 902f393..0000000
--- a/chrome/worker/websharedworker_stub.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/worker/websharedworker_stub.h"
-
-#include "chrome/common/webmessageportchannel_impl.h"
-#include "chrome/common/worker_messages.h"
-#include "webkit/api/public/WebSharedWorker.h"
-#include "webkit/api/public/WebString.h"
-#include "webkit/api/public/WebURL.h"
-
-WebSharedWorkerStub::WebSharedWorkerStub(
- const string16& name, int route_id)
- : WebWorkerStubBase(route_id),
- name_(name) {
-
- // TODO(atwilson): Add support for NaCl when they support MessagePorts.
- impl_ = WebKit::WebSharedWorker::create(client());
-
-}
-
-WebSharedWorkerStub::~WebSharedWorkerStub() {
- impl_->clientDestroyed();
-}
-
-void WebSharedWorkerStub::OnMessageReceived(const IPC::Message& message) {
- IPC_BEGIN_MESSAGE_MAP(WebSharedWorkerStub, message)
- IPC_MESSAGE_HANDLER(WorkerMsg_StartWorkerContext, OnStartWorkerContext)
- IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext,
- OnTerminateWorkerContext)
- IPC_MESSAGE_HANDLER(WorkerMsg_Connect, OnConnect)
- IPC_END_MESSAGE_MAP()
-}
-
-void WebSharedWorkerStub::OnStartWorkerContext(
- const GURL& url, const string16& user_agent, const string16& source_code) {
- impl_->startWorkerContext(url, name_, user_agent, source_code);
-}
-
-void WebSharedWorkerStub::OnConnect(int sent_message_port_id, int routing_id) {
- WebKit::WebMessagePortChannel* channel =
- new WebMessagePortChannelImpl(routing_id, sent_message_port_id);
- impl_->connect(channel);
-}
-
-void WebSharedWorkerStub::OnTerminateWorkerContext() {
- impl_->terminateWorkerContext();
-
- // Call the client to make sure context exits.
- EnsureWorkerContextTerminates();
-}
diff --git a/chrome/worker/websharedworker_stub.h b/chrome/worker/websharedworker_stub.h
deleted file mode 100644
index f7a26f3..0000000
--- a/chrome/worker/websharedworker_stub.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_WORKER_WEB_SHARED_WORKER_STUB_H_
-#define CHROME_WORKER_WEB_SHARED_WORKER_STUB_H_
-
-#include "chrome/worker/webworker_stub_base.h"
-#include "chrome/worker/webworkerclient_proxy.h"
-#include "googleurl/src/gurl.h"
-
-namespace WebKit {
-class WebSharedWorker;
-}
-
-// This class creates a WebSharedWorker, and translates incoming IPCs to the
-// appropriate WebSharedWorker APIs.
-class WebSharedWorkerStub : public WebWorkerStubBase {
- public:
- WebSharedWorkerStub(const string16& name, int route_id);
-
- // IPC::Channel::Listener implementation.
- virtual void OnMessageReceived(const IPC::Message& message);
-
- private:
- virtual ~WebSharedWorkerStub();
-
- // Invoked when the WebWorkerClientProxy is shutting down.
- void OnConnect(int sent_message_port_id, int routing_id);
- void OnStartWorkerContext(
- const GURL& url, const string16& user_agent, const string16& source_code);
- void OnTerminateWorkerContext();
-
- WebKit::WebSharedWorker* impl_;
- string16 name_;
-
- DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerStub);
-};
-
-#endif // CHROME_WORKER_WEB_SHARED_WORKER_STUB_H_
diff --git a/chrome/worker/webworker_stub.cc b/chrome/worker/webworker_stub.cc
deleted file mode 100644
index 37be7ab..0000000
--- a/chrome/worker/webworker_stub.cc
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/worker/webworker_stub.h"
-
-#include "base/command_line.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/webmessageportchannel_impl.h"
-#include "chrome/common/worker_messages.h"
-#include "chrome/worker/nativewebworker_impl.h"
-#include "webkit/api/public/WebString.h"
-#include "webkit/api/public/WebURL.h"
-#include "webkit/api/public/WebWorker.h"
-
-using WebKit::WebWorker;
-
-static bool UrlIsNativeWorker(const GURL& url) {
- // If the renderer was not passed the switch to enable native workers,
- // then the URL should be treated as a JavaScript worker.
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kEnableNativeWebWorkers)) {
- return false;
- }
- // Based on the suffix, decide whether the url should be considered
- // a NativeWebWorker (for .nexe) or a WebWorker (for anything else).
- const std::string kNativeSuffix(".nexe");
- std::string worker_url = url.path();
- // Compute the start index of the suffix.
- std::string::size_type suffix_index =
- worker_url.length() - kNativeSuffix.length();
- std::string::size_type pos = worker_url.find(kNativeSuffix, suffix_index);
- return (suffix_index == pos);
-}
-
-WebWorkerStub::WebWorkerStub(const GURL& url, int route_id)
- : WebWorkerStubBase(route_id) {
- if (UrlIsNativeWorker(url)) {
- // Launch a native worker.
- impl_ = NativeWebWorkerImpl::create(client());
- } else {
- // Launch a JavaScript worker.
- impl_ = WebKit::WebWorker::create(client());
- }
-}
-
-WebWorkerStub::~WebWorkerStub() {
- impl_->clientDestroyed();
-}
-
-void WebWorkerStub::OnMessageReceived(const IPC::Message& message) {
- if (!impl_)
- return;
-
- IPC_BEGIN_MESSAGE_MAP(WebWorkerStub, message)
- IPC_MESSAGE_FORWARD(WorkerMsg_StartWorkerContext, impl_,
- WebWorker::startWorkerContext)
- IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext,
- OnTerminateWorkerContext)
- IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage)
- IPC_MESSAGE_FORWARD(WorkerMsg_WorkerObjectDestroyed, impl_,
- WebWorker::workerObjectDestroyed)
- IPC_END_MESSAGE_MAP()
-}
-
-void WebWorkerStub::OnTerminateWorkerContext() {
- impl_->terminateWorkerContext();
-
- // Call the client to make sure context exits.
- EnsureWorkerContextTerminates();
-}
-
-void WebWorkerStub::OnPostMessage(
- const string16& message,
- const std::vector<int>& sent_message_port_ids,
- const std::vector<int>& new_routing_ids) {
- WebKit::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, channels);
-}
diff --git a/chrome/worker/webworker_stub.h b/chrome/worker/webworker_stub.h
deleted file mode 100644
index d83a4b7..0000000
--- a/chrome/worker/webworker_stub.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_WORKER_WEB_WORKER_STUB_H_
-#define CHROME_WORKER_WEB_WORKER_STUB_H_
-
-#include "chrome/worker/webworker_stub_base.h"
-#include "chrome/worker/webworkerclient_proxy.h"
-#include "googleurl/src/gurl.h"
-
-namespace WebKit {
-class WebWorker;
-}
-
-// This class creates a WebWorker, and translates incoming IPCs to the
-// appropriate WebWorker APIs.
-class WebWorkerStub : public WebWorkerStubBase {
- public:
- WebWorkerStub(const GURL& url, int route_id);
-
- // IPC::Channel::Listener implementation.
- virtual void OnMessageReceived(const IPC::Message& message);
-
- private:
- virtual ~WebWorkerStub();
-
- void OnTerminateWorkerContext();
- void OnPostMessage(const string16& message,
- const std::vector<int>& sent_message_port_ids,
- const std::vector<int>& new_routing_ids);
-
- WebKit::WebWorker* impl_;
-
- DISALLOW_COPY_AND_ASSIGN(WebWorkerStub);
-};
-
-#endif // CHROME_WORKER_WEB_WORKER_STUB_H_
diff --git a/chrome/worker/webworker_stub_base.cc b/chrome/worker/webworker_stub_base.cc
deleted file mode 100644
index 8ea2a15..0000000
--- a/chrome/worker/webworker_stub_base.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/worker/webworker_stub_base.h"
-
-#include "base/compiler_specific.h"
-#include "chrome/common/child_process.h"
-#include "chrome/worker/worker_thread.h"
-
-WebWorkerStubBase::WebWorkerStubBase(int route_id)
- : route_id_(route_id),
- ALLOW_THIS_IN_INITIALIZER_LIST(client_(route_id, this)) {
-
- // Start processing incoming IPCs for this worker.
- WorkerThread::current()->AddRoute(route_id_, this);
- ChildProcess::current()->AddRefProcess();
-}
-
-WebWorkerStubBase::~WebWorkerStubBase() {
- WorkerThread::current()->RemoveRoute(route_id_);
- ChildProcess::current()->ReleaseProcess();
-}
-
-void WebWorkerStubBase::Shutdown() {
- // The worker has exited - free ourselves and the client.
- delete this;
-}
-
-void WebWorkerStubBase::EnsureWorkerContextTerminates() {
- client_.EnsureWorkerContextTerminates();
-}
diff --git a/chrome/worker/webworker_stub_base.h b/chrome/worker/webworker_stub_base.h
deleted file mode 100644
index 1e5ec12..0000000
--- a/chrome/worker/webworker_stub_base.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_WORKER_WEB_WORKER_STUB_BASE_H_
-#define CHROME_WORKER_WEB_WORKER_STUB_BASE_H_
-
-#include "chrome/worker/webworkerclient_proxy.h"
-#include "ipc/ipc_channel.h"
-
-// This class is the common base class for both WebWorkerStub and
-// WebSharedWorkerStub and contains common setup/teardown functionality.
-class WebWorkerStubBase : public IPC::Channel::Listener {
- public:
- WebWorkerStubBase(int route_id);
- virtual ~WebWorkerStubBase();
-
- // Invoked when the WebWorkerClientProxy is shutting down.
- void Shutdown();
-
- // Called after terminating the worker context to make sure that the worker
- // actually terminates (is not stuck in an infinite loop).
- void EnsureWorkerContextTerminates();
-
- WebWorkerClientProxy* client() { return &client_; }
-
- private:
- int route_id_;
-
- // WebWorkerClient that responds to outgoing API calls from the worker object.
- WebWorkerClientProxy client_;
-
- DISALLOW_COPY_AND_ASSIGN(WebWorkerStubBase);
-};
-
-#endif // CHROME_WORKER_WEB_WORKER_STUB_BASE_H_
diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc
index baff23c..9fe0870 100644
--- a/chrome/worker/webworkerclient_proxy.cc
+++ b/chrome/worker/webworkerclient_proxy.cc
@@ -5,12 +5,13 @@
#include "chrome/worker/webworkerclient_proxy.h"
#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/webworker_stub_base.h"
#include "chrome/worker/worker_thread.h"
+#include "chrome/worker/nativewebworker_impl.h"
#include "ipc/ipc_logging.h"
#include "webkit/api/public/WebString.h"
#include "webkit/api/public/WebURL.h"
@@ -25,14 +26,43 @@ using WebKit::WebWorkerClient;
// How long to wait for worker to finish after it's been told to terminate.
#define kMaxTimeForRunawayWorkerMs 3000
-WebWorkerClientProxy::WebWorkerClientProxy(int route_id,
- WebWorkerStubBase* stub)
- : route_id_(route_id),
- stub_(stub),
+static bool UrlIsNativeWorker(const GURL& url) {
+ // If the renderer was not passed the switch to enable native workers,
+ // then the URL should be treated as a JavaScript worker.
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableNativeWebWorkers)) {
+ return false;
+ }
+ // Based on the suffix, decide whether the url should be considered
+ // a NativeWebWorker (for .nexe) or a WebWorker (for anything else).
+ const std::string kNativeSuffix(".nexe");
+ std::string worker_url = url.path();
+ // Compute the start index of the suffix.
+ std::string::size_type suffix_index =
+ worker_url.length() - kNativeSuffix.length();
+ std::string::size_type pos = worker_url.find(kNativeSuffix, suffix_index);
+ return (suffix_index == pos);
+}
+
+WebWorkerClientProxy::WebWorkerClientProxy(const GURL& url, int route_id)
+ : url_(url),
+ route_id_(route_id),
ALLOW_THIS_IN_INITIALIZER_LIST(kill_process_factory_(this)) {
+ if (UrlIsNativeWorker(url)) {
+ // Launch a native worker.
+ impl_ = NativeWebWorkerImpl::create(this);
+ } else {
+ // Launch a JavaScript worker.
+ impl_ = WebWorker::create(this);
+ }
+ WorkerThread::current()->AddRoute(route_id_, this);
+ ChildProcess::current()->AddRefProcess();
}
WebWorkerClientProxy::~WebWorkerClientProxy() {
+ impl_->clientDestroyed();
+ WorkerThread::current()->RemoveRoute(route_id_);
+ ChildProcess::current()->ReleaseProcess();
}
void WebWorkerClientProxy::postMessageToWorkerObject(
@@ -93,9 +123,8 @@ void WebWorkerClientProxy::reportPendingActivity(bool has_pending_activity) {
void WebWorkerClientProxy::workerContextDestroyed() {
Send(new WorkerHostMsg_WorkerContextDestroyed(route_id_));
- // Tell the stub that the worker has shutdown - frees this object.
- if (stub_)
- stub_->Shutdown();
+
+ delete this;
}
WebKit::WebWorker* WebWorkerClientProxy::createWorker(
@@ -107,7 +136,24 @@ bool WebWorkerClientProxy::Send(IPC::Message* message) {
return WorkerThread::current()->Send(message);
}
-void WebWorkerClientProxy::EnsureWorkerContextTerminates() {
+void WebWorkerClientProxy::OnMessageReceived(const IPC::Message& message) {
+ if (!impl_)
+ return;
+
+ IPC_BEGIN_MESSAGE_MAP(WebWorkerClientProxy, message)
+ IPC_MESSAGE_FORWARD(WorkerMsg_StartWorkerContext, impl_,
+ WebWorker::startWorkerContext)
+ IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext,
+ OnTerminateWorkerContext)
+ IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage)
+ IPC_MESSAGE_FORWARD(WorkerMsg_WorkerObjectDestroyed, impl_,
+ WebWorker::workerObjectDestroyed)
+ IPC_END_MESSAGE_MAP()
+}
+
+void WebWorkerClientProxy::OnTerminateWorkerContext() {
+ impl_->terminateWorkerContext();
+
// Avoid a worker doing a while(1) from never exiting.
if (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kWebWorkerShareProcesses)) {
@@ -126,3 +172,15 @@ void WebWorkerClientProxy::EnsureWorkerContextTerminates() {
kMaxTimeForRunawayWorkerMs);
}
+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, channels);
+}
diff --git a/chrome/worker/webworkerclient_proxy.h b/chrome/worker/webworkerclient_proxy.h
index b422912..456ecb0 100644
--- a/chrome/worker/webworkerclient_proxy.h
+++ b/chrome/worker/webworkerclient_proxy.h
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/task.h"
+#include "googleurl/src/gurl.h"
#include "ipc/ipc_channel.h"
#include "webkit/api/public/WebWorkerClient.h"
@@ -16,17 +17,15 @@ namespace WebKit {
class WebWorker;
}
-class WebWorkerStubBase;
-
// This class receives IPCs from the renderer and calls the WebCore::Worker
// implementation (after the data types have been converted by glue code). It
// is also called by the worker code and converts these function calls into
// IPCs that are sent to the renderer, where they're converted back to function
// calls by WebWorkerProxy.
-class WebWorkerClientProxy : public WebKit::WebWorkerClient {
+class WebWorkerClientProxy : public WebKit::WebWorkerClient,
+ public IPC::Channel::Listener {
public:
- WebWorkerClientProxy(int route_id, WebWorkerStubBase* stub);
- ~WebWorkerClientProxy();
+ WebWorkerClientProxy(const GURL& url, int route_id);
// WebWorkerClient implementation.
virtual void postMessageToWorkerObject(
@@ -56,13 +55,26 @@ class WebWorkerClientProxy : public WebKit::WebWorkerClient {
return NULL;
}
- void EnsureWorkerContextTerminates();
+ // IPC::Channel::Listener implementation.
+ virtual void OnMessageReceived(const IPC::Message& message);
private:
+ ~WebWorkerClientProxy();
+
bool Send(IPC::Message* message);
+ void OnTerminateWorkerContext();
+ void OnPostMessage(const string16& message,
+ const std::vector<int>& sent_message_port_ids,
+ const std::vector<int>& new_routing_ids);
+
+ // The source url for this worker.
+ GURL url_;
+
int route_id_;
- WebWorkerStubBase* stub_;
+
+ WebKit::WebWorker* impl_;
+
ScopedRunnableMethodFactory<WebWorkerClientProxy> kill_process_factory_;
DISALLOW_COPY_AND_ASSIGN(WebWorkerClientProxy);
diff --git a/chrome/worker/worker_thread.cc b/chrome/worker/worker_thread.cc
index 8ffc92b..e4be0b9 100644
--- a/chrome/worker/worker_thread.cc
+++ b/chrome/worker/worker_thread.cc
@@ -7,8 +7,7 @@
#include "base/lazy_instance.h"
#include "base/thread_local.h"
#include "chrome/common/worker_messages.h"
-#include "chrome/worker/webworker_stub.h"
-#include "chrome/worker/websharedworker_stub.h"
+#include "chrome/worker/webworkerclient_proxy.h"
#include "chrome/worker/worker_webkitclient_impl.h"
#include "webkit/api/public/WebKit.h"
@@ -38,13 +37,7 @@ void WorkerThread::OnControlMessageReceived(const IPC::Message& msg) {
IPC_END_MESSAGE_MAP()
}
-void WorkerThread::OnCreateWorker(const GURL& url,
- bool is_shared,
- const string16& name,
- int route_id) {
- // WebWorkerStub and WebSharedWorkerStub own themselves.
- if (is_shared)
- new WebSharedWorkerStub(name, route_id);
- else
- new WebWorkerStub(url, route_id);
+void WorkerThread::OnCreateWorker(const GURL& url, int route_id) {
+ // WebWorkerClientProxy owns itself.
+ new WebWorkerClientProxy(url, route_id);
}
diff --git a/chrome/worker/worker_thread.h b/chrome/worker/worker_thread.h
index 040f0db..27d0abf 100644
--- a/chrome/worker/worker_thread.h
+++ b/chrome/worker/worker_thread.h
@@ -21,8 +21,7 @@ class WorkerThread : public ChildThread {
private:
virtual void OnControlMessageReceived(const IPC::Message& msg);
- void OnCreateWorker(
- const GURL& url, bool is_shared, const string16& name, int route_id);
+ void OnCreateWorker(const GURL& url, int route_id);
scoped_ptr<WorkerWebKitClientImpl> webkit_client_;