diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 16:27:06 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-05 16:27:06 +0000 |
commit | 6898bbedb15bfddf91ea125e3ffde4b1789d9bf3 (patch) | |
tree | e3950c1d597f704af541572cfc39e9874131d667 /chrome/renderer | |
parent | 1bbe5f61a331b2fb3cd1c0e18cf3aefa7105e635 (diff) | |
download | chromium_src-6898bbedb15bfddf91ea125e3ffde4b1789d9bf3.zip chromium_src-6898bbedb15bfddf91ea125e3ffde4b1789d9bf3.tar.gz chromium_src-6898bbedb15bfddf91ea125e3ffde4b1789d9bf3.tar.bz2 |
Added beginnings of browser-process support for shared workers.
Refactored WebWorkerClientProxy into two classes - WebWorkerDispatcher which dispatches incoming IPCs for the worker, and WebWorkerClientProxy, which handles outgoing API calls from WebWorkerImpl. This allows WebWorkerClientProxy to be reused by WebSharedWorkerDispatcher.
BUG=26233
TEST=none (will enable layout tests when basic functionality available)
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=31077
Review URL: http://codereview.chromium.org/351004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31096 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/websharedworker_proxy.cc (renamed from chrome/renderer/websharedworker_impl.cc) | 28 | ||||
-rw-r--r-- | chrome/renderer/websharedworker_proxy.h (renamed from chrome/renderer/websharedworker_impl.h) | 23 | ||||
-rw-r--r-- | chrome/renderer/webworker_base.cc | 8 | ||||
-rw-r--r-- | chrome/renderer/webworker_base.h | 5 | ||||
-rw-r--r-- | chrome/renderer/webworker_proxy.cc | 9 | ||||
-rw-r--r-- | chrome/renderer/webworker_proxy.h | 1 |
6 files changed, 33 insertions, 41 deletions
diff --git a/chrome/renderer/websharedworker_impl.cc b/chrome/renderer/websharedworker_proxy.cc index f5e20ce..ee08901 100644 --- a/chrome/renderer/websharedworker_impl.cc +++ b/chrome/renderer/websharedworker_proxy.cc @@ -2,38 +2,32 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/renderer/websharedworker_impl.h" +#include "chrome/renderer/websharedworker_proxy.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" -WebSharedWorkerImpl::WebSharedWorkerImpl(const GURL& url, - const string16& name, - ChildThread* child_thread, +WebSharedWorkerProxy::WebSharedWorkerProxy(ChildThread* child_thread, int route_id, int render_view_route_id) - : WebWorkerBase(child_thread, route_id, render_view_route_id), - url_(url), - name_(name) { + : WebWorkerBase(child_thread, route_id, render_view_route_id) { } -bool WebSharedWorkerImpl::isStarted() { +bool WebSharedWorkerProxy::isStarted() { return IsStarted(); } -void WebSharedWorkerImpl::startWorkerContext( +void WebSharedWorkerProxy::startWorkerContext( const WebKit::WebURL& script_url, + const WebKit::WebString& name, const WebKit::WebString& user_agent, const WebKit::WebString& 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); + CreateWorkerContext(script_url, true, name, user_agent, source_code); } -void WebSharedWorkerImpl::connect(WebKit::WebMessagePortChannel* channel) { +void WebSharedWorkerProxy::connect(WebKit::WebMessagePortChannel* channel) { WebMessagePortChannelImpl* webchannel = static_cast<WebMessagePortChannelImpl*>(channel); @@ -44,13 +38,13 @@ void WebSharedWorkerImpl::connect(WebKit::WebMessagePortChannel* channel) { Send(new WorkerMsg_Connect(route_id_, message_port_id, MSG_ROUTING_NONE)); } -void WebSharedWorkerImpl::OnMessageReceived(const IPC::Message& message) { - IPC_BEGIN_MESSAGE_MAP(WebSharedWorkerImpl, message) +void WebSharedWorkerProxy::OnMessageReceived(const IPC::Message& message) { + IPC_BEGIN_MESSAGE_MAP(WebSharedWorkerProxy, message) IPC_MESSAGE_HANDLER(ViewMsg_WorkerCreated, OnWorkerCreated) IPC_END_MESSAGE_MAP() } -void WebSharedWorkerImpl::OnWorkerCreated() { +void WebSharedWorkerProxy::OnWorkerCreated() { // The worker is created - now send off the CreateWorkerContext message and // any other queued messages SendQueuedMessages(); diff --git a/chrome/renderer/websharedworker_impl.h b/chrome/renderer/websharedworker_proxy.h index 14d122d89..8ffe63c 100644 --- a/chrome/renderer/websharedworker_impl.h +++ b/chrome/renderer/websharedworker_proxy.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_IMPL_H_ -#define CHROME_RENDERER_WEBSHAREDWORKER_IMPL_H_ +#ifndef CHROME_RENDERER_WEBSHAREDWORKER_PROXY_H_ +#define CHROME_RENDERER_WEBSHAREDWORKER_PROXY_H_ #include "base/basictypes.h" #include "chrome/renderer/webworker_base.h" @@ -17,12 +17,10 @@ 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 WebSharedWorkerImpl : public WebKit::WebSharedWorker, - private WebWorkerBase { +class WebSharedWorkerProxy : public WebKit::WebSharedWorker, + private WebWorkerBase { public: - WebSharedWorkerImpl(const GURL& url, - const string16& name, - ChildThread* child_thread, + WebSharedWorkerProxy(ChildThread* child_thread, int route_id, int render_view_route_id); @@ -30,20 +28,17 @@ class WebSharedWorkerImpl : 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 implementation. + // IPC::Channel::Listener proxyementation. void OnMessageReceived(const IPC::Message& message); private: void OnWorkerCreated(); - // The name and URL that uniquely identify this worker. - GURL url_; - string16 name_; - - DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerImpl); + DISALLOW_COPY_AND_ASSIGN(WebSharedWorkerProxy); }; -#endif // CHROME_RENDERER_WEBSHAREDWORKER_IMPL_H_ +#endif // CHROME_RENDERER_WEBSHAREDWORKER_PROXY_H_ diff --git a/chrome/renderer/webworker_base.cc b/chrome/renderer/webworker_base.cc index 98365cd..1364e7a 100644 --- a/chrome/renderer/webworker_base.cc +++ b/chrome/renderer/webworker_base.cc @@ -48,12 +48,14 @@ void WebWorkerBase::Disconnect() { route_id_ = MSG_ROUTING_NONE; } -void WebWorkerBase::CreateWorkerContext(IPC::Message* create_message, - const GURL& script_url, +void WebWorkerBase::CreateWorkerContext(const GURL& script_url, + bool is_shared, + const string16& name, const string16& user_agent, const string16& source_code) { DCHECK(route_id_ == MSG_ROUTING_NONE); - // create_message is a sync message that sets route_id_ + IPC::Message* create_message = new ViewHostMsg_CreateWorker( + script_url, is_shared, name, render_view_route_id_, &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 c7c6c62..12ee84a 100644 --- a/chrome/renderer/webworker_base.h +++ b/chrome/renderer/webworker_base.h @@ -26,8 +26,9 @@ class WebWorkerBase : public IPC::Channel::Listener { virtual ~WebWorkerBase(); // Creates and initializes a new worker context. - void CreateWorkerContext(IPC::Message* create_message, - const GURL& script_url, + void CreateWorkerContext(const GURL& script_url, + bool is_shared, + const string16& name, const string16& user_agent, const string16& source_code); diff --git a/chrome/renderer/webworker_proxy.cc b/chrome/renderer/webworker_proxy.cc index 5a24c41..e8a5b9d 100644 --- a/chrome/renderer/webworker_proxy.cc +++ b/chrome/renderer/webworker_proxy.cc @@ -11,6 +11,7 @@ #include "webkit/api/public/WebURL.h" #include "webkit/api/public/WebWorkerClient.h" +using WebKit::WebCommonWorkerClient; using WebKit::WebMessagePortChannel; using WebKit::WebMessagePortChannelArray; using WebKit::WebString; @@ -41,9 +42,7 @@ void WebWorkerProxy::startWorkerContext( const WebURL& script_url, const WebString& user_agent, const WebString& 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); + CreateWorkerContext(script_url, false, string16(), user_agent, source_code); } void WebWorkerProxy::terminateWorkerContext() { @@ -97,8 +96,8 @@ void WebWorkerProxy::OnMessageReceived(const IPC::Message& message) { client_, WebWorkerClient::reportPendingActivity) IPC_MESSAGE_FORWARD(WorkerHostMsg_WorkerContextDestroyed, - client_, - WebWorkerClient::workerContextDestroyed) + static_cast<WebCommonWorkerClient*>(client_), + WebCommonWorkerClient::workerContextDestroyed) IPC_END_MESSAGE_MAP() } diff --git a/chrome/renderer/webworker_proxy.h b/chrome/renderer/webworker_proxy.h index 686669a..48487c0 100644 --- a/chrome/renderer/webworker_proxy.h +++ b/chrome/renderer/webworker_proxy.h @@ -46,6 +46,7 @@ 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); |