summaryrefslogtreecommitdiffstats
path: root/webkit/glue/devtools
diff options
context:
space:
mode:
Diffstat (limited to 'webkit/glue/devtools')
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.cc2
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.h8
-rw-r--r--webkit/glue/devtools/debugger_agent_manager.cc43
-rw-r--r--webkit/glue/devtools/debugger_agent_manager.h13
4 files changed, 45 insertions, 21 deletions
diff --git a/webkit/glue/devtools/debugger_agent_impl.cc b/webkit/glue/devtools/debugger_agent_impl.cc
index 299af72..88fc171 100644
--- a/webkit/glue/devtools/debugger_agent_impl.cc
+++ b/webkit/glue/devtools/debugger_agent_impl.cc
@@ -31,7 +31,7 @@ using WebCore::V8Proxy;
DebuggerAgentImpl::DebuggerAgentImpl(
WebViewImpl* web_view_impl,
DebuggerAgentDelegate* delegate,
- WebDevToolsAgent* webdevtools_agent)
+ WebDevToolsAgentImpl* webdevtools_agent)
: web_view_impl_(web_view_impl),
delegate_(delegate),
webdevtools_agent_(webdevtools_agent) {
diff --git a/webkit/glue/devtools/debugger_agent_impl.h b/webkit/glue/devtools/debugger_agent_impl.h
index 664d506..acce569 100644
--- a/webkit/glue/devtools/debugger_agent_impl.h
+++ b/webkit/glue/devtools/debugger_agent_impl.h
@@ -8,7 +8,7 @@
#include "v8.h"
#include "webkit/glue/devtools/debugger_agent.h"
-class WebDevToolsAgent;
+class WebDevToolsAgentImpl;
class WebViewImpl;
namespace WebCore {
@@ -22,7 +22,7 @@ class DebuggerAgentImpl : public DebuggerAgent {
public:
DebuggerAgentImpl(WebViewImpl* web_view_impl,
DebuggerAgentDelegate* delegate,
- WebDevToolsAgent* webdevtools_agent);
+ WebDevToolsAgentImpl* webdevtools_agent);
virtual ~DebuggerAgentImpl();
// Initializes dom agent with the given document.
@@ -42,13 +42,13 @@ class DebuggerAgentImpl : public DebuggerAgent {
const WebCore::String& json_args);
WebCore::Page* GetPage();
- WebDevToolsAgent* webdevtools_agent() { return webdevtools_agent_; };
+ WebDevToolsAgentImpl* webdevtools_agent() { return webdevtools_agent_; };
private:
v8::Persistent<v8::Context> context_;
WebViewImpl* web_view_impl_;
DebuggerAgentDelegate* delegate_;
- WebDevToolsAgent* webdevtools_agent_;
+ WebDevToolsAgentImpl* webdevtools_agent_;
DISALLOW_COPY_AND_ASSIGN(DebuggerAgentImpl);
};
diff --git a/webkit/glue/devtools/debugger_agent_manager.cc b/webkit/glue/devtools/debugger_agent_manager.cc
index 678c904..ef37b7d 100644
--- a/webkit/glue/devtools/debugger_agent_manager.cc
+++ b/webkit/glue/devtools/debugger_agent_manager.cc
@@ -15,6 +15,7 @@
#include "base/values.h"
#include "webkit/glue/devtools/debugger_agent_impl.h"
#include "webkit/glue/devtools/debugger_agent_manager.h"
+#include "webkit/glue/webdevtoolsagent_impl.h"
#if USE(V8)
#include "v8/include/v8-debug.h"
@@ -32,6 +33,15 @@ void DebuggerAgentManager::V8DebugMessageHandler(const uint16_t* message,
#endif
}
+void DebuggerAgentManager::V8DebugHostDispatchHandler(
+ void* dispatch,
+ void* data) {
+ WebDevToolsAgent::Message* m =
+ reinterpret_cast<WebDevToolsAgent::Message*>(dispatch);
+ m->Dispatch();
+ delete m;
+}
+
// static
DebuggerAgentManager::AttachedAgentsSet*
DebuggerAgentManager::attached_agents_ = NULL;
@@ -45,6 +55,9 @@ void DebuggerAgentManager::DebugAttach(DebuggerAgentImpl* debugger_agent) {
&DebuggerAgentManager::V8DebugMessageHandler,
NULL, /* no additional data */
false /* don't create separate thread for sending debugger output */);
+ v8::Debug::SetHostDispatchHandler(
+ &DebuggerAgentManager::V8DebugHostDispatchHandler,
+ NULL /* no additional data */);
}
attached_agents_->add(debugger_agent);
#endif
@@ -61,6 +74,7 @@ void DebuggerAgentManager::DebugDetach(DebuggerAgentImpl* debugger_agent) {
attached_agents_->remove(debugger_agent);
if (attached_agents_->isEmpty()) {
v8::Debug::SetMessageHandler(NULL);
+ v8::Debug::SetHostDispatchHandler(NULL);
delete attached_agents_;
attached_agents_ = NULL;
}
@@ -126,8 +140,8 @@ bool DebuggerAgentManager::SendCommandResponse(DictionaryValue* response) {
return false;
}
- int agent_ptr;
- if (!request_seq->GetInteger(L"webdevtools_agent", &agent_ptr)) {
+ int caller_id;
+ if (!request_seq->GetInteger(L"caller_id", &caller_id)) {
NOTREACHED();
return false;
}
@@ -140,7 +154,7 @@ bool DebuggerAgentManager::SendCommandResponse(DictionaryValue* response) {
}
DebuggerAgentImpl* debugger_agent = FindDebuggerAgentForToolsAgent(
- reinterpret_cast<WebDevToolsAgent*>(agent_ptr));
+ caller_id);
if (!debugger_agent) {
return false;
}
@@ -155,15 +169,23 @@ bool DebuggerAgentManager::SendCommandResponse(DictionaryValue* response) {
// static
void DebuggerAgentManager::ExecuteDebuggerCommand(
const std::string& command,
- WebDevToolsAgent* webdevtools_agent) {
+ int caller_id) {
const std::string cmd = DebuggerAgentManager::ReplaceRequestSequenceId(
command,
- webdevtools_agent);
+ caller_id);
SendCommandToV8(UTF8ToWide(cmd));
}
// static
+void DebuggerAgentManager::ScheduleMessageDispatch(
+ WebDevToolsAgent::Message* message) {
+#if USE(V8)
+ v8::Debug::SendHostDispatch(message);
+#endif
+}
+
+// static
void DebuggerAgentManager::SendCommandToV8(const std::wstring& cmd) {
#if USE(V8)
v8::Debug::SendCommand(reinterpret_cast<const uint16_t*>(cmd.data()),
@@ -195,7 +217,7 @@ DebuggerAgentImpl* DebuggerAgentManager::FindAgentForCurrentV8Context() {
const std::string DebuggerAgentManager::ReplaceRequestSequenceId(
const std::string& request,
- WebDevToolsAgent* webdevtools_agent) {
+ int caller_id) {
OwnPtr<Value> message(JSONReader::Read(request,
false /* allow_trailing_comma */));
if (!message.get()) {
@@ -219,8 +241,7 @@ const std::string DebuggerAgentManager::ReplaceRequestSequenceId(
// TODO(yurys): get rid of this hack, handler pointer should be passed
// into v8::Debug::SendCommand along with the command.
- int agent_ptr = reinterpret_cast<int>(webdevtools_agent);
- new_seq.Set(L"webdevtools_agent", Value::CreateIntegerValue(agent_ptr));
+ new_seq.SetInteger(L"caller_id", caller_id);
// TODO(yurys): fix v8 parser so that it handle objects as ids correctly.
std::string new_seq_str;
@@ -232,13 +253,11 @@ const std::string DebuggerAgentManager::ReplaceRequestSequenceId(
return json;
}
-// Note that we cannot safely dereference 'webdevtools_agent' bacause the
-// referenced agent may already have been detached and destroyed.
DebuggerAgentImpl* DebuggerAgentManager::FindDebuggerAgentForToolsAgent(
- WebDevToolsAgent* webdevtools_agent) {
+ int caller_id) {
for (AttachedAgentsSet::iterator it = attached_agents_->begin();
it != attached_agents_->end(); ++it) {
- if ((*it)->webdevtools_agent() == webdevtools_agent) {
+ if ((*it)->webdevtools_agent()->host_id() == caller_id) {
return *it;
}
}
diff --git a/webkit/glue/devtools/debugger_agent_manager.h b/webkit/glue/devtools/debugger_agent_manager.h
index 39469b8..42f03cc 100644
--- a/webkit/glue/devtools/debugger_agent_manager.h
+++ b/webkit/glue/devtools/debugger_agent_manager.h
@@ -10,10 +10,10 @@
#include "base/basictypes.h"
#include "v8/include/v8-debug.h"
+#include "webkit/glue/webdevtoolsagent.h"
class DebuggerAgentImpl;
class DictionaryValue;
-class WebDevToolsAgent;
// There is single v8 instance per render process. Also there may be several
// RenderViews and consequently devtools agents in the process that want to talk
@@ -38,7 +38,11 @@ class DebuggerAgentManager {
static void DebugCommand(const std::string& command);
static void ExecuteDebuggerCommand(const std::string& command,
- WebDevToolsAgent* webdevtools_agent);
+ int caller_id);
+
+ // Requests that debugger makes a callback on the render thread while on
+ // breakpoint.
+ static void ScheduleMessageDispatch(WebDevToolsAgent::Message* message);
private:
DebuggerAgentManager();
@@ -47,17 +51,18 @@ class DebuggerAgentManager {
static void V8DebugMessageHandler(const uint16_t* message,
int length,
void* data);
+ static void V8DebugHostDispatchHandler(void* dispatch, void* data);
static void DebuggerOutput(const std::string& out);
static void SendCommandToV8(const std::wstring& cmd);
static bool SendCommandResponse(DictionaryValue* response);
static DebuggerAgentImpl* FindAgentForCurrentV8Context();
static DebuggerAgentImpl* FindDebuggerAgentForToolsAgent(
- WebDevToolsAgent* webdevtools_agent);
+ int caller_id);
static const std::string ReplaceRequestSequenceId(
const std::string& request,
- WebDevToolsAgent* webdevtools_agent);
+ int caller_id);
typedef HashSet<DebuggerAgentImpl*> AttachedAgentsSet;
static AttachedAgentsSet* attached_agents_;