summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authoryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 14:13:04 +0000
committeryurys@google.com <yurys@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-08 14:13:04 +0000
commit9b9d728c445b3c1c2ac0b3f66753a205dc2eafc3 (patch)
treed52354b9d35df88bff508b5936a7fd9b98f31d55 /chrome/renderer
parent51a5ea2a6ef9d361b62ef1e6f3590131ac395cea (diff)
downloadchromium_src-9b9d728c445b3c1c2ac0b3f66753a205dc2eafc3.zip
chromium_src-9b9d728c445b3c1c2ac0b3f66753a205dc2eafc3.tar.gz
chromium_src-9b9d728c445b3c1c2ac0b3f66753a205dc2eafc3.tar.bz2
1. All debugger messages are dispatched in a static method on the IO thread. All responses from the v8 go to another static method where we should find out which devtool agent delegate should be used for sending the response. We use call_id to match request with the delegate its response should be sent to. We don't pass the delegate directly as it's designed to be accessed on the render thread only.
To match debug command response with its request the request sequence number is replaced with a number that is unique across the renderer(note that requests from different clients may have equal ids so we cannot rely on them). This happens before the command gets to the v8. When the command response is ready the original request_seq is restored. Before that the request_seq field is used to find out which devtools agent delegate should be used for sending the response. 2. For the debugger events we derive target agent from the current v8 execution context. If there is no agent attached to the RenderView owning that context 'continue' command is sent to the v8 automatically and the message is ignored. Review URL: http://codereview.chromium.org/62106 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13347 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/devtools_agent_filter.cc14
-rw-r--r--chrome/renderer/devtools_agent_filter.h10
-rw-r--r--chrome/renderer/render_view.cc6
3 files changed, 24 insertions, 6 deletions
diff --git a/chrome/renderer/devtools_agent_filter.cc b/chrome/renderer/devtools_agent_filter.cc
index 319746f..9ecc2b4 100644
--- a/chrome/renderer/devtools_agent_filter.cc
+++ b/chrome/renderer/devtools_agent_filter.cc
@@ -7,22 +7,28 @@
#include "chrome/common/devtools_messages.h"
#include "webkit/glue/webdevtoolsagent.h"
-DevToolsAgentFilter::DevToolsAgentFilter() {
+DevToolsAgentFilter::DevToolsAgentFilter(WebDevToolsAgent* webdevtools_agent,
+ int routing_id)
+ : webdevtools_agent_(webdevtools_agent),
+ routing_id_(routing_id) {
}
DevToolsAgentFilter::~DevToolsAgentFilter() {
}
bool DevToolsAgentFilter::OnMessageReceived(const IPC::Message& message) {
+ if (routing_id_ != message.routing_id()) {
+ return false;
+ }
+
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(DevToolsAgentFilter, message)
- IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DebuggerCommand,
- OnDebuggerCommand)
+ IPC_MESSAGE_HANDLER(DevToolsAgentMsg_DebuggerCommand, OnDebuggerCommand)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void DevToolsAgentFilter::OnDebuggerCommand(const std::string& command) {
- WebDevToolsAgent::ExecuteDebuggerCommand(command);
+ WebDevToolsAgent::ExecuteDebuggerCommand(command, webdevtools_agent_);
}
diff --git a/chrome/renderer/devtools_agent_filter.h b/chrome/renderer/devtools_agent_filter.h
index edfe221..c784383 100644
--- a/chrome/renderer/devtools_agent_filter.h
+++ b/chrome/renderer/devtools_agent_filter.h
@@ -9,6 +9,8 @@
#include "chrome/common/ipc_channel_proxy.h"
+class WebDevToolsAgent;
+
// DevToolsAgentFilter is registered as an IPC filter in order to be able to
// dispatch messages while on the IO thread. The reason for that is that while
// debugging, Render thread is being held by the v8 and hence no messages
@@ -20,7 +22,12 @@ class DevToolsAgentFilter : public IPC::ChannelProxy::MessageFilter {
// DevToolsAgentFilter is a field of the RenderView. The view is supposed
// to remove this agent from the message filter list on IO thread before
// dying.
- DevToolsAgentFilter();
+ //
+ // Note that the pointer to WebDevToolsAgent should never be dereferenced on
+ // the IO thread because it is destroyed asynchronously on the render thread.
+ // However the filter needs it to pass along with debugger command request
+ // to WebDevToolsAgent::ExecuteDebuggerCommand static method.
+ DevToolsAgentFilter(WebDevToolsAgent* webdevtools_agent, int routing_id);
virtual ~DevToolsAgentFilter();
private:
@@ -31,6 +38,7 @@ class DevToolsAgentFilter : public IPC::ChannelProxy::MessageFilter {
// handle debug messages even when v8 is stopped.
void OnDebuggerCommand(const std::string& command);
+ WebDevToolsAgent* webdevtools_agent_;
int routing_id_; // View routing id that we can access from IO thread.
DISALLOW_COPY_AND_ASSIGN(DevToolsAgentFilter);
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 3ed10cf..e76d187 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -300,9 +300,13 @@ void RenderView::Init(gfx::NativeViewId parent_hwnd,
}
devtools_agent_.reset(new DevToolsAgent(routing_id, this));
- devtools_agent_filter_ = new DevToolsAgentFilter();
+
webwidget_ = WebView::Create(this, webkit_prefs);
+ devtools_agent_filter_ = new DevToolsAgentFilter(
+ webview()->GetWebDevToolsAgent(),
+ routing_id);
+
#if defined(OS_LINUX)
// We have to enable ourselves as the editor delegate on linux so we can copy
// text selections to the X clipboard.