| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/inspector/ThreadDebugger.h" | 5 #include "core/inspector/ThreadDebugger.h" |
| 6 | 6 |
| 7 #include <memory> |
| 7 #include "bindings/core/v8/SourceLocation.h" | 8 #include "bindings/core/v8/SourceLocation.h" |
| 8 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
| 9 #include "bindings/core/v8/V8DOMException.h" | 10 #include "bindings/core/v8/V8DOMException.h" |
| 10 #include "bindings/core/v8/V8DOMTokenList.h" | 11 #include "bindings/core/v8/V8DOMTokenList.h" |
| 11 #include "bindings/core/v8/V8Event.h" | 12 #include "bindings/core/v8/V8Event.h" |
| 12 #include "bindings/core/v8/V8EventListener.h" | 13 #include "bindings/core/v8/V8EventListener.h" |
| 13 #include "bindings/core/v8/V8EventListenerHelper.h" | 14 #include "bindings/core/v8/V8EventListenerHelper.h" |
| 14 #include "bindings/core/v8/V8EventListenerInfo.h" | 15 #include "bindings/core/v8/V8EventListenerInfo.h" |
| 15 #include "bindings/core/v8/V8HTMLAllCollection.h" | 16 #include "bindings/core/v8/V8HTMLAllCollection.h" |
| 16 #include "bindings/core/v8/V8HTMLCollection.h" | 17 #include "bindings/core/v8/V8HTMLCollection.h" |
| 17 #include "bindings/core/v8/V8Node.h" | 18 #include "bindings/core/v8/V8Node.h" |
| 18 #include "bindings/core/v8/V8NodeList.h" | 19 #include "bindings/core/v8/V8NodeList.h" |
| 19 #include "bindings/core/v8/V8ScriptRunner.h" | 20 #include "bindings/core/v8/V8ScriptRunner.h" |
| 20 #include "core/dom/DocumentUserGestureToken.h" | 21 #include "core/dom/DocumentUserGestureToken.h" |
| 21 #include "core/inspector/ConsoleMessage.h" | 22 #include "core/inspector/ConsoleMessage.h" |
| 22 #include "core/inspector/InspectorDOMDebuggerAgent.h" | 23 #include "core/inspector/InspectorDOMDebuggerAgent.h" |
| 23 #include "core/inspector/InspectorTraceEvents.h" | 24 #include "core/inspector/InspectorTraceEvents.h" |
| 24 #include "core/inspector/V8InspectorString.h" | 25 #include "core/inspector/V8InspectorString.h" |
| 25 #include "platform/ScriptForbiddenScope.h" | 26 #include "platform/ScriptForbiddenScope.h" |
| 26 #include "wtf/CurrentTime.h" | 27 #include "wtf/CurrentTime.h" |
| 27 #include "wtf/PtrUtil.h" | 28 #include "wtf/PtrUtil.h" |
| 28 #include <memory> | |
| 29 | 29 |
| 30 namespace blink { | 30 namespace blink { |
| 31 | 31 |
| 32 ThreadDebugger::ThreadDebugger(v8::Isolate* isolate) | 32 ThreadDebugger::ThreadDebugger(v8::Isolate* isolate) |
| 33 : m_isolate(isolate), | 33 : m_isolate(isolate), |
| 34 m_v8Inspector(v8_inspector::V8Inspector::create(isolate, this)), | 34 m_v8Inspector(v8_inspector::V8Inspector::create(isolate, this)), |
| 35 m_v8TracingCpuProfiler(v8::TracingCpuProfiler::Create(isolate)) {} | 35 m_v8TracingCpuProfiler(v8::TracingCpuProfiler::Create(isolate)) {} |
| 36 | 36 |
| 37 ThreadDebugger::~ThreadDebugger() {} | 37 ThreadDebugger::~ThreadDebugger() {} |
| 38 | 38 |
| 39 // static | 39 // static |
| 40 ThreadDebugger* ThreadDebugger::from(v8::Isolate* isolate) { | 40 ThreadDebugger* ThreadDebugger::from(v8::Isolate* isolate) { |
| 41 if (!isolate) | 41 if (!isolate) |
| 42 return nullptr; | 42 return nullptr; |
| 43 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 43 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 44 return data ? data->threadDebugger() : nullptr; | 44 return data ? static_cast<ThreadDebugger*>(data->threadDebugger()) : nullptr; |
| 45 } | 45 } |
| 46 | 46 |
| 47 // static | 47 // static |
| 48 void ThreadDebugger::setThreadDebugger(v8::Isolate* isolate, |
| 49 ThreadDebugger* threadDebugger) { |
| 50 V8PerIsolateData::from(isolate)->setThreadDebugger(threadDebugger); |
| 51 } |
| 52 |
| 53 // static |
| 54 ThreadDebugger* ThreadDebugger::getThreadDebugger(v8::Isolate* isolate) { |
| 55 return static_cast<ThreadDebugger*>( |
| 56 V8PerIsolateData::from(isolate)->threadDebugger()); |
| 57 } |
| 58 |
| 59 // static |
| 48 MessageLevel ThreadDebugger::v8MessageLevelToMessageLevel( | 60 MessageLevel ThreadDebugger::v8MessageLevelToMessageLevel( |
| 49 v8::Isolate::MessageErrorLevel level) { | 61 v8::Isolate::MessageErrorLevel level) { |
| 50 MessageLevel result = InfoMessageLevel; | 62 MessageLevel result = InfoMessageLevel; |
| 51 switch (level) { | 63 switch (level) { |
| 52 case v8::Isolate::kMessageDebug: | 64 case v8::Isolate::kMessageDebug: |
| 53 result = VerboseMessageLevel; | 65 result = VerboseMessageLevel; |
| 54 break; | 66 break; |
| 55 case v8::Isolate::kMessageWarning: | 67 case v8::Isolate::kMessageWarning: |
| 56 result = WarningMessageLevel; | 68 result = WarningMessageLevel; |
| 57 break; | 69 break; |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 void ThreadDebugger::onTimer(TimerBase* timer) { | 497 void ThreadDebugger::onTimer(TimerBase* timer) { |
| 486 for (size_t index = 0; index < m_timers.size(); ++index) { | 498 for (size_t index = 0; index < m_timers.size(); ++index) { |
| 487 if (m_timers[index].get() == timer) { | 499 if (m_timers[index].get() == timer) { |
| 488 m_timerCallbacks[index](m_timerData[index]); | 500 m_timerCallbacks[index](m_timerData[index]); |
| 489 return; | 501 return; |
| 490 } | 502 } |
| 491 } | 503 } |
| 492 } | 504 } |
| 493 | 505 |
| 494 } // namespace blink | 506 } // namespace blink |
| OLD | NEW |