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

Unified Diff: src/inspector/v8-debugger.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/inspector/v8-debugger.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/inspector/v8-debugger.cc
diff --git a/src/inspector/v8-debugger.cc b/src/inspector/v8-debugger.cc
index 95605d0ce98a34af51b6abd92877e05b04ec7de2..39cc556fb920bebb164c7b077e7aef6e340dd837 100644
--- a/src/inspector/v8-debugger.cc
+++ b/src/inspector/v8-debugger.cc
@@ -70,6 +70,8 @@ void V8Debugger::enable() {
v8::HandleScope scope(m_isolate);
v8::debug::SetDebugEventListener(m_isolate, &V8Debugger::v8DebugEventCallback,
v8::External::New(m_isolate, this));
+ v8::debug::SetAsyncTaskListener(m_isolate, &V8Debugger::v8AsyncTaskListener,
+ this);
m_debuggerContext.Reset(m_isolate, v8::debug::GetDebugContext(m_isolate));
v8::debug::ChangeBreakOnException(m_isolate, v8::debug::NoBreakOnException);
m_pauseOnExceptionsState = v8::debug::NoBreakOnException;
@@ -85,6 +87,7 @@ void V8Debugger::disable() {
allAsyncTasksCanceled();
m_wasmTranslation.Clear();
v8::debug::SetDebugEventListener(m_isolate, nullptr);
+ v8::debug::SetAsyncTaskListener(m_isolate, nullptr, nullptr);
}
bool V8Debugger::enabled() const { return !m_debuggerScript.IsEmpty(); }
@@ -533,16 +536,10 @@ void V8Debugger::handleV8DebugEvent(
v8::HandleScope scope(m_isolate);
v8::DebugEvent event = eventDetails.GetEvent();
- if (event != v8::AsyncTaskEvent && event != v8::Break &&
- event != v8::Exception && event != v8::AfterCompile &&
- event != v8::CompileError)
+ if (event != v8::Break && event != v8::Exception &&
+ event != v8::AfterCompile && event != v8::CompileError)
return;
- if (event == v8::AsyncTaskEvent) {
- handleV8AsyncTaskEvent(eventDetails.GetEventData());
- return;
- }
-
v8::Local<v8::Context> eventContext = eventDetails.GetEventContext();
DCHECK(!eventContext.IsEmpty());
V8DebuggerAgentImpl* agent = m_inspector->enabledDebuggerAgentForGroup(
@@ -596,52 +593,35 @@ void V8Debugger::handleV8DebugEvent(
}
}
-void V8Debugger::handleV8AsyncTaskEvent(v8::Local<v8::Object> eventData) {
- if (!m_maxAsyncCallStackDepth) return;
-
- // TODO(kozyatinskiy): remove usage of current context as soon as async event
- // is migrated to pure C++ API.
- v8::debug::PromiseDebugActionType type =
- static_cast<v8::debug::PromiseDebugActionType>(
- eventData
- ->Get(m_isolate->GetCurrentContext(),
- toV8StringInternalized(m_isolate, "type_"))
- .ToLocalChecked()
- ->ToInteger(m_isolate->GetCurrentContext())
- .ToLocalChecked()
- ->Value());
- int id = static_cast<int>(eventData
- ->Get(m_isolate->GetCurrentContext(),
- toV8StringInternalized(m_isolate, "id_"))
- .ToLocalChecked()
- ->ToInteger(m_isolate->GetCurrentContext())
- .ToLocalChecked()
- ->Value());
+void V8Debugger::v8AsyncTaskListener(v8::debug::PromiseDebugActionType type,
+ int id, void* data) {
+ V8Debugger* debugger = static_cast<V8Debugger*>(data);
+ if (!debugger->m_maxAsyncCallStackDepth) return;
// Async task events from Promises are given misaligned pointers to prevent
// from overlapping with other Blink task identifiers. There is a single
// namespace of such ids, managed by src/js/promise.js.
void* ptr = reinterpret_cast<void*>(id * 2 + 1);
switch (type) {
case v8::debug::kDebugEnqueueAsyncFunction:
- asyncTaskScheduled("async function", ptr, true);
+ debugger->asyncTaskScheduled("async function", ptr, true);
break;
case v8::debug::kDebugEnqueuePromiseResolve:
- asyncTaskScheduled("Promise.resolve", ptr, true);
+ debugger->asyncTaskScheduled("Promise.resolve", ptr, true);
break;
case v8::debug::kDebugEnqueuePromiseReject:
- asyncTaskScheduled("Promise.reject", ptr, true);
+ debugger->asyncTaskScheduled("Promise.reject", ptr, true);
break;
case v8::debug::kDebugEnqueuePromiseResolveThenableJob:
- asyncTaskScheduled("PromiseResolveThenableJob", ptr, true);
+ debugger->asyncTaskScheduled("PromiseResolveThenableJob", ptr, true);
break;
case v8::debug::kDebugPromiseCollected:
- asyncTaskCanceled(ptr);
+ debugger->asyncTaskCanceled(ptr);
break;
case v8::debug::kDebugWillHandle:
- asyncTaskStarted(ptr);
+ debugger->asyncTaskStarted(ptr);
break;
case v8::debug::kDebugDidHandle:
- asyncTaskFinished(ptr);
+ debugger->asyncTaskFinished(ptr);
break;
}
}
« no previous file with comments | « src/inspector/v8-debugger.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698