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 CONTENT_RENDERER_WEBWORKER_PROXY_H_ | 5 #ifndef CONTENT_RENDERER_WEBWORKER_PROXY_H_ |
6 #define CONTENT_RENDERER_WEBWORKER_PROXY_H_ | 6 #define CONTENT_RENDERER_WEBWORKER_PROXY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "content/renderer/webworker_base.h" | 12 #include "content/renderer/webworker_base.h" |
13 #include "ipc/ipc_channel.h" | 13 #include "ipc/ipc_channel.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorker.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorker.h" |
15 | 15 |
| 16 #ifndef WebTransferableReceipt_h |
| 17 #ifndef STUB_WebTransferableReceipt_h |
| 18 #define STUB_WebTransferableReceipt_h |
| 19 namespace WebKit { |
| 20 typedef WebMessagePortChannel WebTransferableReceipt; |
| 21 typedef WebVector<WebTransferableReceipt*> WebTransferableReceiptArray; |
| 22 } // namespace WebKit |
| 23 #endif // STUB_WebTransferableReceipt_h |
| 24 #endif // WebTransferableReceipt_h |
| 25 |
16 class ChildThread; | 26 class ChildThread; |
17 class GURL; | 27 class GURL; |
18 class RenderView; | 28 class RenderView; |
19 struct WorkerHostMsg_PostConsoleMessageToWorkerObject_Params; | 29 struct WorkerHostMsg_PostConsoleMessageToWorkerObject_Params; |
20 | 30 |
21 // This class provides an implementation of WebWorker that the renderer provides | 31 // This class provides an implementation of WebWorker that the renderer provides |
22 // to the glue. This class converts function calls to IPC messages that are | 32 // to the glue. This class converts function calls to IPC messages that are |
23 // dispatched in the worker process by WebWorkerClientProxy. It also receives | 33 // dispatched in the worker process by WebWorkerClientProxy. It also receives |
24 // IPC messages from WebWorkerClientProxy which it converts to function calls to | 34 // IPC messages from WebWorkerClientProxy which it converts to function calls to |
25 // WebWorkerClient. | 35 // WebWorkerClient. |
26 class WebWorkerProxy : public WebKit::WebWorker, private WebWorkerBase { | 36 class WebWorkerProxy : public WebKit::WebWorker, private WebWorkerBase { |
27 public: | 37 public: |
28 WebWorkerProxy(WebKit::WebWorkerClient* client, | 38 WebWorkerProxy(WebKit::WebWorkerClient* client, |
29 ChildThread* child_thread, | 39 ChildThread* child_thread, |
30 int render_view_route_id, | 40 int render_view_route_id, |
31 int parent_appcache_host_id); | 41 int parent_appcache_host_id); |
32 virtual ~WebWorkerProxy(); | 42 virtual ~WebWorkerProxy(); |
33 | 43 |
34 // WebWorker implementation. | 44 // WebWorker implementation. |
35 virtual void startWorkerContext(const WebKit::WebURL& script_url, | 45 virtual void startWorkerContext(const WebKit::WebURL& script_url, |
36 const WebKit::WebString& user_agent, | 46 const WebKit::WebString& user_agent, |
37 const WebKit::WebString& source_code); | 47 const WebKit::WebString& source_code); |
38 virtual void terminateWorkerContext(); | 48 virtual void terminateWorkerContext(); |
39 virtual void postMessageToWorkerContext( | 49 virtual void postMessageToWorkerContext( |
40 const WebKit::WebString& message, | 50 const WebKit::WebString& message, |
41 const WebKit::WebMessagePortChannelArray& channel_array); | 51 const WebKit::WebTransferableReceiptArray& receipts); |
42 virtual void workerObjectDestroyed(); | 52 virtual void workerObjectDestroyed(); |
43 virtual void clientDestroyed(); | 53 virtual void clientDestroyed(); |
44 | 54 |
45 virtual void attachDevTools(); | 55 virtual void attachDevTools(); |
46 virtual void detachDevTools(); | 56 virtual void detachDevTools(); |
47 virtual void dispatchDevToolsMessage(const WebKit::WebString&); | 57 virtual void dispatchDevToolsMessage(const WebKit::WebString&); |
48 | 58 |
49 // IPC::Channel::Listener implementation. | 59 // IPC::Channel::Listener implementation. |
50 virtual bool OnMessageReceived(const IPC::Message& message); | 60 virtual bool OnMessageReceived(const IPC::Message& message); |
51 | 61 |
52 private: | 62 private: |
53 void CancelCreation(); | 63 void CancelCreation(); |
54 void OnWorkerCreated(); | 64 void OnWorkerCreated(); |
55 void OnWorkerContextDestroyed(); | 65 void OnWorkerContextDestroyed(); |
56 void OnPostMessage(const string16& message, | 66 void OnPostMessage(const string16& message, |
57 const std::vector<int>& sent_message_port_ids, | 67 const std::vector<int>& sent_message_port_ids, |
58 const std::vector<int>& new_routing_ids); | 68 const std::vector<int>& new_routing_ids); |
59 void OnPostConsoleMessageToWorkerObject( | 69 void OnPostConsoleMessageToWorkerObject( |
60 const WorkerHostMsg_PostConsoleMessageToWorkerObject_Params& params); | 70 const WorkerHostMsg_PostConsoleMessageToWorkerObject_Params& params); |
61 | 71 |
62 | 72 |
63 // Used to communicate to the WebCore::Worker object in response to IPC | 73 // Used to communicate to the WebCore::Worker object in response to IPC |
64 // messages. | 74 // messages. |
65 WebKit::WebWorkerClient* client_; | 75 WebKit::WebWorkerClient* client_; |
66 | 76 |
67 DISALLOW_COPY_AND_ASSIGN(WebWorkerProxy); | 77 DISALLOW_COPY_AND_ASSIGN(WebWorkerProxy); |
68 }; | 78 }; |
69 | 79 |
70 #endif // CONTENT_RENDERER_WEBWORKER_PROXY_H_ | 80 #endif // CONTENT_RENDERER_WEBWORKER_PROXY_H_ |
OLD | NEW |