Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: src/api.cc

Issue 100158: Create a transition API for the debug message handler (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include/v8-debug.h ('K') | « include/v8-debug.h ('k') | src/debug.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
===================================================================
--- src/api.cc (revision 1813)
+++ src/api.cc (working copy)
@@ -3260,6 +3260,16 @@
}
+static v8::Debug::MessageHandler message_handler = NULL;
+
+static void MessageHandlerWrapper(const v8::Debug::Message& message) {
+ if (message_handler) {
+ v8::String::Value json(message.GetJSON());
+ message_handler(*json, json.length(), message.GetClientData());
+ }
+}
+
+
void Debug::SetMessageHandler(v8::Debug::MessageHandler handler,
bool message_handler_thread) {
EnsureInitialized("v8::Debug::SetMessageHandler");
@@ -3267,6 +3277,20 @@
// Message handler thread not supported any more. Parameter temporally left in
// the API for client compatability reasons.
CHECK(!message_handler_thread);
+
+ // TODO(sgjesse) support the old message handler API through a simple wrapper.
+ message_handler = handler;
+ if (message_handler != NULL) {
+ i::Debugger::SetMessageHandler(MessageHandlerWrapper);
+ } else {
+ i::Debugger::SetMessageHandler(NULL);
+ }
+}
+
+
+void Debug::SetMessageHandler2(v8::Debug::MessageHandler2 handler) {
+ EnsureInitialized("v8::Debug::SetMessageHandler");
+ ENTER_V8;
i::Debugger::SetMessageHandler(handler);
}
« include/v8-debug.h ('K') | « include/v8-debug.h ('k') | src/debug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698