summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/debugger_bridge.cc17
-rw-r--r--webkit/glue/debugger_bridge.h8
2 files changed, 19 insertions, 6 deletions
diff --git a/webkit/glue/debugger_bridge.cc b/webkit/glue/debugger_bridge.cc
index 6a00858..77a4c43 100644
--- a/webkit/glue/debugger_bridge.cc
+++ b/webkit/glue/debugger_bridge.cc
@@ -11,19 +11,30 @@
#include "v8/include/v8-debug.h"
#endif
-void V8DebugMessageHandler(const uint16_t* message, int length, void* data) {
+void V8DebugMessageHandler(const uint16_t* message, int length,
+ v8::Debug::ClientData* client_data) {
+ if (!DebuggerBridge::instance_) {
+ NOTREACHED();
+ return;
+ }
std::wstring out(reinterpret_cast<const wchar_t*>(message), length);
- reinterpret_cast<DebuggerBridge*>(data)->OutputLater(out);
+ DebuggerBridge::instance_->OutputLater(out);
}
+// static
+DebuggerBridge* DebuggerBridge::instance_ = NULL;
+
DebuggerBridge::DebuggerBridge(Delegate* del)
: delegate_(del),
attached_(false) {
delegate_loop_ = MessageLoop::current();
+ DCHECK(instance_ == NULL);
+ instance_ = this;
}
DebuggerBridge::~DebuggerBridge() {
DCHECK(!attached_);
+ instance_ = NULL;
Detach();
}
@@ -38,7 +49,7 @@ void DebuggerBridge::Attach() {
#ifdef USING_V8
if (!attached_) {
attached_ = true;
- v8::Debug::SetMessageHandler(V8DebugMessageHandler, this);
+ v8::Debug::SetMessageHandler(V8DebugMessageHandler);
}
#endif
}
diff --git a/webkit/glue/debugger_bridge.h b/webkit/glue/debugger_bridge.h
index 423641c..f4bd160 100644
--- a/webkit/glue/debugger_bridge.h
+++ b/webkit/glue/debugger_bridge.h
@@ -15,7 +15,8 @@
#include "base/ref_counted.h"
#include "v8/include/v8-debug.h"
-void V8DebugMessageHandler(const uint16_t* message, int length, void* data);
+void V8DebugMessageHandler(const uint16_t* message, int length,
+ v8::Debug::ClientData* client_data);
class DebuggerBridge : public base::RefCountedThreadSafe<DebuggerBridge> {
public:
@@ -44,8 +45,8 @@ class DebuggerBridge : public base::RefCountedThreadSafe<DebuggerBridge> {
void Detach();
private:
- friend void V8DebugMessageHandler(const uint16_t* message,
- int length, void* data);
+ friend void V8DebugMessageHandler(const uint16_t* message, int length,
+ v8::Debug::ClientData* client_data);
// Called by the LocalDebugSession so that the delegate can called in the
// appropriate thread.
@@ -56,6 +57,7 @@ class DebuggerBridge : public base::RefCountedThreadSafe<DebuggerBridge> {
Delegate* delegate_;
MessageLoop* delegate_loop_;
bool attached_;
+ static DebuggerBridge* instance_;
DISALLOW_COPY_AND_ASSIGN(DebuggerBridge);
};