summaryrefslogtreecommitdiffstats
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
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
-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
-rw-r--r--webkit/api/WebKit.gyp5
-rw-r--r--webkit/api/public/WebCommonWorkerClient.h77
-rw-r--r--webkit/api/public/WebSharedWorker.h15
-rw-r--r--webkit/api/public/WebWorkerClient.h25
-rw-r--r--webkit/api/src/SharedWorkerRepository.cpp24
-rw-r--r--webkit/api/src/WebSharedWorkerImpl.cpp49
-rw-r--r--webkit/api/src/WebSharedWorkerImpl.h78
32 files changed, 214 insertions, 645 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_;
diff --git a/webkit/api/WebKit.gyp b/webkit/api/WebKit.gyp
index 1efd323..49c8966 100644
--- a/webkit/api/WebKit.gyp
+++ b/webkit/api/WebKit.gyp
@@ -76,7 +76,6 @@
'public/WebColor.h',
'public/WebColorName.h',
'public/WebCommon.h',
- 'public/WebCommonWorkerClient.h',
'public/WebCompositionCommand.h',
'public/WebConsoleMessage.h',
'public/WebContextMenuData.h',
@@ -135,8 +134,6 @@
'public/WebSecurityOrigin.h',
'public/WebSecurityPolicy.h',
'public/WebSettings.h',
- 'public/WebSharedWorker.h'
- 'public/WebSharedWorkerRepository.h',
'public/WebSize.h',
'public/WebSocketStreamError.h',
'public/WebSocketStreamHandle.h',
@@ -262,8 +259,6 @@
'src/WebSecurityPolicy.cpp',
'src/WebSettingsImpl.cpp',
'src/WebSettingsImpl.h',
- 'src/WebSharedWorkerImpl.cpp',
- 'src/WebSharedWorkerImpl.h',
'src/WebStorageAreaImpl.cpp',
'src/WebStorageAreaImpl.h',
'src/WebStorageEventDispatcherImpl.cpp',
diff --git a/webkit/api/public/WebCommonWorkerClient.h b/webkit/api/public/WebCommonWorkerClient.h
deleted file mode 100644
index fd7e399..0000000
--- a/webkit/api/public/WebCommonWorkerClient.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef WebCommonWorkerClient_h
-#define WebCommonWorkerClient_h
-
-namespace WebKit {
- class WebNotificationPresenter;
- class WebString;
- class WebWorker;
- class WebWorkerClient;
-
- // Provides an interface back to the in-page script object for a worker.
- // This interface contains common APIs used by both shared and dedicated
- // workers.
- // All functions are expected to be called back on the thread that created
- // the Worker object, unless noted.
- class WebCommonWorkerClient {
- public:
- virtual void postExceptionToWorkerObject(
- const WebString& errorString, int lineNumber,
- const WebString& sourceURL) = 0;
-
- virtual void postConsoleMessageToWorkerObject(
- int destinationIdentifier,
- int sourceIdentifier,
- int messageType,
- int messageLevel,
- const WebString& message,
- int lineNumber,
- const WebString& sourceURL) = 0;
-
- virtual void workerContextDestroyed() = 0;
-
- // Returns the notification presenter for this worker context. Pointer
- // is owned by the object implementing WebCommonWorkerClient.
- virtual WebNotificationPresenter* notificationPresenter() = 0;
-
- // This can be called on any thread to create a nested WebWorker.
- // WebSharedWorkers are not instantiated via this API - instead
- // they are created via the WebSharedWorkerRepository.
- virtual WebWorker* createWorker(WebWorkerClient* client) = 0;
-
- protected:
- ~WebCommonWorkerClient() { }
- };
-
-} // namespace WebKit
-
-#endif
diff --git a/webkit/api/public/WebSharedWorker.h b/webkit/api/public/WebSharedWorker.h
index a580882..37f0ad6 100644
--- a/webkit/api/public/WebSharedWorker.h
+++ b/webkit/api/public/WebSharedWorker.h
@@ -37,35 +37,24 @@ namespace WebKit {
class ScriptExecutionContext;
class WebString;
class WebMessagePortChannel;
- class WebCommonWorkerClient;
class WebURL;
// This is the interface to a SharedWorker thread.
// Since SharedWorkers communicate entirely through MessagePorts this interface only contains APIs for starting up a SharedWorker.
class WebSharedWorker {
public:
- // Invoked from the worker thread to instantiate a WebSharedWorker that interacts with the WebKit worker components.
- WEBKIT_API static WebSharedWorker* create(WebCommonWorkerClient*);
-
- virtual ~WebSharedWorker() {};
+ virtual ~WebSharedWorker() {}
// Returns false if the thread hasn't been started yet (script loading has not taken place).
// FIXME(atwilson): Remove this when we move the initial script loading into the worker process.
virtual bool isStarted() = 0;
virtual void startWorkerContext(const WebURL& scriptURL,
- const WebString& name,
const WebString& userAgent,
const WebString& sourceCode) = 0;
- // Sends a connect event to the SharedWorker context.
+ // Sends a connect event to the SharedWorker thread.
virtual void connect(WebMessagePortChannel*) = 0;
-
- // Invoked to shutdown the worker when there are no more associated documents.
- virtual void terminateWorkerContext() = 0;
-
- // Notification when the WebCommonWorkerClient is destroyed.
- virtual void clientDestroyed() = 0;
};
} // namespace WebKit
diff --git a/webkit/api/public/WebWorkerClient.h b/webkit/api/public/WebWorkerClient.h
index 044ba52..c0aa1bd 100644
--- a/webkit/api/public/WebWorkerClient.h
+++ b/webkit/api/public/WebWorkerClient.h
@@ -32,7 +32,6 @@
#define WebWorkerClient_h
#include "WebMessagePortChannel.h"
-#include "WebCommonWorkerClient.h"
namespace WebKit {
class WebNotificationPresenter;
@@ -42,15 +41,37 @@ namespace WebKit {
// Provides an interface back to the in-page script object for a worker.
// All functions are expected to be called back on the thread that created
// the Worker object, unless noted.
- class WebWorkerClient : public WebCommonWorkerClient {
+ class WebWorkerClient {
public:
virtual void postMessageToWorkerObject(
const WebString&,
const WebMessagePortChannelArray&) = 0;
+ virtual void postExceptionToWorkerObject(
+ const WebString& errorString, int lineNumber,
+ const WebString& sourceURL) = 0;
+
+ virtual void postConsoleMessageToWorkerObject(
+ int destinationIdentifier,
+ int sourceIdentifier,
+ int messageType,
+ int messageLevel,
+ const WebString& message,
+ int lineNumber,
+ const WebString& sourceURL) = 0;
+
virtual void confirmMessageFromWorkerObject(bool hasPendingActivity) = 0;
virtual void reportPendingActivity(bool hasPendingActivity) = 0;
+ virtual void workerContextDestroyed() = 0;
+
+ // Returns the notification presenter for this worker context. Pointer
+ // is owned by the object implementing WebWorkerClient.
+ virtual WebNotificationPresenter* notificationPresenter() = 0;
+
+ // This can be called on any thread to create a nested worker.
+ virtual WebWorker* createWorker(WebWorkerClient* client) = 0;
+
protected:
~WebWorkerClient() { }
};
diff --git a/webkit/api/src/SharedWorkerRepository.cpp b/webkit/api/src/SharedWorkerRepository.cpp
index 32e8fd7..ddc6238 100644
--- a/webkit/api/src/SharedWorkerRepository.cpp
+++ b/webkit/api/src/SharedWorkerRepository.cpp
@@ -60,32 +60,28 @@ using WebKit::WebSharedWorkerRepository;
// Callback class that keeps the Worker object alive while loads are potentially happening, and also translates load errors into error events on the worker.
class SharedWorkerScriptLoader : public RefCounted<SharedWorkerScriptLoader>, private WorkerScriptLoaderClient {
public:
- SharedWorkerScriptLoader(PassRefPtr<SharedWorker> worker, const KURL& url, const String& name, PassOwnPtr<MessagePortChannel> port, PassOwnPtr<WebSharedWorker> webWorker)
- : m_worker(worker),
- m_url(url),
- m_name(name),
- m_webWorker(webWorker),
- m_port(port)
+ SharedWorkerScriptLoader(PassRefPtr<SharedWorker> worker, PassOwnPtr<MessagePortChannel> port, PassOwnPtr<WebSharedWorker> webWorker)
+ : m_worker(worker)
+ , m_webWorker(webWorker)
+ , m_port(port)
{
}
- void load();
+ void load(const KURL&);
private:
// WorkerScriptLoaderClient callback
virtual void notifyFinished();
RefPtr<SharedWorker> m_worker;
- KURL m_url;
- String m_name;
OwnPtr<WebSharedWorker> m_webWorker;
OwnPtr<MessagePortChannel> m_port;
WorkerScriptLoader m_scriptLoader;
};
-void SharedWorkerScriptLoader::load()
+void SharedWorkerScriptLoader::load(const KURL& url)
{
- m_scriptLoader.loadAsynchronously(m_worker->scriptExecutionContext(), m_url, DenyCrossOriginRequests, this);
+ m_scriptLoader.loadAsynchronously(m_worker->scriptExecutionContext(), url, DenyCrossOriginRequests, this);
}
// Extracts a WebMessagePortChannel from a MessagePortChannel.
@@ -103,7 +99,7 @@ void SharedWorkerScriptLoader::notifyFinished()
if (m_scriptLoader.failed())
m_worker->dispatchEvent(Event::create(eventNames().errorEvent, false, true));
else {
- m_webWorker->startWorkerContext(m_url, m_name, m_worker->scriptExecutionContext()->userAgent(m_url), m_scriptLoader.script());
+ m_webWorker->startWorkerContext(m_scriptLoader.url(), m_worker->scriptExecutionContext()->userAgent(m_scriptLoader.url()), m_scriptLoader.script());
m_webWorker->connect(getWebPort(m_port.release()));
}
@@ -142,8 +138,8 @@ void SharedWorkerRepository::connect(PassRefPtr<SharedWorker> worker, PassOwnPtr
if (!webWorker->isStarted()) {
// Need to kick off a load for the worker. The loader will connect to the worker once the script has been loaded, then free itself.
- SharedWorkerScriptLoader* loader = new SharedWorkerScriptLoader(worker, url, name, port.release(), webWorker.release());
- loader->load();
+ SharedWorkerScriptLoader* loader = new SharedWorkerScriptLoader(worker, port.release(), webWorker.release());
+ loader->load(url);
} else
webWorker->connect(getWebPort(port.release()));
}
diff --git a/webkit/api/src/WebSharedWorkerImpl.cpp b/webkit/api/src/WebSharedWorkerImpl.cpp
deleted file mode 100644
index e5c9fc5..0000000
--- a/webkit/api/src/WebSharedWorkerImpl.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WebSharedWorkerImpl.h"
-
-using namespace WebCore;
-
-namespace WebKit {
-
-#if ENABLE(SHARED_WORKERS)
-
-WebSharedWorker* WebSharedWorker::create(WebCommonWorkerClient* client)
-{
- // FIXME: Return an instance of WebSharedWorkerImpl once the implementation is complete.
- ASSERT_NOT_REACHED();
- return NULL;
-}
-
-#endif // ENABLE(SHARED_WORKERS)
-
-} // namespace WebKit
diff --git a/webkit/api/src/WebSharedWorkerImpl.h b/webkit/api/src/WebSharedWorkerImpl.h
deleted file mode 100644
index fad0f5a..0000000
--- a/webkit/api/src/WebSharedWorkerImpl.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef WebSharedWorkerImpl_h
-#define WebSharedWorkerImpl_h
-
-#include "WebSharedWorker.h"
-
-#if ENABLE(SHARED_WORKERS)
-
-#include "ScriptExecutionContext.h"
-#include "WorkerLoaderProxy.h"
-#include "WorkerObjectProxy.h"
-#include <wtf/PassOwnPtr.h>
-#include <wtf/RefPtr.h>
-
-namespace WebCore {
-class SharedWorkerThread;
-}
-
-namespace WebKit {
-class WebView;
-
-// This class is used by the worker process code to talk to the WebCore::SharedWorker implementation.
-// It can't use it directly since it uses WebKit types, so this class converts the data types.
-// When the WebCore::SharedWorker object wants to call WebCore::WorkerReportingProxy, this class will
-// convert to Chrome data types first and then call the supplied WebCommonWorkerClient.
-class WebSharedWorkerImpl : public WebCore::WorkerLoaderProxy {
-public:
- explicit WebSharedWorkerImpl(WebCommonWorkerClient* client);
-
- // WebSharedWorker methods:
- virtual bool isStarted();
- virtual void startWorkerContext(const WebURL&, const WebString& name, const WebString& userAgent, const WebString& sourceCode);
- virtual void connect(WebMessagePortChannel*);
-
- WebCommonWorkerClient* client() { return m_client; }
-
-private:
- virtual ~WebSharedWorkerImpl();
-
- WebCommonWorkerClient* m_client;
-
- RefPtr<WebCore::SharedWorkerThread> m_workerThread;
-};
-
-} // namespace WebKit
-
-#endif // ENABLE(SHARED_WORKERS)
-
-#endif