diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 02:13:41 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 02:13:41 +0000 |
commit | 5f3f56de244046b0222ef25510809b79a36135d9 (patch) | |
tree | 8cbd74310eaecae79efd20af5e8d60a062ce78e3 | |
parent | f72f38623b7a32e7ba8c92f4a6d98d05fc51c311 (diff) | |
download | chromium_src-5f3f56de244046b0222ef25510809b79a36135d9.zip chromium_src-5f3f56de244046b0222ef25510809b79a36135d9.tar.gz chromium_src-5f3f56de244046b0222ef25510809b79a36135d9.tar.bz2 |
Move createWorker from WebKitClient to WebWorkerClient per your suggestion, to avoid using WebKitClient outside the main thread.
Review URL: http://codereview.chromium.org/115103
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16454 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/worker/webworkerclient_proxy.cc | 6 | ||||
-rw-r--r-- | chrome/worker/worker_webkitclient_impl.cc | 6 | ||||
-rw-r--r-- | chrome/worker/worker_webkitclient_impl.h | 1 | ||||
-rw-r--r-- | webkit/api/public/WebKitClient.h | 7 | ||||
-rw-r--r-- | webkit/api/public/WebWorkerClient.h | 6 | ||||
-rw-r--r-- | webkit/glue/webkitclient_impl.h | 3 | ||||
-rw-r--r-- | webkit/glue/webworker_impl.h | 2 | ||||
-rw-r--r-- | webkit/glue/webworkerclient_impl.cc | 15 | ||||
-rw-r--r-- | webkit/glue/webworkerclient_impl.h | 3 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_worker/test_webworker.h | 3 |
10 files changed, 34 insertions, 18 deletions
diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc index 2c57dad..003a860 100644 --- a/chrome/worker/webworkerclient_proxy.cc +++ b/chrome/worker/webworkerclient_proxy.cc @@ -7,6 +7,7 @@ #include "chrome/common/child_process.h" #include "chrome/common/ipc_logging.h" #include "chrome/common/worker_messages.h" +#include "chrome/renderer/webworker_proxy.h" #include "chrome/worker/worker_thread.h" #include "webkit/api/public/WebString.h" #include "webkit/api/public/WebURL.h" @@ -70,6 +71,11 @@ void WebWorkerClientProxy::workerContextDestroyed() { delete this; } +WebKit::WebWorker* WebWorkerClientProxy::createWorker( + WebKit::WebWorkerClient* client) { + return new WebWorkerProxy(client, WorkerThread::current(), 0); +} + bool WebWorkerClientProxy::Send(IPC::Message* message) { return WorkerThread::current()->Send(message); } diff --git a/chrome/worker/worker_webkitclient_impl.cc b/chrome/worker/worker_webkitclient_impl.cc index 21d715ab..1861b64 100644 --- a/chrome/worker/worker_webkitclient_impl.cc +++ b/chrome/worker/worker_webkitclient_impl.cc @@ -5,7 +5,6 @@ #include "chrome/worker/worker_webkitclient_impl.h" #include "base/logging.h" -#include "chrome/renderer/webworker_proxy.h" #include "chrome/worker/worker_thread.h" #include "webkit/api/public/WebString.h" #include "webkit/api/public/WebURL.h" @@ -57,8 +56,3 @@ WebKit::WebString WorkerWebKitClientImpl::defaultLocale() { NOTREACHED(); return WebKit::WebString(); } - -WebKit::WebWorker* WorkerWebKitClientImpl::createWorker( - WebKit::WebWorkerClient* client) { - return new WebWorkerProxy(client, WorkerThread::current(), 0); -} diff --git a/chrome/worker/worker_webkitclient_impl.h b/chrome/worker/worker_webkitclient_impl.h index 61d8824..474e1b2 100644 --- a/chrome/worker/worker_webkitclient_impl.h +++ b/chrome/worker/worker_webkitclient_impl.h @@ -23,7 +23,6 @@ class WorkerWebKitClientImpl : public webkit_glue::WebKitClientImpl { const WebKit::WebURL& policy_url); virtual void prefetchHostName(const WebKit::WebString&); virtual WebKit::WebString defaultLocale(); - virtual WebKit::WebWorker* createWorker(WebKit::WebWorkerClient* client); }; #endif // CHROME_WORKER_WORKER_WEBKIT_CLIENT_IMPL_H_ diff --git a/webkit/api/public/WebKitClient.h b/webkit/api/public/WebKitClient.h index 112e5ff..5b136d5 100644 --- a/webkit/api/public/WebKitClient.h +++ b/webkit/api/public/WebKitClient.h @@ -44,8 +44,6 @@ namespace WebKit { class WebURL; struct WebPluginInfo; template <typename T> class WebVector; - class WebWorker; - class WebWorkerClient; class WebKitClient { public: @@ -129,11 +127,6 @@ namespace WebKit { // Callable from a background WebKit thread. virtual void callOnMainThread(void (*func)()) = 0; - - - // WebWorkers ---------------------------------------------------------- - - virtual WebWorker* createWorker(WebWorkerClient*) = 0; }; } // namespace WebKit diff --git a/webkit/api/public/WebWorkerClient.h b/webkit/api/public/WebWorkerClient.h index dd46de2..6c6f0db 100644 --- a/webkit/api/public/WebWorkerClient.h +++ b/webkit/api/public/WebWorkerClient.h @@ -35,8 +35,11 @@ namespace WebKit { class WebString; + class WebWorker; // 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: virtual void postMessageToWorkerObject(const WebString&) = 0; @@ -57,6 +60,9 @@ namespace WebKit { virtual void reportPendingActivity(bool hasPendingActivity) = 0; virtual void workerContextDestroyed() = 0; + + // This can be called on any thread to create a nested worker. + virtual WebKit::WebWorker* createWorker(WebKit::WebWorkerClient* client) = 0; }; } // namespace WebKit diff --git a/webkit/glue/webkitclient_impl.h b/webkit/glue/webkitclient_impl.h index d820ee8..679cb61 100644 --- a/webkit/glue/webkitclient_impl.h +++ b/webkit/glue/webkitclient_impl.h @@ -33,9 +33,6 @@ class WebKitClientImpl : public WebKit::WebKitClient { virtual void stopSharedTimer(); virtual void callOnMainThread(void (*func)()); virtual void suddenTerminationChanged(bool enabled) { } - virtual WebKit::WebWorker* createWorker(WebKit::WebWorkerClient* client) { - return NULL; - } private: void DoTimeout() { diff --git a/webkit/glue/webworker_impl.h b/webkit/glue/webworker_impl.h index f1c6910..4477a2c 100644 --- a/webkit/glue/webworker_impl.h +++ b/webkit/glue/webworker_impl.h @@ -55,6 +55,8 @@ class WebWorkerImpl: public WebCore::WorkerObjectProxy, virtual void postMessageToWorkerContext(const WebKit::WebString& message); virtual void workerObjectDestroyed(); + WebKit::WebWorkerClient* client() { return client_; } + // Executes the given task on the main thread. static void DispatchTaskToMainThread( PassRefPtr<WebCore::ScriptExecutionContext::Task> task); diff --git a/webkit/glue/webworkerclient_impl.cc b/webkit/glue/webworkerclient_impl.cc index 216b78c..5e5cf23 100644 --- a/webkit/glue/webworkerclient_impl.cc +++ b/webkit/glue/webworkerclient_impl.cc @@ -12,8 +12,11 @@ #include "FrameLoaderClient.h" #include "GenericWorkerTask.h" #include "ScriptExecutionContext.h" +#include "WorkerContextExecutionProxy.h" #include "WorkerMessagingProxy.h" #include "Worker.h" +#include "WorkerContext.h" +#include "WorkerThread.h" #include <wtf/Threading.h> #undef LOG @@ -71,7 +74,17 @@ WebCore::WorkerContextProxy* WebCore::WorkerContextProxy::create( frame_loader_client->webframe()->GetWebViewImpl()->delegate(); webworker = webview_delegate->CreateWebWorker(proxy); } else { - webworker = WebKit::webKitClient()->createWorker(proxy); + WebCore::WorkerContextExecutionProxy* current_context = + WebCore::WorkerContextExecutionProxy::retrieve(); + if (!current_context) { + NOTREACHED(); + return NULL; + } + + WebCore::WorkerObjectProxy* worker_object_proxy = + current_context->workerContext()->thread()->workerObjectProxy(); + WebWorkerImpl* impl = reinterpret_cast<WebWorkerImpl*>(worker_object_proxy); + webworker = impl->client()->createWorker(proxy); } proxy->set_webworker(webworker); diff --git a/webkit/glue/webworkerclient_impl.h b/webkit/glue/webworkerclient_impl.h index 685eac9..f76ed5e 100644 --- a/webkit/glue/webworkerclient_impl.h +++ b/webkit/glue/webworkerclient_impl.h @@ -59,6 +59,9 @@ class WebWorkerClientImpl : public WebCore::WorkerContextProxy, virtual void confirmMessageFromWorkerObject(bool has_pending_activity); virtual void reportPendingActivity(bool has_pending_activity); virtual void workerContextDestroyed(); + virtual WebKit::WebWorker* createWorker(WebKit::WebWorkerClient* client) { + return NULL; + } private: virtual ~WebWorkerClientImpl(); diff --git a/webkit/tools/test_shell/test_worker/test_webworker.h b/webkit/tools/test_shell/test_worker/test_webworker.h index 1071775..171b09c 100644 --- a/webkit/tools/test_shell/test_worker/test_webworker.h +++ b/webkit/tools/test_shell/test_worker/test_webworker.h @@ -48,6 +48,9 @@ class TestWebWorker : public WebKit::WebWorker, virtual void confirmMessageFromWorkerObject(bool has_pending_activity); virtual void reportPendingActivity(bool has_pending_activity); virtual void workerContextDestroyed(); + virtual WebKit::WebWorker* createWorker(WebKit::WebWorkerClient* client) { + return NULL; + } private: friend class base::RefCounted<TestWebWorker>; |