| OLD | NEW |
| 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 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 #include "src/inspector/V8InspectorImpl.h" | 31 #include "src/inspector/V8InspectorImpl.h" |
| 32 | 32 |
| 33 #include "src/inspector/InspectedContext.h" | 33 #include "src/inspector/InspectedContext.h" |
| 34 #include "src/inspector/StringUtil.h" | 34 #include "src/inspector/StringUtil.h" |
| 35 #include "src/inspector/V8ConsoleAgentImpl.h" | 35 #include "src/inspector/V8ConsoleAgentImpl.h" |
| 36 #include "src/inspector/V8ConsoleMessage.h" | 36 #include "src/inspector/V8ConsoleMessage.h" |
| 37 #include "src/inspector/V8Debugger.h" | 37 #include "src/inspector/V8Debugger.h" |
| 38 #include "src/inspector/V8DebuggerAgentImpl.h" | 38 #include "src/inspector/V8DebuggerAgentImpl.h" |
| 39 #include "src/inspector/V8InspectorSessionImpl.h" | 39 #include "src/inspector/V8InspectorSessionImpl.h" |
| 40 #include "src/inspector/V8ProfilerAgentImpl.h" |
| 40 #include "src/inspector/V8RuntimeAgentImpl.h" | 41 #include "src/inspector/V8RuntimeAgentImpl.h" |
| 41 #include "src/inspector/V8StackTraceImpl.h" | 42 #include "src/inspector/V8StackTraceImpl.h" |
| 42 #include "src/inspector/protocol/Protocol.h" | 43 #include "src/inspector/protocol/Protocol.h" |
| 43 | 44 |
| 44 #include "include/v8-profiler.h" | |
| 45 | |
| 46 namespace v8_inspector { | 45 namespace v8_inspector { |
| 47 | 46 |
| 48 std::unique_ptr<V8Inspector> V8Inspector::create(v8::Isolate* isolate, | 47 std::unique_ptr<V8Inspector> V8Inspector::create(v8::Isolate* isolate, |
| 49 V8InspectorClient* client) { | 48 V8InspectorClient* client) { |
| 50 return wrapUnique(new V8InspectorImpl(isolate, client)); | 49 return wrapUnique(new V8InspectorImpl(isolate, client)); |
| 51 } | 50 } |
| 52 | 51 |
| 53 V8InspectorImpl::V8InspectorImpl(v8::Isolate* isolate, | 52 V8InspectorImpl::V8InspectorImpl(v8::Isolate* isolate, |
| 54 V8InspectorClient* client) | 53 V8InspectorClient* client) |
| 55 : m_isolate(isolate), | 54 : m_isolate(isolate), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 67 return agent && agent->enabled() ? agent : nullptr; | 66 return agent && agent->enabled() ? agent : nullptr; |
| 68 } | 67 } |
| 69 | 68 |
| 70 V8RuntimeAgentImpl* V8InspectorImpl::enabledRuntimeAgentForGroup( | 69 V8RuntimeAgentImpl* V8InspectorImpl::enabledRuntimeAgentForGroup( |
| 71 int contextGroupId) { | 70 int contextGroupId) { |
| 72 V8InspectorSessionImpl* session = sessionForContextGroup(contextGroupId); | 71 V8InspectorSessionImpl* session = sessionForContextGroup(contextGroupId); |
| 73 V8RuntimeAgentImpl* agent = session ? session->runtimeAgent() : nullptr; | 72 V8RuntimeAgentImpl* agent = session ? session->runtimeAgent() : nullptr; |
| 74 return agent && agent->enabled() ? agent : nullptr; | 73 return agent && agent->enabled() ? agent : nullptr; |
| 75 } | 74 } |
| 76 | 75 |
| 76 V8ProfilerAgentImpl* V8InspectorImpl::enabledProfilerAgentForGroup( |
| 77 int contextGroupId) { |
| 78 V8InspectorSessionImpl* session = sessionForContextGroup(contextGroupId); |
| 79 V8ProfilerAgentImpl* agent = session ? session->profilerAgent() : nullptr; |
| 80 return agent && agent->enabled() ? agent : nullptr; |
| 81 } |
| 82 |
| 77 v8::MaybeLocal<v8::Value> V8InspectorImpl::runCompiledScript( | 83 v8::MaybeLocal<v8::Value> V8InspectorImpl::runCompiledScript( |
| 78 v8::Local<v8::Context> context, v8::Local<v8::Script> script) { | 84 v8::Local<v8::Context> context, v8::Local<v8::Script> script) { |
| 79 v8::MicrotasksScope microtasksScope(m_isolate, | 85 v8::MicrotasksScope microtasksScope(m_isolate, |
| 80 v8::MicrotasksScope::kRunMicrotasks); | 86 v8::MicrotasksScope::kRunMicrotasks); |
| 81 int groupId = V8Debugger::getGroupId(context); | 87 int groupId = V8Debugger::getGroupId(context); |
| 82 if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(groupId)) | 88 if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(groupId)) |
| 83 agent->willExecuteScript(script->GetUnboundScript()->GetId()); | 89 agent->willExecuteScript(script->GetUnboundScript()->GetId()); |
| 84 v8::MaybeLocal<v8::Value> result = script->Run(context); | 90 v8::MaybeLocal<v8::Value> result = script->Run(context); |
| 85 // Get agent from the map again, since it could have detached during script | 91 // Get agent from the map again, since it could have detached during script |
| 86 // execution. | 92 // execution. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 agent->willExecuteScript(scriptId); | 270 agent->willExecuteScript(scriptId); |
| 265 } | 271 } |
| 266 | 272 |
| 267 void V8InspectorImpl::didExecuteScript(v8::Local<v8::Context> context) { | 273 void V8InspectorImpl::didExecuteScript(v8::Local<v8::Context> context) { |
| 268 if (V8DebuggerAgentImpl* agent = | 274 if (V8DebuggerAgentImpl* agent = |
| 269 enabledDebuggerAgentForGroup(V8Debugger::getGroupId(context))) | 275 enabledDebuggerAgentForGroup(V8Debugger::getGroupId(context))) |
| 270 agent->didExecuteScript(); | 276 agent->didExecuteScript(); |
| 271 } | 277 } |
| 272 | 278 |
| 273 void V8InspectorImpl::idleStarted() { | 279 void V8InspectorImpl::idleStarted() { |
| 274 m_isolate->GetCpuProfiler()->SetIdle(true); | 280 for (auto it = m_sessions.begin(); it != m_sessions.end(); ++it) { |
| 281 if (it->second->profilerAgent()->idleStarted()) return; |
| 282 } |
| 275 } | 283 } |
| 276 | 284 |
| 277 void V8InspectorImpl::idleFinished() { | 285 void V8InspectorImpl::idleFinished() { |
| 278 m_isolate->GetCpuProfiler()->SetIdle(false); | 286 for (auto it = m_sessions.begin(); it != m_sessions.end(); ++it) { |
| 287 if (it->second->profilerAgent()->idleFinished()) return; |
| 288 } |
| 279 } | 289 } |
| 280 | 290 |
| 281 unsigned V8InspectorImpl::exceptionThrown( | 291 unsigned V8InspectorImpl::exceptionThrown( |
| 282 v8::Local<v8::Context> context, const StringView& message, | 292 v8::Local<v8::Context> context, const StringView& message, |
| 283 v8::Local<v8::Value> exception, const StringView& detailedMessage, | 293 v8::Local<v8::Value> exception, const StringView& detailedMessage, |
| 284 const StringView& url, unsigned lineNumber, unsigned columnNumber, | 294 const StringView& url, unsigned lineNumber, unsigned columnNumber, |
| 285 std::unique_ptr<V8StackTrace> stackTrace, int scriptId) { | 295 std::unique_ptr<V8StackTrace> stackTrace, int scriptId) { |
| 286 int contextGroupId = V8Debugger::getGroupId(context); | 296 int contextGroupId = V8Debugger::getGroupId(context); |
| 287 if (!contextGroupId || m_muteExceptionsMap[contextGroupId]) return 0; | 297 if (!contextGroupId || m_muteExceptionsMap[contextGroupId]) return 0; |
| 288 std::unique_ptr<V8StackTraceImpl> stackTraceImpl = | 298 std::unique_ptr<V8StackTraceImpl> stackTraceImpl = |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 } | 368 } |
| 359 | 369 |
| 360 V8InspectorSessionImpl* V8InspectorImpl::sessionForContextGroup( | 370 V8InspectorSessionImpl* V8InspectorImpl::sessionForContextGroup( |
| 361 int contextGroupId) { | 371 int contextGroupId) { |
| 362 if (!contextGroupId) return nullptr; | 372 if (!contextGroupId) return nullptr; |
| 363 SessionMap::iterator iter = m_sessions.find(contextGroupId); | 373 SessionMap::iterator iter = m_sessions.find(contextGroupId); |
| 364 return iter == m_sessions.end() ? nullptr : iter->second; | 374 return iter == m_sessions.end() ? nullptr : iter->second; |
| 365 } | 375 } |
| 366 | 376 |
| 367 } // namespace v8_inspector | 377 } // namespace v8_inspector |
| OLD | NEW |