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

Unified Diff: src/debug/debug.cc

Issue 2623313005: [inspector] introduced debug::SetAsyncTaskListener (Closed)
Patch Set: fixed compilation 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
Index: src/debug/debug.cc
diff --git a/src/debug/debug.cc b/src/debug/debug.cc
index 7fbcbfd49fa3d6210a6fab4a49b71a58bca58aaf..c92900abd6d0ec06c7f3410c070993a34d5b7c02 100644
--- a/src/debug/debug.cc
+++ b/src/debug/debug.cc
@@ -1682,11 +1682,11 @@ MaybeHandle<Object> Debug::MakeCompileEvent(Handle<Script> script,
return CallFunction("MakeCompileEvent", arraysize(argv), argv);
}
-MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<Smi> type, Handle<Smi> id,
- Handle<Smi> name) {
+MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<Smi> type,
+ Handle<Smi> id) {
DCHECK(id->IsNumber());
// Create the async task event object.
- Handle<Object> argv[] = {type, id, name};
+ Handle<Object> argv[] = {type, id};
return CallFunction("MakeAsyncTaskEvent", arraysize(argv), argv);
}
@@ -1821,8 +1821,7 @@ void SendAsyncTaskEventCancel(const v8::WeakCallbackInfo<void>& info) {
reinterpret_cast<CollectedCallbackData*>(info.GetParameter()));
if (!data->debug->is_active()) return;
HandleScope scope(data->isolate);
- data->debug->OnAsyncTaskEvent(debug::kDebugCancel, data->id,
- kDebugPromiseCollected);
+ data->debug->OnAsyncTaskEvent(debug::kDebugPromiseCollected, data->id);
}
void ResetPromiseHandle(const v8::WeakCallbackInfo<void>& info) {
@@ -1860,10 +1859,24 @@ int Debug::NextAsyncTaskId(Handle<JSObject> promise) {
return async_id->value();
}
-void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id,
- PromiseDebugActionName name) {
+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_);
+ bool only_foreign_listener_present =
jgruber 2017/01/13 16:38:38 Not sure this was what dgozman@ intended in his pr
kozy 2017/01/13 17:05:08 added comment and renamed variable.
+ message_handler_ == nullptr &&
+ (event_listener_.is_null() || event_listener_->IsForeign());
+ if (only_foreign_listener_present) return;
+ }
+
HandleScope scope(isolate_);
DebugScope debug_scope(this);
if (debug_scope.failed()) return;
@@ -1872,8 +1885,7 @@ void Debug::OnAsyncTaskEvent(debug::PromiseDebugActionType type, int id,
Handle<Object> event_data;
// Bail out and don't call debugger if exception.
if (!MakeAsyncTaskEvent(handle(Smi::FromInt(type), isolate_),
- handle(Smi::FromInt(id), isolate_),
- handle(Smi::FromInt(name), isolate_))
+ handle(Smi::FromInt(id), isolate_))
.ToHandle(&event_data))
return;
@@ -2147,7 +2159,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_ != NULL || !event_listener_.is_null() ||
jgruber 2017/01/13 16:38:38 Nit: You could replace the other NULL here while y
kozy 2017/01/13 17:05:08 Done.
+ async_task_listener_ != nullptr;
if (is_active || in_debug_scope()) {
// Note that the debug context could have already been loaded to
// bootstrap test cases.

Powered by Google App Engine
This is Rietveld 408576698