Chromium Code Reviews| 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 17 matching lines...) Expand all Loading... | |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "platform/v8_inspector/V8DebuggerImpl.h" | 31 #include "platform/v8_inspector/V8DebuggerImpl.h" |
| 32 | 32 |
| 33 #include "platform/inspector_protocol/Values.h" | 33 #include "platform/inspector_protocol/Values.h" |
| 34 #include "platform/v8_inspector/Atomics.h" | 34 #include "platform/v8_inspector/Atomics.h" |
| 35 #include "platform/v8_inspector/DebuggerScript.h" | 35 #include "platform/v8_inspector/DebuggerScript.h" |
| 36 #include "platform/v8_inspector/InspectedContext.h" | 36 #include "platform/v8_inspector/InspectedContext.h" |
| 37 #include "platform/v8_inspector/ScriptBreakpoint.h" | 37 #include "platform/v8_inspector/ScriptBreakpoint.h" |
| 38 #include "platform/v8_inspector/V8Console.h" | |
| 38 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" | 39 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" |
| 39 #include "platform/v8_inspector/V8InspectorSessionImpl.h" | 40 #include "platform/v8_inspector/V8InspectorSessionImpl.h" |
| 41 #include "platform/v8_inspector/V8ProfilerAgentImpl.h" | |
| 40 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" | 42 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" |
| 41 #include "platform/v8_inspector/V8StackTraceImpl.h" | 43 #include "platform/v8_inspector/V8StackTraceImpl.h" |
| 42 #include "platform/v8_inspector/V8StringUtil.h" | 44 #include "platform/v8_inspector/V8StringUtil.h" |
| 43 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 45 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
| 44 | 46 |
| 45 namespace blink { | 47 namespace blink { |
| 46 | 48 |
| 47 namespace { | 49 namespace { |
| 48 const char stepIntoV8MethodName[] = "stepIntoStatement"; | 50 const char stepIntoV8MethodName[] = "stepIntoStatement"; |
| 49 const char stepOutV8MethodName[] = "stepOutOfFunction"; | 51 const char stepOutV8MethodName[] = "stepOutOfFunction"; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 if (!m_enabledAgentsCount++) | 146 if (!m_enabledAgentsCount++) |
| 145 enable(); | 147 enable(); |
| 146 } | 148 } |
| 147 | 149 |
| 148 void V8DebuggerImpl::debuggerAgentDisabled() | 150 void V8DebuggerImpl::debuggerAgentDisabled() |
| 149 { | 151 { |
| 150 if (!--m_enabledAgentsCount) | 152 if (!--m_enabledAgentsCount) |
| 151 disable(); | 153 disable(); |
| 152 } | 154 } |
| 153 | 155 |
| 156 V8ProfilerAgentImpl* V8DebuggerImpl::findEnabledProfilerAgent(v8::Local<v8::Cont ext> context) | |
| 157 { | |
| 158 int contextGroupId = getGroupId(context); | |
| 159 if (!contextGroupId) | |
| 160 return nullptr; | |
| 161 V8InspectorSessionImpl* session = m_sessions.get(contextGroupId); | |
| 162 if (session && session->profileAgentImpl()->enabled()) | |
| 163 return session->profileAgentImpl(); | |
| 164 return nullptr; | |
| 165 } | |
| 166 | |
| 154 V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(int contextGroupId ) | 167 V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(int contextGroupId ) |
| 155 { | 168 { |
| 156 if (!contextGroupId) | 169 if (!contextGroupId) |
| 157 return nullptr; | 170 return nullptr; |
| 158 V8InspectorSessionImpl* session = m_sessions.get(contextGroupId); | 171 V8InspectorSessionImpl* session = m_sessions.get(contextGroupId); |
| 159 if (session && session->debuggerAgentImpl()->enabled()) | 172 if (session && session->debuggerAgentImpl()->enabled()) |
| 160 return session->debuggerAgentImpl(); | 173 return session->debuggerAgentImpl(); |
| 161 return nullptr; | 174 return nullptr; |
| 162 } | 175 } |
| 163 | 176 |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 759 void V8DebuggerImpl::contextCreated(const V8ContextInfo& info) | 772 void V8DebuggerImpl::contextCreated(const V8ContextInfo& info) |
| 760 { | 773 { |
| 761 ASSERT(info.context->GetIsolate() == m_isolate); | 774 ASSERT(info.context->GetIsolate() == m_isolate); |
| 762 // TODO(dgozman): make s_lastContextId non-static. | 775 // TODO(dgozman): make s_lastContextId non-static. |
| 763 int contextId = atomicIncrement(&s_lastContextId); | 776 int contextId = atomicIncrement(&s_lastContextId); |
| 764 String16 debugData = String16::number(info.contextGroupId) + "," + String16: :number(contextId) + "," + (info.isDefault ? "default" : "nondefault"); | 777 String16 debugData = String16::number(info.contextGroupId) + "," + String16: :number(contextId) + "," + (info.isDefault ? "default" : "nondefault"); |
| 765 v8::HandleScope scope(m_isolate); | 778 v8::HandleScope scope(m_isolate); |
| 766 v8::Context::Scope contextScope(info.context); | 779 v8::Context::Scope contextScope(info.context); |
| 767 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), toV8String(m_isolate, debugData)); | 780 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex), toV8String(m_isolate, debugData)); |
| 768 | 781 |
| 782 installConsole(info.context, info.hasMemoryOnConsole); | |
|
dgozman
2016/04/12 03:32:16
Let's move this to InspectedContext constructor.
kozy
2016/04/12 21:58:32
Done.
| |
| 783 | |
| 769 if (!m_contexts.contains(info.contextGroupId)) | 784 if (!m_contexts.contains(info.contextGroupId)) |
| 770 m_contexts.set(info.contextGroupId, adoptPtr(new ContextByIdMap())); | 785 m_contexts.set(info.contextGroupId, adoptPtr(new ContextByIdMap())); |
| 771 ASSERT(!m_contexts.get(info.contextGroupId)->contains(contextId)); | 786 ASSERT(!m_contexts.get(info.contextGroupId)->contains(contextId)); |
| 772 | 787 |
| 773 OwnPtr<InspectedContext> contextOwner = adoptPtr(new InspectedContext(this, info, contextId)); | 788 OwnPtr<InspectedContext> contextOwner = adoptPtr(new InspectedContext(this, info, contextId)); |
| 774 InspectedContext* inspectedContext = contextOwner.get(); | 789 InspectedContext* inspectedContext = contextOwner.get(); |
| 775 m_contexts.get(info.contextGroupId)->set(contextId, contextOwner.release()); | 790 m_contexts.get(info.contextGroupId)->set(contextId, contextOwner.release()); |
| 776 | 791 |
| 777 if (V8InspectorSessionImpl* session = m_sessions.get(info.contextGroupId)) | 792 if (V8InspectorSessionImpl* session = m_sessions.get(info.contextGroupId)) |
| 778 session->runtimeAgentImpl()->reportExecutionContextCreated(inspectedCont ext); | 793 session->runtimeAgentImpl()->reportExecutionContextCreated(inspectedCont ext); |
| 779 } | 794 } |
| 780 | 795 |
| 796 bool V8DebuggerImpl::installConsole(v8::Local<v8::Context> context, bool hasMemo ryAttribute) | |
| 797 { | |
| 798 v8::Isolate* isolate = context->GetIsolate(); | |
| 799 v8::Local<v8::Object> global = context->Global(); | |
| 800 v8::Local<v8::Object> console; | |
| 801 if (!V8Console::create(context, this, hasMemoryAttribute).ToLocal(&console)) | |
| 802 return false; | |
| 803 return global->Set(context, toV8StringInternalized(isolate, "console"), cons ole).FromMaybe(false); | |
| 804 } | |
| 805 | |
| 781 void V8DebuggerImpl::contextDestroyed(v8::Local<v8::Context> context) | 806 void V8DebuggerImpl::contextDestroyed(v8::Local<v8::Context> context) |
| 782 { | 807 { |
| 783 int contextId = V8Debugger::contextId(context); | 808 int contextId = V8Debugger::contextId(context); |
| 784 int contextGroupId = getGroupId(context); | 809 int contextGroupId = getGroupId(context); |
| 785 if (!m_contexts.contains(contextGroupId) || !m_contexts.get(contextGroupId)- >contains(contextId)) | 810 if (!m_contexts.contains(contextGroupId) || !m_contexts.get(contextGroupId)- >contains(contextId)) |
| 786 return; | 811 return; |
| 787 | 812 |
| 788 InspectedContext* inspectedContext = m_contexts.get(contextGroupId)->get(con textId); | 813 InspectedContext* inspectedContext = m_contexts.get(contextGroupId)->get(con textId); |
| 789 if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId)) | 814 if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId)) |
| 790 session->runtimeAgentImpl()->reportExecutionContextDestroyed(inspectedCo ntext); | 815 session->runtimeAgentImpl()->reportExecutionContextDestroyed(inspectedCo ntext); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 824 } | 849 } |
| 825 | 850 |
| 826 const V8DebuggerImpl::ContextByIdMap* V8DebuggerImpl::contextGroup(int contextGr oupId) | 851 const V8DebuggerImpl::ContextByIdMap* V8DebuggerImpl::contextGroup(int contextGr oupId) |
| 827 { | 852 { |
| 828 if (!m_contexts.contains(contextGroupId)) | 853 if (!m_contexts.contains(contextGroupId)) |
| 829 return nullptr; | 854 return nullptr; |
| 830 return m_contexts.get(contextGroupId); | 855 return m_contexts.get(contextGroupId); |
| 831 } | 856 } |
| 832 | 857 |
| 833 } // namespace blink | 858 } // namespace blink |
| OLD | NEW |