| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 | 62 |
| 63 v8::MaybeLocal<v8::Value> V8DebuggerImpl::callDebuggerMethod(const char* functio
nName, int argc, v8::Local<v8::Value> argv[]) | 63 v8::MaybeLocal<v8::Value> V8DebuggerImpl::callDebuggerMethod(const char* functio
nName, int argc, v8::Local<v8::Value> argv[]) |
| 64 { | 64 { |
| 65 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); | 65 v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope::kDoNotRunMicr
otasks); |
| 66 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); | 66 v8::Local<v8::Object> debuggerScript = m_debuggerScript.Get(m_isolate); |
| 67 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScr
ipt->Get(v8InternalizedString(functionName))); | 67 v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(debuggerScr
ipt->Get(v8InternalizedString(functionName))); |
| 68 DCHECK(m_isolate->InContext()); | 68 DCHECK(m_isolate->InContext()); |
| 69 return function->Call(m_isolate->GetCurrentContext(), debuggerScript, argc,
argv); | 69 return function->Call(m_isolate->GetCurrentContext(), debuggerScript, argc,
argv); |
| 70 } | 70 } |
| 71 | 71 |
| 72 PassOwnPtr<V8Debugger> V8Debugger::create(v8::Isolate* isolate, V8DebuggerClient
* client) | 72 std::unique_ptr<V8Debugger> V8Debugger::create(v8::Isolate* isolate, V8DebuggerC
lient* client) |
| 73 { | 73 { |
| 74 return adoptPtr(new V8DebuggerImpl(isolate, client)); | 74 return wrapUnique(new V8DebuggerImpl(isolate, client)); |
| 75 } | 75 } |
| 76 | 76 |
| 77 V8DebuggerImpl::V8DebuggerImpl(v8::Isolate* isolate, V8DebuggerClient* client) | 77 V8DebuggerImpl::V8DebuggerImpl(v8::Isolate* isolate, V8DebuggerClient* client) |
| 78 : m_isolate(isolate) | 78 : m_isolate(isolate) |
| 79 , m_client(client) | 79 , m_client(client) |
| 80 , m_enabledAgentsCount(0) | 80 , m_enabledAgentsCount(0) |
| 81 , m_breakpointsActivated(true) | 81 , m_breakpointsActivated(true) |
| 82 , m_runningNestedMessageLoop(false) | 82 , m_runningNestedMessageLoop(false) |
| 83 { | 83 { |
| 84 } | 84 } |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 v8::Debug::SetLiveEditEnabled(m_isolate, false); | 365 v8::Debug::SetLiveEditEnabled(m_isolate, false); |
| 366 inLiveEditScope = false; | 366 inLiveEditScope = false; |
| 367 } | 367 } |
| 368 private: | 368 private: |
| 369 v8::Isolate* m_isolate; | 369 v8::Isolate* m_isolate; |
| 370 }; | 370 }; |
| 371 | 371 |
| 372 DCHECK(enabled()); | 372 DCHECK(enabled()); |
| 373 v8::HandleScope scope(m_isolate); | 373 v8::HandleScope scope(m_isolate); |
| 374 | 374 |
| 375 OwnPtr<v8::Context::Scope> contextScope; | 375 std::unique_ptr<v8::Context::Scope> contextScope; |
| 376 if (!isPaused()) | 376 if (!isPaused()) |
| 377 contextScope = adoptPtr(new v8::Context::Scope(debuggerContext())); | 377 contextScope = wrapUnique(new v8::Context::Scope(debuggerContext())); |
| 378 | 378 |
| 379 v8::Local<v8::Value> argv[] = { toV8String(m_isolate, sourceID), toV8String(
m_isolate, newContent), v8Boolean(preview, m_isolate) }; | 379 v8::Local<v8::Value> argv[] = { toV8String(m_isolate, sourceID), toV8String(
m_isolate, newContent), v8Boolean(preview, m_isolate) }; |
| 380 | 380 |
| 381 v8::Local<v8::Value> v8result; | 381 v8::Local<v8::Value> v8result; |
| 382 { | 382 { |
| 383 EnableLiveEditScope enableLiveEditScope(m_isolate); | 383 EnableLiveEditScope enableLiveEditScope(m_isolate); |
| 384 v8::TryCatch tryCatch(m_isolate); | 384 v8::TryCatch tryCatch(m_isolate); |
| 385 tryCatch.SetVerbose(false); | 385 tryCatch.SetVerbose(false); |
| 386 v8::MaybeLocal<v8::Value> maybeResult = callDebuggerMethod("liveEditScri
ptSource", 3, argv); | 386 v8::MaybeLocal<v8::Value> maybeResult = callDebuggerMethod("liveEditScri
ptSource", 3, argv); |
| 387 if (tryCatch.HasCaught()) { | 387 if (tryCatch.HasCaught()) { |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 v8::True(m_isolate), // internal | 718 v8::True(m_isolate), // internal |
| 719 toV8String(m_isolate, String16()), // sourceMap | 719 toV8String(m_isolate, String16()), // sourceMap |
| 720 v8::True(m_isolate)); // opaqueresource | 720 v8::True(m_isolate)); // opaqueresource |
| 721 v8::ScriptCompiler::Source source(code, origin); | 721 v8::ScriptCompiler::Source source(code, origin); |
| 722 v8::Local<v8::Script> script; | 722 v8::Local<v8::Script> script; |
| 723 if (!v8::ScriptCompiler::Compile(context, &source, v8::ScriptCompiler::kNoCo
mpileOptions).ToLocal(&script)) | 723 if (!v8::ScriptCompiler::Compile(context, &source, v8::ScriptCompiler::kNoCo
mpileOptions).ToLocal(&script)) |
| 724 return v8::Local<v8::Script>(); | 724 return v8::Local<v8::Script>(); |
| 725 return script; | 725 return script; |
| 726 } | 726 } |
| 727 | 727 |
| 728 PassOwnPtr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTra
ce> stackTrace, size_t maxStackSize) | 728 std::unique_ptr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::Sta
ckTrace> stackTrace, size_t maxStackSize) |
| 729 { | 729 { |
| 730 V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(m_isolate->GetCurrentC
ontext()); | 730 V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(m_isolate->GetCurrentC
ontext()); |
| 731 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize); | 731 return V8StackTraceImpl::create(agent, stackTrace, maxStackSize); |
| 732 } | 732 } |
| 733 | 733 |
| 734 PassOwnPtr<V8InspectorSession> V8DebuggerImpl::connect(int contextGroupId, V8Ins
pectorSessionClient* client, const String16* state) | 734 std::unique_ptr<V8InspectorSession> V8DebuggerImpl::connect(int contextGroupId,
V8InspectorSessionClient* client, const String16* state) |
| 735 { | 735 { |
| 736 DCHECK(!m_sessions.contains(contextGroupId)); | 736 DCHECK(!m_sessions.contains(contextGroupId)); |
| 737 OwnPtr<V8InspectorSessionImpl> session = V8InspectorSessionImpl::create(this
, contextGroupId, client, state); | 737 std::unique_ptr<V8InspectorSessionImpl> session = V8InspectorSessionImpl::cr
eate(this, contextGroupId, client, state); |
| 738 m_sessions.set(contextGroupId, session.get()); | 738 m_sessions.set(contextGroupId, session.get()); |
| 739 return std::move(session); | 739 return std::move(session); |
| 740 } | 740 } |
| 741 | 741 |
| 742 void V8DebuggerImpl::disconnect(V8InspectorSessionImpl* session) | 742 void V8DebuggerImpl::disconnect(V8InspectorSessionImpl* session) |
| 743 { | 743 { |
| 744 DCHECK(m_sessions.contains(session->contextGroupId())); | 744 DCHECK(m_sessions.contains(session->contextGroupId())); |
| 745 m_sessions.remove(session->contextGroupId()); | 745 m_sessions.remove(session->contextGroupId()); |
| 746 } | 746 } |
| 747 | 747 |
| 748 void V8DebuggerImpl::contextCreated(const V8ContextInfo& info) | 748 void V8DebuggerImpl::contextCreated(const V8ContextInfo& info) |
| 749 { | 749 { |
| 750 DCHECK(info.context->GetIsolate() == m_isolate); | 750 DCHECK(info.context->GetIsolate() == m_isolate); |
| 751 // TODO(dgozman): make s_lastContextId non-static. | 751 // TODO(dgozman): make s_lastContextId non-static. |
| 752 int contextId = atomicIncrement(&s_lastContextId); | 752 int contextId = atomicIncrement(&s_lastContextId); |
| 753 String16 debugData = String16::number(info.contextGroupId) + "," + String16:
:number(contextId) + "," + (info.isDefault ? "default" : "nondefault"); | 753 String16 debugData = String16::number(info.contextGroupId) + "," + String16:
:number(contextId) + "," + (info.isDefault ? "default" : "nondefault"); |
| 754 v8::HandleScope scope(m_isolate); | 754 v8::HandleScope scope(m_isolate); |
| 755 v8::Context::Scope contextScope(info.context); | 755 v8::Context::Scope contextScope(info.context); |
| 756 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex),
toV8String(m_isolate, debugData)); | 756 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex),
toV8String(m_isolate, debugData)); |
| 757 | 757 |
| 758 if (!m_contexts.contains(info.contextGroupId)) | 758 if (!m_contexts.contains(info.contextGroupId)) |
| 759 m_contexts.set(info.contextGroupId, adoptPtr(new ContextByIdMap())); | 759 m_contexts.set(info.contextGroupId, wrapUnique(new ContextByIdMap())); |
| 760 DCHECK(!m_contexts.get(info.contextGroupId)->contains(contextId)); | 760 DCHECK(!m_contexts.get(info.contextGroupId)->contains(contextId)); |
| 761 | 761 |
| 762 OwnPtr<InspectedContext> contextOwner = adoptPtr(new InspectedContext(this,
info, contextId)); | 762 std::unique_ptr<InspectedContext> contextOwner(new InspectedContext(this, in
fo, contextId)); |
| 763 InspectedContext* inspectedContext = contextOwner.get(); | 763 InspectedContext* inspectedContext = contextOwner.get(); |
| 764 m_contexts.get(info.contextGroupId)->set(contextId, std::move(contextOwner))
; | 764 m_contexts.get(info.contextGroupId)->set(contextId, std::move(contextOwner))
; |
| 765 | 765 |
| 766 if (V8InspectorSessionImpl* session = m_sessions.get(info.contextGroupId)) | 766 if (V8InspectorSessionImpl* session = m_sessions.get(info.contextGroupId)) |
| 767 session->runtimeAgent()->reportExecutionContextCreated(inspectedContext)
; | 767 session->runtimeAgent()->reportExecutionContextCreated(inspectedContext)
; |
| 768 } | 768 } |
| 769 | 769 |
| 770 void V8DebuggerImpl::contextDestroyed(v8::Local<v8::Context> context) | 770 void V8DebuggerImpl::contextDestroyed(v8::Local<v8::Context> context) |
| 771 { | 771 { |
| 772 int contextId = V8Debugger::contextId(context); | 772 int contextId = V8Debugger::contextId(context); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 void V8DebuggerImpl::idleStarted() | 805 void V8DebuggerImpl::idleStarted() |
| 806 { | 806 { |
| 807 m_isolate->GetCpuProfiler()->SetIdle(true); | 807 m_isolate->GetCpuProfiler()->SetIdle(true); |
| 808 } | 808 } |
| 809 | 809 |
| 810 void V8DebuggerImpl::idleFinished() | 810 void V8DebuggerImpl::idleFinished() |
| 811 { | 811 { |
| 812 m_isolate->GetCpuProfiler()->SetIdle(false); | 812 m_isolate->GetCpuProfiler()->SetIdle(false); |
| 813 } | 813 } |
| 814 | 814 |
| 815 PassOwnPtr<V8StackTrace> V8DebuggerImpl::captureStackTrace(size_t maxStackSize) | 815 std::unique_ptr<V8StackTrace> V8DebuggerImpl::captureStackTrace(size_t maxStackS
ize) |
| 816 { | 816 { |
| 817 V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(m_isolate->GetCurrentC
ontext()); | 817 V8DebuggerAgentImpl* agent = findEnabledDebuggerAgent(m_isolate->GetCurrentC
ontext()); |
| 818 return V8StackTraceImpl::capture(agent, maxStackSize); | 818 return V8StackTraceImpl::capture(agent, maxStackSize); |
| 819 } | 819 } |
| 820 | 820 |
| 821 v8::Local<v8::Context> V8DebuggerImpl::regexContext() | 821 v8::Local<v8::Context> V8DebuggerImpl::regexContext() |
| 822 { | 822 { |
| 823 if (m_regexContext.IsEmpty()) | 823 if (m_regexContext.IsEmpty()) |
| 824 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); | 824 m_regexContext.Reset(m_isolate, v8::Context::New(m_isolate)); |
| 825 return m_regexContext.Get(m_isolate); | 825 return m_regexContext.Get(m_isolate); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 840 return nullptr; | 840 return nullptr; |
| 841 return m_contexts.get(contextGroupId); | 841 return m_contexts.get(contextGroupId); |
| 842 } | 842 } |
| 843 | 843 |
| 844 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI
d) | 844 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI
d) |
| 845 { | 845 { |
| 846 return contextGroupId ? m_sessions.get(contextGroupId) : nullptr; | 846 return contextGroupId ? m_sessions.get(contextGroupId) : nullptr; |
| 847 } | 847 } |
| 848 | 848 |
| 849 } // namespace blink | 849 } // namespace blink |
| OLD | NEW |