| 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" |
| 40 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" | 41 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" |
| 41 #include "platform/v8_inspector/V8StackTraceImpl.h" | 42 #include "platform/v8_inspector/V8StackTraceImpl.h" |
| 42 #include "platform/v8_inspector/V8StringUtil.h" | 43 #include "platform/v8_inspector/V8StringUtil.h" |
| 43 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 44 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
| 44 | 45 |
| 45 namespace blink { | 46 namespace blink { |
| 46 | 47 |
| 47 namespace { | 48 namespace { |
| (...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 void V8DebuggerImpl::contextCreated(const V8ContextInfo& info) | 760 void V8DebuggerImpl::contextCreated(const V8ContextInfo& info) |
| 760 { | 761 { |
| 761 ASSERT(info.context->GetIsolate() == m_isolate); | 762 ASSERT(info.context->GetIsolate() == m_isolate); |
| 762 // TODO(dgozman): make s_lastContextId non-static. | 763 // TODO(dgozman): make s_lastContextId non-static. |
| 763 int contextId = atomicIncrement(&s_lastContextId); | 764 int contextId = atomicIncrement(&s_lastContextId); |
| 764 String16 debugData = String16::number(info.contextGroupId) + "," + String16:
:number(contextId) + "," + (info.isDefault ? "default" : "nondefault"); | 765 String16 debugData = String16::number(info.contextGroupId) + "," + String16:
:number(contextId) + "," + (info.isDefault ? "default" : "nondefault"); |
| 765 v8::HandleScope scope(m_isolate); | 766 v8::HandleScope scope(m_isolate); |
| 766 v8::Context::Scope contextScope(info.context); | 767 v8::Context::Scope contextScope(info.context); |
| 767 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex),
toV8String(m_isolate, debugData)); | 768 info.context->SetEmbedderData(static_cast<int>(v8::Context::kDebugIdIndex),
toV8String(m_isolate, debugData)); |
| 768 | 769 |
| 770 installConsole(info.context); |
| 771 |
| 769 if (!m_contexts.contains(info.contextGroupId)) | 772 if (!m_contexts.contains(info.contextGroupId)) |
| 770 m_contexts.set(info.contextGroupId, adoptPtr(new ContextByIdMap())); | 773 m_contexts.set(info.contextGroupId, adoptPtr(new ContextByIdMap())); |
| 771 ASSERT(!m_contexts.get(info.contextGroupId)->contains(contextId)); | 774 ASSERT(!m_contexts.get(info.contextGroupId)->contains(contextId)); |
| 772 | 775 |
| 773 OwnPtr<InspectedContext> contextOwner = adoptPtr(new InspectedContext(this,
info, contextId)); | 776 OwnPtr<InspectedContext> contextOwner = adoptPtr(new InspectedContext(this,
info, contextId)); |
| 774 InspectedContext* inspectedContext = contextOwner.get(); | 777 InspectedContext* inspectedContext = contextOwner.get(); |
| 775 m_contexts.get(info.contextGroupId)->set(contextId, contextOwner.release()); | 778 m_contexts.get(info.contextGroupId)->set(contextId, contextOwner.release()); |
| 776 | 779 |
| 777 if (V8InspectorSessionImpl* session = m_sessions.get(info.contextGroupId)) | 780 if (V8InspectorSessionImpl* session = m_sessions.get(info.contextGroupId)) |
| 778 session->runtimeAgentImpl()->reportExecutionContextCreated(inspectedCont
ext); | 781 session->runtimeAgentImpl()->reportExecutionContextCreated(inspectedCont
ext); |
| 779 } | 782 } |
| 780 | 783 |
| 784 bool V8DebuggerImpl::installConsole(v8::Local<v8::Context> context) |
| 785 { |
| 786 v8::Isolate* isolate = context->GetIsolate(); |
| 787 v8::Local<v8::Object> global = context->Global(); |
| 788 return global->Set(context, toV8StringInternalized(isolate, "console"), V8Co
nsole::create(context, m_client)).FromMaybe(false); |
| 789 } |
| 790 |
| 781 void V8DebuggerImpl::contextDestroyed(v8::Local<v8::Context> context) | 791 void V8DebuggerImpl::contextDestroyed(v8::Local<v8::Context> context) |
| 782 { | 792 { |
| 783 int contextId = V8Debugger::contextId(context); | 793 int contextId = V8Debugger::contextId(context); |
| 784 int contextGroupId = getGroupId(context); | 794 int contextGroupId = getGroupId(context); |
| 785 if (!m_contexts.contains(contextGroupId) || !m_contexts.get(contextGroupId)-
>contains(contextId)) | 795 if (!m_contexts.contains(contextGroupId) || !m_contexts.get(contextGroupId)-
>contains(contextId)) |
| 786 return; | 796 return; |
| 787 | 797 |
| 788 InspectedContext* inspectedContext = m_contexts.get(contextGroupId)->get(con
textId); | 798 InspectedContext* inspectedContext = m_contexts.get(contextGroupId)->get(con
textId); |
| 789 if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId)) | 799 if (V8InspectorSessionImpl* session = m_sessions.get(contextGroupId)) |
| 790 session->runtimeAgentImpl()->reportExecutionContextDestroyed(inspectedCo
ntext); | 800 session->runtimeAgentImpl()->reportExecutionContextDestroyed(inspectedCo
ntext); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 } | 834 } |
| 825 | 835 |
| 826 const V8DebuggerImpl::ContextByIdMap* V8DebuggerImpl::contextGroup(int contextGr
oupId) | 836 const V8DebuggerImpl::ContextByIdMap* V8DebuggerImpl::contextGroup(int contextGr
oupId) |
| 827 { | 837 { |
| 828 if (!m_contexts.contains(contextGroupId)) | 838 if (!m_contexts.contains(contextGroupId)) |
| 829 return nullptr; | 839 return nullptr; |
| 830 return m_contexts.get(contextGroupId); | 840 return m_contexts.get(contextGroupId); |
| 831 } | 841 } |
| 832 | 842 |
| 833 } // namespace blink | 843 } // namespace blink |
| OLD | NEW |