diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/renderer/webworker_proxy.cc | 10 | ||||
-rw-r--r-- | chrome/renderer/webworker_proxy.h | 5 | ||||
-rw-r--r-- | chrome/worker/webworkerclient_proxy.cc | 15 | ||||
-rw-r--r-- | chrome/worker/webworkerclient_proxy.h | 8 | ||||
-rw-r--r-- | chrome/worker/worker.scons | 3 | ||||
-rw-r--r-- | chrome/worker/worker.vcproj | 12 | ||||
-rw-r--r-- | chrome/worker/worker_thread.cc | 20 | ||||
-rw-r--r-- | chrome/worker/worker_thread.h | 7 | ||||
-rw-r--r-- | chrome/worker/worker_webkitclient_impl.cc | 29 | ||||
-rw-r--r-- | chrome/worker/worker_webkitclient_impl.h | 23 |
10 files changed, 105 insertions, 27 deletions
diff --git a/chrome/renderer/webworker_proxy.cc b/chrome/renderer/webworker_proxy.cc index cf6477a..0da55f3 100644 --- a/chrome/renderer/webworker_proxy.cc +++ b/chrome/renderer/webworker_proxy.cc @@ -28,6 +28,12 @@ void WebWorkerProxy::StartWorkerContext( RenderThread::current()->AddRoute(route_id_, this); Send(new WorkerMsg_StartWorkerContext( route_id_, script_url, user_agent, source_code)); + + for (size_t i = 0; i < queued_messages_.size(); ++i) { + queued_messages_[i]->set_routing_id(route_id_); + Send(queued_messages_[i]); + } + queued_messages_.clear(); } void WebWorkerProxy::TerminateWorkerContext() { @@ -50,8 +56,8 @@ void WebWorkerProxy::WorkerObjectDestroyed() { bool WebWorkerProxy::Send(IPC::Message* message) { if (route_id_ == MSG_ROUTING_NONE) { - delete message; - return false; + queued_messages_.push_back(message); + return true; } // For now we proxy all messages to the worker process through the browser. diff --git a/chrome/renderer/webworker_proxy.h b/chrome/renderer/webworker_proxy.h index 97a6bb3..e068e8e 100644 --- a/chrome/renderer/webworker_proxy.h +++ b/chrome/renderer/webworker_proxy.h @@ -5,6 +5,8 @@ #ifndef CHROME_RENDERER_WEBWORKER_PROXY_H_ #define CHROME_RENDERER_WEBWORKER_PROXY_H_ +#include <vector> + #include "base/basictypes.h" #include "chrome/common/ipc_channel.h" #include "webkit/glue/webworker.h" @@ -49,6 +51,9 @@ class WebWorkerProxy : public WebWorker, // messages. WebWorkerClient* client_; + // Stores messages that were sent before the StartWorkerContext message. + std::vector<IPC::Message*> queued_messages_; + DISALLOW_COPY_AND_ASSIGN(WebWorkerProxy); }; diff --git a/chrome/worker/webworkerclient_proxy.cc b/chrome/worker/webworkerclient_proxy.cc index fc8c2d3..9e3917c0 100644 --- a/chrome/worker/webworkerclient_proxy.cc +++ b/chrome/worker/webworkerclient_proxy.cc @@ -14,7 +14,6 @@ WebWorkerClientProxy::WebWorkerClientProxy(const GURL& url, int route_id) : url_(url), route_id_(route_id), - started_worker_(false), ALLOW_THIS_IN_INITIALIZER_LIST(impl_(WebWorker::Create(this))) { WorkerThread::current()->AddRoute(route_id_, this); WorkerProcess::current()->AddRefProcess(); @@ -67,12 +66,6 @@ bool WebWorkerClientProxy::Send(IPC::Message* message) { } void WebWorkerClientProxy::OnMessageReceived(const IPC::Message& message) { - if (!started_worker_ && - message.type() != WorkerMsg_StartWorkerContext::ID) { - queued_messages_.push_back(new IPC::Message(message)); - return; - } - WebWorker* worker = impl_.get(); IPC_BEGIN_MESSAGE_MAP(WebWorkerClientProxy, message) IPC_MESSAGE_FORWARD(WorkerMsg_StartWorkerContext, worker, @@ -84,12 +77,4 @@ void WebWorkerClientProxy::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_FORWARD(WorkerMsg_WorkerObjectDestroyed, worker, WebWorker::WorkerObjectDestroyed) IPC_END_MESSAGE_MAP() - - if (message.type() == WorkerMsg_StartWorkerContext::ID) { - started_worker_ = true; - for (size_t i = 0; i < queued_messages_.size(); ++i) - OnMessageReceived(*queued_messages_[i]); - - queued_messages_.clear(); - } } diff --git a/chrome/worker/webworkerclient_proxy.h b/chrome/worker/webworkerclient_proxy.h index c744023..094bdeb 100644 --- a/chrome/worker/webworkerclient_proxy.h +++ b/chrome/worker/webworkerclient_proxy.h @@ -5,8 +5,6 @@ #ifndef CHROME_WORKER_WEBWORKERCLIENT_PROXY_H_ #define CHROME_WORKER_WEBWORKERCLIENT_PROXY_H_ -#include <vector> - #include "base/basictypes.h" #include "base/scoped_ptr.h" #include "chrome/common/ipc_channel.h" @@ -54,14 +52,8 @@ class WebWorkerClientProxy : public WebWorkerClient, int route_id_; - // Whether we've received StartWorkerContext message. - bool started_worker_; - scoped_ptr<WebWorker> impl_; - // Stores messages that arrived before the StartWorkerContext message. - std::vector<IPC::Message*> queued_messages_; - DISALLOW_COPY_AND_ASSIGN(WebWorkerClientProxy); }; diff --git a/chrome/worker/worker.scons b/chrome/worker/worker.scons index e00c413..6b194c4 100644 --- a/chrome/worker/worker.scons +++ b/chrome/worker/worker.scons @@ -32,6 +32,8 @@ input_files = ChromeFileList([ 'worker_process.h', 'worker_thread.cc', 'worker_thread.h', + 'worker_webkitclient_impl.cc', + 'worker_webkitclient_impl.h', '$CHROME_DIR/tools/build/win/precompiled$OBJSUFFIX', '$CHROME_DIR/tools/build/win/precompiled.h', ]) @@ -48,6 +50,7 @@ if env.Bit('posix'): 'worker_main.cc', 'worker_process.cc', 'worker_thread.cc', + 'worker_webkitclient_impl.cc', ) env.ChromeLibrary('worker', input_files) diff --git a/chrome/worker/worker.vcproj b/chrome/worker/worker.vcproj index ba82a39..08b43d1 100644 --- a/chrome/worker/worker.vcproj +++ b/chrome/worker/worker.vcproj @@ -18,7 +18,7 @@ <Configuration
Name="Debug|Win32"
ConfigurationType="4"
- InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;..\tools\build\win\precompiled.vsprops"
+ InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\debug.vsprops;..\tools\build\win\precompiled.vsprops;..\..\webkit\build\WebKit\using_WebKit.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
@@ -69,7 +69,7 @@ <Configuration
Name="Release|Win32"
ConfigurationType="4"
- InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\release.vsprops"
+ InheritedPropertySheets="$(SolutionDir)..\build\common.vsprops;$(SolutionDir)..\build\release.vsprops;..\..\webkit\build\WebKit\using_WebKit.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
@@ -165,6 +165,14 @@ RelativePath=".\worker_thread.h"
>
</File>
+ <File
+ RelativePath=".\worker_webkitclient_impl.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\worker_webkitclient_impl.h"
+ >
+ </File>
</Files>
<Globals>
</Globals>
diff --git a/chrome/worker/worker_thread.cc b/chrome/worker/worker_thread.cc index daba38b..298f9db 100644 --- a/chrome/worker/worker_thread.cc +++ b/chrome/worker/worker_thread.cc @@ -7,6 +7,9 @@ #include "chrome/common/worker_messages.h" #include "chrome/worker/webworkerclient_proxy.h" #include "chrome/worker/worker_process.h" +#include "chrome/worker/worker_webkitclient_impl.h" + +#include "WebKit.h" WorkerThread::WorkerThread() : ChildThread(base::Thread::Options(MessageLoop::TYPE_DEFAULT, kV8StackSize)) { @@ -15,6 +18,23 @@ WorkerThread::WorkerThread() WorkerThread::~WorkerThread() { } +void WorkerThread::Init() { + ChildThread::Init(); + webkit_client_.reset(new WorkerWebKitClientImpl); + WebKit::initialize(webkit_client_.get()); +} + +void WorkerThread::CleanUp() { + // Shutdown in reverse of the initialization order. + + if (webkit_client_.get()) { + WebKit::shutdown(); + webkit_client_.reset(); + } + + ChildThread::CleanUp(); +} + void WorkerThread::OnControlMessageReceived(const IPC::Message& msg) { IPC_BEGIN_MESSAGE_MAP(WorkerThread, msg) IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateWorker) diff --git a/chrome/worker/worker_thread.h b/chrome/worker/worker_thread.h index 25ae2f2..c7f9a09 100644 --- a/chrome/worker/worker_thread.h +++ b/chrome/worker/worker_thread.h @@ -9,6 +9,7 @@ #include "chrome/common/child_thread.h" class GURL; +class WorkerWebKitClientImpl; class WorkerThread : public ChildThread { public: @@ -23,8 +24,14 @@ class WorkerThread : public ChildThread { private: virtual void OnControlMessageReceived(const IPC::Message& msg); + // Called by the thread base class + virtual void Init(); + virtual void CleanUp(); + void OnCreateWorker(const GURL& url, int route_id); + scoped_ptr<WorkerWebKitClientImpl> webkit_client_; + DISALLOW_COPY_AND_ASSIGN(WorkerThread); }; diff --git a/chrome/worker/worker_webkitclient_impl.cc b/chrome/worker/worker_webkitclient_impl.cc new file mode 100644 index 0000000..8bd147c --- /dev/null +++ b/chrome/worker/worker_webkitclient_impl.cc @@ -0,0 +1,29 @@ +// 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/worker_webkitclient_impl.h" + +#include "WebString.h" +#include "WebURL.h" + +WebKit::WebMimeRegistry* WorkerWebKitClientImpl::mimeRegistry() { + return NULL; +} + +void WorkerWebKitClientImpl::setCookies(const WebKit::WebURL& url, + const WebKit::WebURL& policy_url, + const WebKit::WebString& value) { +} + +WebKit::WebString WorkerWebKitClientImpl::cookies( + const WebKit::WebURL& url, const WebKit::WebURL& policy_url) { + return WebKit::WebString(); +} + +void WorkerWebKitClientImpl::prefetchHostName(const WebKit::WebString&) { +} + +WebKit::WebString WorkerWebKitClientImpl::defaultLocale() { + return WebKit::WebString(); +} diff --git a/chrome/worker/worker_webkitclient_impl.h b/chrome/worker/worker_webkitclient_impl.h new file mode 100644 index 0000000..e8b9a73 --- /dev/null +++ b/chrome/worker/worker_webkitclient_impl.h @@ -0,0 +1,23 @@ +// 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_WORKER_WEBKIT_CLIENT_IMPL_H_ +#define CHROME_WORKER_WORKER_WEBKIT_CLIENT_IMPL_H_ + +#include "webkit/glue/webkitclient_impl.h" + +class WorkerWebKitClientImpl : public webkit_glue::WebKitClientImpl { + public: + // WebKitClient methods: + virtual WebKit::WebMimeRegistry* mimeRegistry(); + virtual void setCookies(const WebKit::WebURL& url, + const WebKit::WebURL& policy_url, + const WebKit::WebString& value); + virtual WebKit::WebString cookies(const WebKit::WebURL& url, + const WebKit::WebURL& policy_url); + virtual void prefetchHostName(const WebKit::WebString&); + virtual WebKit::WebString defaultLocale(); +}; + +#endif // CHROME_WORKER_WORKER_WEBKIT_CLIENT_IMPL_H_ |