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 #include "content/renderer/webworker_proxy.h" | 5 #include "content/renderer/webworker_proxy.h" |
6 | 6 |
7 #include "content/common/child_thread.h" | 7 #include "content/common/child_thread.h" |
8 #include "content/common/content_client.h" | |
8 #include "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
9 #include "content/common/webmessageportchannel_impl.h" | 10 #include "content/common/webmessageportchannel_impl.h" |
10 #include "content/common/worker_messages.h" | 11 #include "content/common/worker_messages.h" |
12 #include "content/renderer/worker_devtools_agent_proxy.h" | |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerClient.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorkerClient.h" |
13 | 15 |
14 using WebKit::WebCommonWorkerClient; | 16 using WebKit::WebCommonWorkerClient; |
15 using WebKit::WebMessagePortChannel; | 17 using WebKit::WebMessagePortChannel; |
16 using WebKit::WebMessagePortChannelArray; | 18 using WebKit::WebMessagePortChannelArray; |
17 using WebKit::WebString; | 19 using WebKit::WebString; |
18 using WebKit::WebURL; | 20 using WebKit::WebURL; |
19 using WebKit::WebWorkerClient; | 21 using WebKit::WebWorkerClient; |
20 | 22 |
21 WebWorkerProxy::WebWorkerProxy( | 23 WebWorkerProxy::WebWorkerProxy( |
22 WebWorkerClient* client, | 24 WebWorkerClient* client, |
23 ChildThread* child_thread, | 25 ChildThread* child_thread, |
24 int render_view_route_id, | 26 int render_view_route_id, |
25 int parent_appcache_host_id) | 27 int parent_appcache_host_id) |
26 : WebWorkerBase(child_thread, 0, MSG_ROUTING_NONE, render_view_route_id, | 28 : WebWorkerBase( |
27 parent_appcache_host_id), | 29 child_thread, |
30 0, | |
31 MSG_ROUTING_NONE, | |
32 render_view_route_id, | |
33 parent_appcache_host_id, | |
34 new WorkerDevToolsAgentProxy(this, MSG_ROUTING_NONE, client)), | |
28 client_(client) { | 35 client_(client) { |
29 // TODO(atwilson): Change to pass in a real document_id when we support nested | 36 // TODO(atwilson): Change to pass in a real document_id when we support nested |
30 // workers. | 37 // workers. |
31 } | 38 } |
32 | 39 |
33 WebWorkerProxy::~WebWorkerProxy() { | 40 WebWorkerProxy::~WebWorkerProxy() { |
34 // If we're midway through starting a worker, cancel it. | 41 // If we're midway through starting a worker, cancel it. |
35 CancelCreation(); | 42 CancelCreation(); |
36 } | 43 } |
37 | 44 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 } | 84 } |
78 | 85 |
79 void WebWorkerProxy::workerObjectDestroyed() { | 86 void WebWorkerProxy::workerObjectDestroyed() { |
80 Send(new WorkerMsg_WorkerObjectDestroyed(route_id_)); | 87 Send(new WorkerMsg_WorkerObjectDestroyed(route_id_)); |
81 delete this; | 88 delete this; |
82 } | 89 } |
83 | 90 |
84 void WebWorkerProxy::clientDestroyed() { | 91 void WebWorkerProxy::clientDestroyed() { |
85 } | 92 } |
86 | 93 |
94 void WebWorkerProxy::attachDevTools() | |
95 { | |
jam
2011/05/25 17:50:12
nit: brace brackets on previous line
yurys
2011/05/26 09:11:49
Done.
| |
96 devtools_delegate_->AttachDevTools(); | |
97 } | |
98 | |
99 void WebWorkerProxy::detachDevTools() | |
100 { | |
101 devtools_delegate_->DetachDevTools(); | |
102 } | |
103 | |
104 void WebWorkerProxy::dispatchDevToolsMessage(const WebString& message) | |
105 { | |
106 devtools_delegate_->SendDevToolsMessage(message.utf8()); | |
107 } | |
108 | |
87 bool WebWorkerProxy::OnMessageReceived(const IPC::Message& message) { | 109 bool WebWorkerProxy::OnMessageReceived(const IPC::Message& message) { |
88 if (!client_) | 110 if (!client_) |
89 return false; | 111 return false; |
90 | 112 |
113 if (devtools_delegate_->OnMessageReceived(message)) | |
114 return true; | |
115 | |
91 bool handled = true; | 116 bool handled = true; |
92 IPC_BEGIN_MESSAGE_MAP(WebWorkerProxy, message) | 117 IPC_BEGIN_MESSAGE_MAP(WebWorkerProxy, message) |
93 IPC_MESSAGE_HANDLER(ViewMsg_WorkerCreated, OnWorkerCreated) | 118 IPC_MESSAGE_HANDLER(ViewMsg_WorkerCreated, OnWorkerCreated) |
94 IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage) | 119 IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage) |
95 IPC_MESSAGE_FORWARD(WorkerHostMsg_PostExceptionToWorkerObject, | 120 IPC_MESSAGE_FORWARD(WorkerHostMsg_PostExceptionToWorkerObject, |
96 client_, | 121 client_, |
97 WebWorkerClient::postExceptionToWorkerObject) | 122 WebWorkerClient::postExceptionToWorkerObject) |
98 IPC_MESSAGE_HANDLER(WorkerHostMsg_PostConsoleMessageToWorkerObject, | 123 IPC_MESSAGE_HANDLER(WorkerHostMsg_PostConsoleMessageToWorkerObject, |
99 OnPostConsoleMessageToWorkerObject) | 124 OnPostConsoleMessageToWorkerObject) |
100 IPC_MESSAGE_FORWARD(WorkerHostMsg_ConfirmMessageFromWorkerObject, | 125 IPC_MESSAGE_FORWARD(WorkerHostMsg_ConfirmMessageFromWorkerObject, |
(...skipping 30 matching lines...) Expand all Loading... | |
131 client_->postMessageToWorkerObject(message, channels); | 156 client_->postMessageToWorkerObject(message, channels); |
132 } | 157 } |
133 | 158 |
134 void WebWorkerProxy::OnPostConsoleMessageToWorkerObject( | 159 void WebWorkerProxy::OnPostConsoleMessageToWorkerObject( |
135 const WorkerHostMsg_PostConsoleMessageToWorkerObject_Params& params) { | 160 const WorkerHostMsg_PostConsoleMessageToWorkerObject_Params& params) { |
136 client_->postConsoleMessageToWorkerObject(params.source_identifier, | 161 client_->postConsoleMessageToWorkerObject(params.source_identifier, |
137 params.message_type, params.message_level, | 162 params.message_type, params.message_level, |
138 params.message, params.line_number, params.source_url); | 163 params.message, params.line_number, params.source_url); |
139 } | 164 } |
140 | 165 |
OLD | NEW |