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 "chrome/renderer/devtools_agent_filter.h" | 5 #include "chrome/renderer/devtools_agent_filter.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "chrome/common/devtools_messages.h" | 8 #include "chrome/common/devtools_messages.h" |
9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
10 #include "chrome/renderer/devtools_agent.h" | 10 #include "chrome/renderer/devtools_agent.h" |
11 #include "chrome/renderer/plugin_channel_host.h" | 11 #include "chrome/renderer/plugin_channel_host.h" |
12 #include "chrome/renderer/render_view.h" | 12 #include "chrome/renderer/render_view.h" |
13 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h" | 13 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgent.h" |
14 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsMessageData.h" | |
15 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsMessageTransport.
h" | |
16 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 14 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
17 #include "webkit/glue/devtools_message_data.h" | |
18 | 15 |
19 using WebKit::WebDevToolsAgent; | 16 using WebKit::WebDevToolsAgent; |
20 using WebKit::WebDevToolsMessageData; | |
21 using WebKit::WebDevToolsMessageTransport; | |
22 using WebKit::WebString; | 17 using WebKit::WebString; |
23 | 18 |
24 // static | 19 // static |
25 void DevToolsAgentFilter::DispatchMessageLoop() { | 20 void DevToolsAgentFilter::DispatchMessageLoop() { |
26 MessageLoop* current = MessageLoop::current(); | 21 MessageLoop* current = MessageLoop::current(); |
27 bool old_state = current->NestableTasksAllowed(); | 22 bool old_state = current->NestableTasksAllowed(); |
28 current->SetNestableTasksAllowed(true); | 23 current->SetNestableTasksAllowed(true); |
29 current->RunAllPending(); | 24 current->RunAllPending(); |
30 current->SetNestableTasksAllowed(old_state); | 25 current->SetNestableTasksAllowed(old_state); |
31 } | 26 } |
(...skipping 13 matching lines...) Expand all Loading... |
45 } | 40 } |
46 | 41 |
47 bool DevToolsAgentFilter::OnMessageReceived(const IPC::Message& message) { | 42 bool DevToolsAgentFilter::OnMessageReceived(const IPC::Message& message) { |
48 // Dispatch debugger commands directly from IO. | 43 // Dispatch debugger commands directly from IO. |
49 message_handled_ = true; | 44 message_handled_ = true; |
50 current_routing_id_ = message.routing_id(); | 45 current_routing_id_ = message.routing_id(); |
51 IPC_BEGIN_MESSAGE_MAP(DevToolsAgentFilter, message) | 46 IPC_BEGIN_MESSAGE_MAP(DevToolsAgentFilter, message) |
52 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DebuggerCommand, OnDebuggerCommand) | 47 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DebuggerCommand, OnDebuggerCommand) |
53 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DebuggerPauseScript, | 48 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DebuggerPauseScript, |
54 OnDebuggerPauseScript) | 49 OnDebuggerPauseScript) |
55 IPC_MESSAGE_HANDLER(DevToolsAgentMsg_RpcMessage, OnRpcMessage) | |
56 IPC_MESSAGE_UNHANDLED(message_handled_ = false) | 50 IPC_MESSAGE_UNHANDLED(message_handled_ = false) |
57 IPC_END_MESSAGE_MAP() | 51 IPC_END_MESSAGE_MAP() |
58 return message_handled_; | 52 return message_handled_; |
59 } | 53 } |
60 | 54 |
61 void DevToolsAgentFilter::OnDebuggerCommand(const std::string& command) { | 55 void DevToolsAgentFilter::OnDebuggerCommand(const std::string& command) { |
62 WebDevToolsAgent::executeDebuggerCommand( | 56 WebDevToolsAgent::executeDebuggerCommand( |
63 WebString::fromUTF8(command), current_routing_id_); | 57 WebString::fromUTF8(command), current_routing_id_); |
64 } | 58 } |
65 | 59 |
66 void DevToolsAgentFilter::OnDebuggerPauseScript() { | 60 void DevToolsAgentFilter::OnDebuggerPauseScript() { |
67 WebDevToolsAgent::debuggerPauseScript(); | 61 WebDevToolsAgent::debuggerPauseScript(); |
68 } | 62 } |
69 | |
70 namespace { | |
71 | |
72 class WebDevToolsMessageTransportImpl : public WebDevToolsMessageTransport { | |
73 public: | |
74 void sendMessageToFrontendOnIOThread(const WebDevToolsMessageData& data) { | |
75 DevToolsAgentFilter::SendRpcMessage(DevToolsMessageData(data)); | |
76 } | |
77 }; | |
78 | |
79 } // namespace | |
80 | |
81 void DevToolsAgentFilter::OnRpcMessage(const DevToolsMessageData& data) { | |
82 WebDevToolsMessageTransportImpl transport; | |
83 message_handled_ = WebDevToolsAgent::dispatchMessageFromFrontendOnIOThread( | |
84 &transport, | |
85 data.ToWebDevToolsMessageData()); | |
86 } | |
87 | |
88 // static | |
89 void DevToolsAgentFilter::SendRpcMessage(const DevToolsMessageData& data) { | |
90 IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient( | |
91 current_routing_id_, | |
92 DevToolsClientMsg_RpcMessage(data)); | |
93 channel_->Send(m); | |
94 } | |
OLD | NEW |