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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 return agent && agent->enabled() ? agent : nullptr; | 83 return agent && agent->enabled() ? agent : nullptr; |
84 } | 84 } |
85 | 85 |
86 V8ProfilerAgentImpl* V8InspectorImpl::enabledProfilerAgentForGroup( | 86 V8ProfilerAgentImpl* V8InspectorImpl::enabledProfilerAgentForGroup( |
87 int contextGroupId) { | 87 int contextGroupId) { |
88 V8InspectorSessionImpl* session = sessionForContextGroup(contextGroupId); | 88 V8InspectorSessionImpl* session = sessionForContextGroup(contextGroupId); |
89 V8ProfilerAgentImpl* agent = session ? session->profilerAgent() : nullptr; | 89 V8ProfilerAgentImpl* agent = session ? session->profilerAgent() : nullptr; |
90 return agent && agent->enabled() ? agent : nullptr; | 90 return agent && agent->enabled() ? agent : nullptr; |
91 } | 91 } |
92 | 92 |
93 v8::MaybeLocal<v8::Value> V8InspectorImpl::runCompiledScript( | |
94 v8::Local<v8::Context> context, v8::Local<v8::Script> script) { | |
95 v8::MicrotasksScope microtasksScope(m_isolate, | |
96 v8::MicrotasksScope::kRunMicrotasks); | |
97 int groupId = contextGroupId(context); | |
98 if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(groupId)) | |
99 agent->willExecuteScript(script->GetUnboundScript()->GetId()); | |
100 v8::MaybeLocal<v8::Value> result = script->Run(context); | |
101 // Get agent from the map again, since it could have detached during script | |
102 // execution. | |
103 if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(groupId)) | |
104 agent->didExecuteScript(); | |
105 return result; | |
106 } | |
107 | |
108 v8::MaybeLocal<v8::Value> V8InspectorImpl::callFunction( | |
109 v8::Local<v8::Function> function, v8::Local<v8::Context> context, | |
110 v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) { | |
111 return callFunction(function, context, receiver, argc, info, | |
112 v8::MicrotasksScope::kRunMicrotasks); | |
113 } | |
114 | |
115 v8::MaybeLocal<v8::Value> V8InspectorImpl::callInternalFunction( | |
116 v8::Local<v8::Function> function, v8::Local<v8::Context> context, | |
117 v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[]) { | |
118 return callFunction(function, context, receiver, argc, info, | |
119 v8::MicrotasksScope::kDoNotRunMicrotasks); | |
120 } | |
121 | |
122 v8::MaybeLocal<v8::Value> V8InspectorImpl::callFunction( | |
123 v8::Local<v8::Function> function, v8::Local<v8::Context> context, | |
124 v8::Local<v8::Value> receiver, int argc, v8::Local<v8::Value> info[], | |
125 v8::MicrotasksScope::Type runMicrotasks) { | |
126 v8::MicrotasksScope microtasksScope(m_isolate, runMicrotasks); | |
127 int groupId = contextGroupId(context); | |
128 if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(groupId)) | |
129 agent->willExecuteScript(function->ScriptId()); | |
130 v8::MaybeLocal<v8::Value> result = | |
131 function->Call(context, receiver, argc, info); | |
132 // Get agent from the map again, since it could have detached during script | |
133 // execution. | |
134 if (V8DebuggerAgentImpl* agent = enabledDebuggerAgentForGroup(groupId)) | |
135 agent->didExecuteScript(); | |
136 return result; | |
137 } | |
138 | |
139 v8::MaybeLocal<v8::Value> V8InspectorImpl::compileAndRunInternalScript( | 93 v8::MaybeLocal<v8::Value> V8InspectorImpl::compileAndRunInternalScript( |
140 v8::Local<v8::Context> context, v8::Local<v8::String> source) { | 94 v8::Local<v8::Context> context, v8::Local<v8::String> source) { |
141 v8::Local<v8::UnboundScript> unboundScript; | 95 v8::Local<v8::UnboundScript> unboundScript; |
142 if (!v8::debug::CompileInspectorScript(m_isolate, source) | 96 if (!v8::debug::CompileInspectorScript(m_isolate, source) |
143 .ToLocal(&unboundScript)) | 97 .ToLocal(&unboundScript)) |
144 return v8::MaybeLocal<v8::Value>(); | 98 return v8::MaybeLocal<v8::Value>(); |
145 v8::MicrotasksScope microtasksScope(m_isolate, | 99 v8::MicrotasksScope microtasksScope(m_isolate, |
146 v8::MicrotasksScope::kDoNotRunMicrotasks); | 100 v8::MicrotasksScope::kDoNotRunMicrotasks); |
147 v8::Context::Scope contextScope(context); | 101 v8::Context::Scope contextScope(context); |
148 return unboundScript->BindToCurrentContext()->Run(context); | 102 return unboundScript->BindToCurrentContext()->Run(context); |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 m_consoleStorageMap.erase(contextGroupId); | 234 m_consoleStorageMap.erase(contextGroupId); |
281 m_muteExceptionsMap.erase(contextGroupId); | 235 m_muteExceptionsMap.erase(contextGroupId); |
282 SessionMap::iterator session = m_sessions.find(contextGroupId); | 236 SessionMap::iterator session = m_sessions.find(contextGroupId); |
283 if (session != m_sessions.end()) session->second->reset(); | 237 if (session != m_sessions.end()) session->second->reset(); |
284 m_contexts.erase(contextGroupId); | 238 m_contexts.erase(contextGroupId); |
285 m_debugger->wasmTranslation()->Clear(); | 239 m_debugger->wasmTranslation()->Clear(); |
286 } | 240 } |
287 | 241 |
288 void V8InspectorImpl::willExecuteScript(v8::Local<v8::Context> context, | 242 void V8InspectorImpl::willExecuteScript(v8::Local<v8::Context> context, |
289 int scriptId) { | 243 int scriptId) { |
290 if (V8DebuggerAgentImpl* agent = | |
291 enabledDebuggerAgentForGroup(contextGroupId(context))) { | |
292 agent->willExecuteScript(scriptId); | |
293 } | |
294 } | 244 } |
295 | 245 |
296 void V8InspectorImpl::didExecuteScript(v8::Local<v8::Context> context) { | 246 void V8InspectorImpl::didExecuteScript(v8::Local<v8::Context> context) { |
297 if (V8DebuggerAgentImpl* agent = | |
298 enabledDebuggerAgentForGroup(contextGroupId(context))) { | |
299 agent->didExecuteScript(); | |
300 } | |
301 } | 247 } |
302 | 248 |
303 void V8InspectorImpl::idleStarted() { | 249 void V8InspectorImpl::idleStarted() { |
304 for (auto it = m_sessions.begin(); it != m_sessions.end(); ++it) { | 250 for (auto it = m_sessions.begin(); it != m_sessions.end(); ++it) { |
305 if (it->second->profilerAgent()->idleStarted()) return; | 251 if (it->second->profilerAgent()->idleStarted()) return; |
306 } | 252 } |
307 } | 253 } |
308 | 254 |
309 void V8InspectorImpl::idleFinished() { | 255 void V8InspectorImpl::idleFinished() { |
310 for (auto it = m_sessions.begin(); it != m_sessions.end(); ++it) { | 256 for (auto it = m_sessions.begin(); it != m_sessions.end(); ++it) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 } | 336 } |
391 | 337 |
392 V8InspectorSessionImpl* V8InspectorImpl::sessionForContextGroup( | 338 V8InspectorSessionImpl* V8InspectorImpl::sessionForContextGroup( |
393 int contextGroupId) { | 339 int contextGroupId) { |
394 if (!contextGroupId) return nullptr; | 340 if (!contextGroupId) return nullptr; |
395 SessionMap::iterator iter = m_sessions.find(contextGroupId); | 341 SessionMap::iterator iter = m_sessions.find(contextGroupId); |
396 return iter == m_sessions.end() ? nullptr : iter->second; | 342 return iter == m_sessions.end() ? nullptr : iter->second; |
397 } | 343 } |
398 | 344 |
399 } // namespace v8_inspector | 345 } // namespace v8_inspector |
OLD | NEW |