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

Unified Diff: Source/core/inspector/InspectorDebuggerAgent.cpp

Issue 855383002: DevTools: use async operation id instead of AsyncCallChain (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comments Created 5 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 | « Source/core/inspector/InspectorDebuggerAgent.h ('k') | Source/core/inspector/V8AsyncCallTracker.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorDebuggerAgent.cpp
diff --git a/Source/core/inspector/InspectorDebuggerAgent.cpp b/Source/core/inspector/InspectorDebuggerAgent.cpp
index f3740c47d17ff07337e305d8994ec3c22ed29cfa..4cc1ac691e3dd58c021d77e7fc169288886aab8d 100644
--- a/Source/core/inspector/InspectorDebuggerAgent.cpp
+++ b/Source/core/inspector/InspectorDebuggerAgent.cpp
@@ -92,6 +92,8 @@ static const int maxSkipStepFrameCount = 128;
const char InspectorDebuggerAgent::backtraceObjectGroup[] = "backtrace";
+const int InspectorDebuggerAgent::unknownAsyncOperationId = 0;
+
static String breakpointIdSuffix(InspectorDebuggerAgent::BreakpointSource source)
{
switch (source) {
@@ -130,6 +132,7 @@ InspectorDebuggerAgent::InspectorDebuggerAgent(InjectedScriptManager* injectedSc
, m_skipContentScripts(false)
, m_cachedSkipStackGeneration(0)
, m_promiseTracker(PromiseTracker::create())
+ , m_lastAsyncOperationId(0)
, m_maxAsyncCallStackDepth(0)
, m_currentAsyncCallChain(nullptr)
, m_nestedAsyncCallCount(0)
@@ -1061,27 +1064,27 @@ const AsyncCallChain* InspectorDebuggerAgent::currentAsyncCallChain() const
return m_currentAsyncCallChain.get();
}
-PassRefPtrWillBeRawPtr<AsyncCallChain> InspectorDebuggerAgent::traceAsyncOperationStarting(const String& description)
+int InspectorDebuggerAgent::traceAsyncOperationStarting(const String& description)
{
ScriptValue callFrames = scriptDebugServer().currentCallFramesForAsyncStack();
+ RefPtrWillBeRawPtr<AsyncCallChain> chain = nullptr;
if (callFrames.isEmpty()) {
- if (!m_currentAsyncCallChain)
- return nullptr;
- RefPtrWillBeRawPtr<AsyncCallChain> chain = AsyncCallChain::create(nullptr, m_currentAsyncCallChain.get(), m_maxAsyncCallStackDepth);
- didCreateAsyncCallChain(chain.get());
- return chain.release(); // Propagate async call stack chain.
+ if (m_currentAsyncCallChain)
+ chain = AsyncCallChain::create(nullptr, m_currentAsyncCallChain.get(), m_maxAsyncCallStackDepth);
+ } else {
+ chain = AsyncCallChain::create(adoptRefWillBeNoop(new AsyncCallStack(description, callFrames)), m_currentAsyncCallChain.get(), m_maxAsyncCallStackDepth);
}
- RefPtrWillBeRawPtr<AsyncCallChain> chain = AsyncCallChain::create(adoptRefWillBeNoop(new AsyncCallStack(description, callFrames)), m_currentAsyncCallChain.get(), m_maxAsyncCallStackDepth);
- didCreateAsyncCallChain(chain.get());
- return chain.release();
-}
-
-void InspectorDebuggerAgent::didCreateAsyncCallChain(AsyncCallChain* chain)
-{
- if (!m_performingAsyncStepIn)
- return;
- if (m_inAsyncOperationForStepInto || m_asyncOperationsForStepInto.isEmpty())
- m_asyncOperationsForStepInto.add(chain);
+ do {
+ ++m_lastAsyncOperationId;
+ if (m_lastAsyncOperationId <= 0)
+ m_lastAsyncOperationId = 1;
+ } while (m_asyncOperations.contains(m_lastAsyncOperationId));
+ m_asyncOperations.set(m_lastAsyncOperationId, chain);
aandrey 2015/01/21 12:51:27 there should be corresponding m_asyncOperations.re
yurys 2015/01/21 13:05:22 Good catch, thank you! Please take a look at the f
+ if (m_performingAsyncStepIn) {
+ if (m_inAsyncOperationForStepInto || m_asyncOperationsForStepInto.isEmpty())
+ m_asyncOperationsForStepInto.add(m_lastAsyncOperationId);
+ }
+ return m_lastAsyncOperationId;
}
void InspectorDebuggerAgent::traceAsyncCallbackCompleted()
@@ -1104,8 +1107,10 @@ void InspectorDebuggerAgent::traceAsyncCallbackCompleted()
}
}
-void InspectorDebuggerAgent::traceAsyncCallbackStarting(v8::Isolate* isolate, PassRefPtrWillBeRawPtr<AsyncCallChain> chain)
+void InspectorDebuggerAgent::traceAsyncCallbackStarting(v8::Isolate* isolate, int operationId)
{
+ ASSERT(operationId > 0 || operationId == unknownAsyncOperationId);
+ AsyncCallChain* chain = operationId > 0 ? m_asyncOperations.get(operationId) : nullptr;
int recursionLevel = V8RecursionScope::recursionLevel(isolate);
if (chain && (!recursionLevel || (recursionLevel == 1 && Microtask::performingCheckpoint(isolate)))) {
// Current AsyncCallChain corresponds to the bottommost JS call frame.
@@ -1113,7 +1118,7 @@ void InspectorDebuggerAgent::traceAsyncCallbackStarting(v8::Isolate* isolate, Pa
m_nestedAsyncCallCount = 1;
if (!m_performingAsyncStepIn)
return;
- if (!m_asyncOperationsForStepInto.contains(m_currentAsyncCallChain.get()))
+ if (!m_asyncOperationsForStepInto.contains(operationId))
return;
m_inAsyncOperationForStepInto = true;
m_scheduledDebuggerStep = StepInto;
@@ -1126,11 +1131,13 @@ void InspectorDebuggerAgent::traceAsyncCallbackStarting(v8::Isolate* isolate, Pa
}
}
-void InspectorDebuggerAgent::traceAsyncOperationCompleted(AsyncCallChain* chain)
+void InspectorDebuggerAgent::traceAsyncOperationCompleted(int operationId)
{
+ ASSERT(operationId > 0 || operationId == unknownAsyncOperationId);
if (!m_performingAsyncStepIn)
return;
- m_asyncOperationsForStepInto.remove(chain);
+ if (operationId > 0)
+ m_asyncOperationsForStepInto.remove(operationId);
if (!m_inAsyncOperationForStepInto && m_asyncOperationsForStepInto.isEmpty())
clearStepIntoAsync();
}
@@ -1141,6 +1148,7 @@ void InspectorDebuggerAgent::resetAsyncCallTracker()
m_nestedAsyncCallCount = 0;
for (auto& listener: m_asyncCallTrackingListeners)
listener->resetAsyncCallChains();
+ m_asyncOperations.clear();
}
void InspectorDebuggerAgent::scriptExecutionBlockedByCSP(const String& directiveText)
« no previous file with comments | « Source/core/inspector/InspectorDebuggerAgent.h ('k') | Source/core/inspector/V8AsyncCallTracker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698