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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerImpl.cpp

Issue 2197723002: [DevTools] Always instrument async tasks in V8Debugger. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 m_maxAsyncCallStackDepthMap[agent] = depth; 958 m_maxAsyncCallStackDepthMap[agent] = depth;
959 959
960 int maxAsyncCallStackDepth = 0; 960 int maxAsyncCallStackDepth = 0;
961 for (const auto& pair : m_maxAsyncCallStackDepthMap) { 961 for (const auto& pair : m_maxAsyncCallStackDepthMap) {
962 if (pair.second > maxAsyncCallStackDepth) 962 if (pair.second > maxAsyncCallStackDepth)
963 maxAsyncCallStackDepth = pair.second; 963 maxAsyncCallStackDepth = pair.second;
964 } 964 }
965 965
966 if (m_maxAsyncCallStackDepth == maxAsyncCallStackDepth) 966 if (m_maxAsyncCallStackDepth == maxAsyncCallStackDepth)
967 return; 967 return;
968
969 if (maxAsyncCallStackDepth && !m_maxAsyncCallStackDepth)
970 m_client->enableAsyncInstrumentation();
971 else if (!maxAsyncCallStackDepth && m_maxAsyncCallStackDepth)
972 m_client->disableAsyncInstrumentation();
973
974 m_maxAsyncCallStackDepth = maxAsyncCallStackDepth; 968 m_maxAsyncCallStackDepth = maxAsyncCallStackDepth;
975 if (!maxAsyncCallStackDepth) 969 if (!maxAsyncCallStackDepth)
976 allAsyncTasksCanceled(); 970 allAsyncTasksCanceled();
977 } 971 }
978 972
979 void V8DebuggerImpl::asyncTaskScheduled(const String16& taskName, void* task, bo ol recurring) 973 void V8DebuggerImpl::asyncTaskScheduled(const String16& taskName, void* task, bo ol recurring)
980 { 974 {
981 if (!m_maxAsyncCallStackDepth) 975 if (!m_maxAsyncCallStackDepth)
982 return; 976 return;
983 v8::HandleScope scope(m_isolate); 977 v8::HandleScope scope(m_isolate);
984 int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurre ntContext()) : 0; 978 int contextGroupId = m_isolate->InContext() ? getGroupId(m_isolate->GetCurre ntContext()) : 0;
985 std::unique_ptr<V8StackTraceImpl> chain = V8StackTraceImpl::capture(this, co ntextGroupId, V8StackTraceImpl::maxCallStackSizeToCapture, taskName); 979 std::unique_ptr<V8StackTraceImpl> chain = V8StackTraceImpl::capture(this, co ntextGroupId, V8StackTraceImpl::maxCallStackSizeToCapture, taskName);
986 if (chain) { 980 if (chain) {
987 m_asyncTaskStacks[task] = std::move(chain); 981 m_asyncTaskStacks[task] = std::move(chain);
988 if (recurring) 982 if (recurring)
989 m_recurringTasks.insert(task); 983 m_recurringTasks.insert(task);
990 } 984 }
991 } 985 }
992 986
993 void V8DebuggerImpl::asyncTaskCanceled(void* task) 987 void V8DebuggerImpl::asyncTaskCanceled(void* task)
994 { 988 {
995 if (!m_maxAsyncCallStackDepth) 989 if (!m_maxAsyncCallStackDepth)
996 return; 990 return;
997 m_asyncTaskStacks.erase(task); 991 m_asyncTaskStacks.erase(task);
998 m_recurringTasks.erase(task); 992 m_recurringTasks.erase(task);
999 } 993 }
1000 994
1001 void V8DebuggerImpl::asyncTaskStarted(void* task) 995 void V8DebuggerImpl::asyncTaskStarted(void* task)
1002 { 996 {
1003 // Not enabled, return.
1004 if (!m_maxAsyncCallStackDepth) 997 if (!m_maxAsyncCallStackDepth)
1005 return; 998 return;
1006
1007 m_currentTasks.push_back(task); 999 m_currentTasks.push_back(task);
1008 AsyncTaskToStackTrace::iterator stackIt = m_asyncTaskStacks.find(task); 1000 AsyncTaskToStackTrace::iterator stackIt = m_asyncTaskStacks.find(task);
1009 // Needs to support following order of events: 1001 // Needs to support following order of events:
1010 // - asyncTaskScheduled 1002 // - asyncTaskScheduled
1011 // <-- attached here --> 1003 // <-- attached here -->
1012 // - asyncTaskStarted 1004 // - asyncTaskStarted
1013 // - asyncTaskCanceled <-- canceled before finished 1005 // - asyncTaskCanceled <-- canceled before finished
1014 // <-- async stack requested here --> 1006 // <-- async stack requested here -->
1015 // - asyncTaskFinished 1007 // - asyncTaskFinished
1016 std::unique_ptr<V8StackTraceImpl> stack; 1008 std::unique_ptr<V8StackTraceImpl> stack;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 1134
1143 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI d) 1135 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI d)
1144 { 1136 {
1145 if (!contextGroupId) 1137 if (!contextGroupId)
1146 return nullptr; 1138 return nullptr;
1147 SessionMap::iterator iter = m_sessions.find(contextGroupId); 1139 SessionMap::iterator iter = m_sessions.find(contextGroupId);
1148 return iter == m_sessions.end() ? nullptr : iter->second; 1140 return iter == m_sessions.end() ? nullptr : iter->second;
1149 } 1141 }
1150 1142
1151 } // namespace blink 1143 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698