OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/worker/webworker_stub.h" | 5 #include "content/worker/webworker_stub.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/common/child_thread.h" | 8 #include "content/common/child_thread.h" |
| 9 #include "content/common/content_client.h" |
9 #include "content/common/file_system/file_system_dispatcher.h" | 10 #include "content/common/file_system/file_system_dispatcher.h" |
10 #include "content/common/webmessageportchannel_impl.h" | 11 #include "content/common/webmessageportchannel_impl.h" |
11 #include "content/common/worker_messages.h" | 12 #include "content/common/worker_messages.h" |
| 13 #include "content/worker/worker_devtools_agent.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorker.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWorker.h" |
15 | 17 |
16 using WebKit::WebWorker; | 18 using WebKit::WebWorker; |
17 | 19 |
18 WebWorkerStub::WebWorkerStub(const GURL& url, int route_id, | 20 WebWorkerStub::WebWorkerStub(const GURL& url, int route_id, |
19 const WorkerAppCacheInitInfo& appcache_init_info) | 21 const WorkerAppCacheInitInfo& appcache_init_info) |
20 : WebWorkerStubBase(route_id, appcache_init_info), | 22 : WebWorkerStubBase(route_id, appcache_init_info), |
21 ALLOW_THIS_IN_INITIALIZER_LIST(impl_(WebWorker::create(client()))), | 23 ALLOW_THIS_IN_INITIALIZER_LIST(impl_(WebWorker::create(client()))), |
22 url_(url) { | 24 url_(url), |
| 25 ALLOW_THIS_IN_INITIALIZER_LIST(worker_devtools_agent_( |
| 26 new WorkerDevToolsAgent(route_id, impl_))) { |
| 27 client()->set_devtools_agent(worker_devtools_agent_.get()); |
23 } | 28 } |
24 | 29 |
25 WebWorkerStub::~WebWorkerStub() { | 30 WebWorkerStub::~WebWorkerStub() { |
26 impl_->clientDestroyed(); | 31 impl_->clientDestroyed(); |
27 } | 32 } |
28 | 33 |
29 void WebWorkerStub::OnChannelError() { | 34 void WebWorkerStub::OnChannelError() { |
30 OnTerminateWorkerContext(); | 35 OnTerminateWorkerContext(); |
31 } | 36 } |
32 | 37 |
33 const GURL& WebWorkerStub::url() const { | 38 const GURL& WebWorkerStub::url() const { |
34 return url_; | 39 return url_; |
35 } | 40 } |
36 | 41 |
37 bool WebWorkerStub::OnMessageReceived(const IPC::Message& message) { | 42 bool WebWorkerStub::OnMessageReceived(const IPC::Message& message) { |
38 if (!impl_) | 43 if (!impl_) |
39 return false; | 44 return false; |
40 | 45 |
| 46 if (worker_devtools_agent_->OnMessageReceived(message)) |
| 47 return true; |
| 48 |
41 bool handled = true; | 49 bool handled = true; |
42 IPC_BEGIN_MESSAGE_MAP(WebWorkerStub, message) | 50 IPC_BEGIN_MESSAGE_MAP(WebWorkerStub, message) |
43 IPC_MESSAGE_FORWARD(WorkerMsg_StartWorkerContext, impl_, | 51 IPC_MESSAGE_FORWARD(WorkerMsg_StartWorkerContext, impl_, |
44 WebWorker::startWorkerContext) | 52 WebWorker::startWorkerContext) |
45 IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext, | 53 IPC_MESSAGE_HANDLER(WorkerMsg_TerminateWorkerContext, |
46 OnTerminateWorkerContext) | 54 OnTerminateWorkerContext) |
47 IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage) | 55 IPC_MESSAGE_HANDLER(WorkerMsg_PostMessage, OnPostMessage) |
48 IPC_MESSAGE_FORWARD(WorkerMsg_WorkerObjectDestroyed, impl_, | 56 IPC_MESSAGE_FORWARD(WorkerMsg_WorkerObjectDestroyed, impl_, |
49 WebWorker::workerObjectDestroyed) | 57 WebWorker::workerObjectDestroyed) |
50 IPC_MESSAGE_UNHANDLED(handled = false) | 58 IPC_MESSAGE_UNHANDLED(handled = false) |
(...skipping 13 matching lines...) Expand all Loading... |
64 const std::vector<int>& sent_message_port_ids, | 72 const std::vector<int>& sent_message_port_ids, |
65 const std::vector<int>& new_routing_ids) { | 73 const std::vector<int>& new_routing_ids) { |
66 WebKit::WebMessagePortChannelArray channels(sent_message_port_ids.size()); | 74 WebKit::WebMessagePortChannelArray channels(sent_message_port_ids.size()); |
67 for (size_t i = 0; i < sent_message_port_ids.size(); i++) { | 75 for (size_t i = 0; i < sent_message_port_ids.size(); i++) { |
68 channels[i] = new WebMessagePortChannelImpl( | 76 channels[i] = new WebMessagePortChannelImpl( |
69 new_routing_ids[i], sent_message_port_ids[i]); | 77 new_routing_ids[i], sent_message_port_ids[i]); |
70 } | 78 } |
71 | 79 |
72 impl_->postMessageToWorkerContext(message, channels); | 80 impl_->postMessageToWorkerContext(message, channels); |
73 } | 81 } |
OLD | NEW |