| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_RENDERER_WEBWORKER_PROXY_H_ | 5 #ifndef CHROME_RENDERER_WEBWORKER_PROXY_H_ |
| 6 #define CHROME_RENDERER_WEBWORKER_PROXY_H_ | 6 #define CHROME_RENDERER_WEBWORKER_PROXY_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "chrome/common/ipc_channel.h" | 11 #include "chrome/common/ipc_channel.h" |
| 12 #include "webkit/api/public/WebWorker.h" | 12 #include "webkit/api/public/WebWorker.h" |
| 13 | 13 |
| 14 class ChildThread; | 14 class ChildThread; |
| 15 class GURL; | 15 class GURL; |
| 16 class RenderView; | 16 class RenderView; |
| 17 struct WorkerHostMsg_PostConsoleMessageToWorkerObject_Params; |
| 17 | 18 |
| 18 // This class provides an implementation of WebWorker that the renderer provides | 19 // This class provides an implementation of WebWorker that the renderer provides |
| 19 // to the glue. This class converts function calls to IPC messages that are | 20 // to the glue. This class converts function calls to IPC messages that are |
| 20 // dispatched in the worker process by WebWorkerClientProxy. It also receives | 21 // dispatched in the worker process by WebWorkerClientProxy. It also receives |
| 21 // IPC messages from WebWorkerClientProxy which it converts to function calls to | 22 // IPC messages from WebWorkerClientProxy which it converts to function calls to |
| 22 // WebWorkerClient. | 23 // WebWorkerClient. |
| 23 class WebWorkerProxy : public WebKit::WebWorker, | 24 class WebWorkerProxy : public WebKit::WebWorker, |
| 24 public IPC::Channel::Listener { | 25 public IPC::Channel::Listener { |
| 25 public: | 26 public: |
| 26 WebWorkerProxy(WebKit::WebWorkerClient* client, | 27 WebWorkerProxy(WebKit::WebWorkerClient* client, |
| 27 ChildThread* child_thread, | 28 ChildThread* child_thread, |
| 28 int render_view_route_id); | 29 int render_view_route_id); |
| 29 virtual ~WebWorkerProxy(); | 30 virtual ~WebWorkerProxy(); |
| 30 | 31 |
| 31 // WebWorker implementation. | 32 // WebWorker implementation. |
| 32 virtual void startWorkerContext(const WebKit::WebURL& script_url, | 33 virtual void startWorkerContext(const WebKit::WebURL& script_url, |
| 33 const WebKit::WebString& user_agent, | 34 const WebKit::WebString& user_agent, |
| 34 const WebKit::WebString& source_code); | 35 const WebKit::WebString& source_code); |
| 35 virtual void terminateWorkerContext(); | 36 virtual void terminateWorkerContext(); |
| 36 virtual void postMessageToWorkerContext(const WebKit::WebString& message); | 37 virtual void postMessageToWorkerContext(const WebKit::WebString& message); |
| 37 virtual void workerObjectDestroyed(); | 38 virtual void workerObjectDestroyed(); |
| 38 | 39 |
| 39 // IPC::Channel::Listener implementation. | 40 // IPC::Channel::Listener implementation. |
| 40 void OnMessageReceived(const IPC::Message& message); | 41 void OnMessageReceived(const IPC::Message& message); |
| 41 | 42 |
| 42 private: | 43 private: |
| 43 bool Send(IPC::Message* message); | 44 bool Send(IPC::Message* message); |
| 44 | 45 |
| 45 void OnDedicatedWorkerCreated(); | 46 void OnDedicatedWorkerCreated(); |
| 47 void OnPostConsoleMessageToWorkerObject( |
| 48 const WorkerHostMsg_PostConsoleMessageToWorkerObject_Params& params); |
| 49 |
| 46 void Disconnect(); | 50 void Disconnect(); |
| 47 | 51 |
| 48 // The routing id used to reach WebWorkerClientProxy in the worker process. | 52 // The routing id used to reach WebWorkerClientProxy in the worker process. |
| 49 int route_id_; | 53 int route_id_; |
| 50 | 54 |
| 51 ChildThread* child_thread_; | 55 ChildThread* child_thread_; |
| 52 | 56 |
| 53 // The routing id for the RenderView that created this worker. | 57 // The routing id for the RenderView that created this worker. |
| 54 int render_view_route_id_; | 58 int render_view_route_id_; |
| 55 | 59 |
| 56 // Used to communicate to the WebCore::Worker object in response to IPC | 60 // Used to communicate to the WebCore::Worker object in response to IPC |
| 57 // messages. | 61 // messages. |
| 58 WebKit::WebWorkerClient* client_; | 62 WebKit::WebWorkerClient* client_; |
| 59 | 63 |
| 60 // Stores messages that were sent before the StartWorkerContext message. | 64 // Stores messages that were sent before the StartWorkerContext message. |
| 61 std::vector<IPC::Message*> queued_messages_; | 65 std::vector<IPC::Message*> queued_messages_; |
| 62 | 66 |
| 63 DISALLOW_COPY_AND_ASSIGN(WebWorkerProxy); | 67 DISALLOW_COPY_AND_ASSIGN(WebWorkerProxy); |
| 64 }; | 68 }; |
| 65 | 69 |
| 66 #endif // CHROME_RENDERER_WEBWORKER_PROXY_H_ | 70 #endif // CHROME_RENDERER_WEBWORKER_PROXY_H_ |
| OLD | NEW |