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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 { | 151 { |
152 if (!--m_enabledAgentsCount) | 152 if (!--m_enabledAgentsCount) |
153 disable(); | 153 disable(); |
154 } | 154 } |
155 | 155 |
156 V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(int contextGroupId
) | 156 V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(int contextGroupId
) |
157 { | 157 { |
158 if (!contextGroupId) | 158 if (!contextGroupId) |
159 return nullptr; | 159 return nullptr; |
160 V8InspectorSessionImpl* session = m_sessions.get(contextGroupId); | 160 V8InspectorSessionImpl* session = m_sessions.get(contextGroupId); |
161 if (session && session->debuggerAgentImpl()->enabled()) | 161 if (session && session->debuggerAgent()->enabled()) |
162 return session->debuggerAgentImpl(); | 162 return session->debuggerAgent(); |
163 return nullptr; | 163 return nullptr; |
164 } | 164 } |
165 | 165 |
166 V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(v8::Local<v8::Cont
ext> context) | 166 V8DebuggerAgentImpl* V8DebuggerImpl::findEnabledDebuggerAgent(v8::Local<v8::Cont
ext> context) |
167 { | 167 { |
168 return findEnabledDebuggerAgent(getGroupId(context)); | 168 return findEnabledDebuggerAgent(getGroupId(context)); |
169 } | 169 } |
170 | 170 |
171 void V8DebuggerImpl::getCompiledScripts(int contextGroupId, protocol::Vector<V8D
ebuggerParsedScript>& result) | 171 void V8DebuggerImpl::getCompiledScripts(int contextGroupId, protocol::Vector<V8D
ebuggerParsedScript>& result) |
172 { | 172 { |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 PassOwnPtr<V8StackTrace> V8DebuggerImpl::createStackTrace(v8::Local<v8::StackTra
ce> 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) | 734 PassOwnPtr<V8InspectorSession> V8DebuggerImpl::connect(int contextGroupId, V8Ins
pectorSessionClient* 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); | 737 OwnPtr<V8InspectorSessionImpl> session = V8InspectorSessionImpl::create(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, adoptPtr(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 OwnPtr<InspectedContext> contextOwner = adoptPtr(new InspectedContext(this,
info, 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->runtimeAgentImpl()->reportExecutionContextCreated(inspectedCont
ext); | 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); |
773 int contextGroupId = getGroupId(context); | 773 int contextGroupId = getGroupId(context); |
774 if (!m_contexts.contains(contextGroupId) || !m_contexts.get(contextGroupId)-
>contains(contextId)) | 774 if (!m_contexts.contains(contextGroupId) || !m_contexts.get(contextGroupId)-
>contains(contextId)) |
775 return; | 775 return; |
776 | 776 |
777 InspectedContext* inspectedContext = m_contexts.get(contextGroupId)->get(con
textId); | 777 InspectedContext* inspectedContext = m_contexts.get(contextGroupId)->get(con
textId); |
778 if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId)) | 778 if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId)) |
779 session->runtimeAgentImpl()->reportExecutionContextDestroyed(inspectedCo
ntext); | 779 session->runtimeAgent()->reportExecutionContextDestroyed(inspectedContex
t); |
780 | 780 |
781 m_contexts.get(contextGroupId)->remove(contextId); | 781 m_contexts.get(contextGroupId)->remove(contextId); |
782 if (m_contexts.get(contextGroupId)->isEmpty()) | 782 if (m_contexts.get(contextGroupId)->isEmpty()) |
783 m_contexts.remove(contextGroupId); | 783 m_contexts.remove(contextGroupId); |
784 } | 784 } |
785 | 785 |
786 void V8DebuggerImpl::resetContextGroup(int contextGroupId) | 786 void V8DebuggerImpl::resetContextGroup(int contextGroupId) |
787 { | 787 { |
788 if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId)) | 788 if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId)) |
789 session->reset(); | 789 session->reset(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |