| 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 devtools_proxy_->AttachDevTools(); |
| 96 } |
| 97 |
| 98 void WebWorkerProxy::detachDevTools() { |
| 99 devtools_proxy_->DetachDevTools(); |
| 100 } |
| 101 |
| 102 void WebWorkerProxy::dispatchDevToolsMessage(const WebString& message) { |
| 103 devtools_proxy_->SendDevToolsMessage(message.utf8()); |
| 104 } |
| 105 |
| 87 bool WebWorkerProxy::OnMessageReceived(const IPC::Message& message) { | 106 bool WebWorkerProxy::OnMessageReceived(const IPC::Message& message) { |
| 88 if (!client_) | 107 if (!client_) |
| 89 return false; | 108 return false; |
| 90 | 109 |
| 110 if (devtools_proxy_->OnMessageReceived(message)) |
| 111 return true; |
| 112 |
| 91 bool handled = true; | 113 bool handled = true; |
| 92 IPC_BEGIN_MESSAGE_MAP(WebWorkerProxy, message) | 114 IPC_BEGIN_MESSAGE_MAP(WebWorkerProxy, message) |
| 93 IPC_MESSAGE_HANDLER(ViewMsg_WorkerCreated, OnWorkerCreated) | 115 IPC_MESSAGE_HANDLER(ViewMsg_WorkerCreated, OnWorkerCreated) |
| 94 IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage) | 116 IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage) |
| 95 IPC_MESSAGE_FORWARD(WorkerHostMsg_PostExceptionToWorkerObject, | 117 IPC_MESSAGE_FORWARD(WorkerHostMsg_PostExceptionToWorkerObject, |
| 96 client_, | 118 client_, |
| 97 WebWorkerClient::postExceptionToWorkerObject) | 119 WebWorkerClient::postExceptionToWorkerObject) |
| 98 IPC_MESSAGE_HANDLER(WorkerHostMsg_PostConsoleMessageToWorkerObject, | 120 IPC_MESSAGE_HANDLER(WorkerHostMsg_PostConsoleMessageToWorkerObject, |
| 99 OnPostConsoleMessageToWorkerObject) | 121 OnPostConsoleMessageToWorkerObject) |
| 100 IPC_MESSAGE_FORWARD(WorkerHostMsg_ConfirmMessageFromWorkerObject, | 122 IPC_MESSAGE_FORWARD(WorkerHostMsg_ConfirmMessageFromWorkerObject, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 131 client_->postMessageToWorkerObject(message, channels); | 153 client_->postMessageToWorkerObject(message, channels); |
| 132 } | 154 } |
| 133 | 155 |
| 134 void WebWorkerProxy::OnPostConsoleMessageToWorkerObject( | 156 void WebWorkerProxy::OnPostConsoleMessageToWorkerObject( |
| 135 const WorkerHostMsg_PostConsoleMessageToWorkerObject_Params& params) { | 157 const WorkerHostMsg_PostConsoleMessageToWorkerObject_Params& params) { |
| 136 client_->postConsoleMessageToWorkerObject(params.source_identifier, | 158 client_->postConsoleMessageToWorkerObject(params.source_identifier, |
| 137 params.message_type, params.message_level, | 159 params.message_type, params.message_level, |
| 138 params.message, params.line_number, params.source_url); | 160 params.message, params.line_number, params.source_url); |
| 139 } | 161 } |
| 140 | 162 |
| OLD | NEW |