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

Unified Diff: src/debug/debug.cc

Issue 2623313005: [inspector] introduced debug::SetAsyncTaskListener (Closed)
Patch Set: added missing header Created 3 years, 11 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
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/debug-interface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug/debug.cc
diff --git a/src/debug/debug.cc b/src/debug/debug.cc
index 05e1a2e7e47b3e24a8e9e5d9e93d19d9c595e56b..6969c06a17d752797851f4d95dd68e49b1bfb9fc 100644
--- a/src/debug/debug.cc
+++ b/src/debug/debug.cc
@@ -1859,9 +1859,31 @@ int Debug::NextAsyncTaskId(Handle<JSObject> promise) {
return async_id->value();
}
+void Debug::SetAsyncTaskListener(debug::AsyncTaskListener listener,
+ void* data) {
+ async_task_listener_ = listener;
+ async_task_listener_data_ = data;
+ UpdateState();
+}
+
void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id) {
if (in_debug_scope() || ignore_events()) return;
+ if (async_task_listener_) {
+ async_task_listener_(type, id, async_task_listener_data_);
+ // There are three types of event listeners: C++ message_handler,
+ // JavaScript event listener and C++ event listener.
+ // Currently inspector still uses C++ event listener and installs
+ // more specific event listeners for part of events. Calling of
+ // C++ event listener is redundant when more specific event listener
+ // is presented. Other clients can install JavaScript event listener
+ // (e.g. some of NodeJS module).
+ bool non_inspector_listener_exists =
+ message_handler_ != nullptr ||
+ (event_listener_.is_null() && !event_listener_->IsForeign());
+ if (!non_inspector_listener_exists) return;
+ }
+
HandleScope scope(isolate_);
DebugScope debug_scope(this);
if (debug_scope.failed()) return;
@@ -2144,7 +2166,8 @@ void Debug::SetMessageHandler(v8::Debug::MessageHandler handler) {
}
void Debug::UpdateState() {
- bool is_active = message_handler_ != NULL || !event_listener_.is_null();
+ bool is_active = message_handler_ != nullptr || !event_listener_.is_null() ||
+ async_task_listener_ != nullptr;
if (is_active || in_debug_scope()) {
// Note that the debug context could have already been loaded to
// bootstrap test cases.
« no previous file with comments | « src/debug/debug.h ('k') | src/debug/debug-interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698