| 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 "bindings/core/v8/ScriptValue.h" | 7 #include "bindings/core/v8/ScriptValue.h" |
| 8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
| 9 #include "bindings/core/v8/V8DOMException.h" | 9 #include "bindings/core/v8/V8DOMException.h" |
| 10 #include "bindings/core/v8/V8DOMTokenList.h" | 10 #include "bindings/core/v8/V8DOMTokenList.h" |
| 11 #include "bindings/core/v8/V8Event.h" | 11 #include "bindings/core/v8/V8Event.h" |
| 12 #include "bindings/core/v8/V8EventListener.h" | 12 #include "bindings/core/v8/V8EventListener.h" |
| 13 #include "bindings/core/v8/V8EventListenerInfo.h" | 13 #include "bindings/core/v8/V8EventListenerInfo.h" |
| 14 #include "bindings/core/v8/V8EventListenerList.h" | 14 #include "bindings/core/v8/V8EventListenerList.h" |
| 15 #include "bindings/core/v8/V8HTMLAllCollection.h" | 15 #include "bindings/core/v8/V8HTMLAllCollection.h" |
| 16 #include "bindings/core/v8/V8HTMLCollection.h" | 16 #include "bindings/core/v8/V8HTMLCollection.h" |
| 17 #include "bindings/core/v8/V8Node.h" | 17 #include "bindings/core/v8/V8Node.h" |
| 18 #include "bindings/core/v8/V8NodeList.h" | 18 #include "bindings/core/v8/V8NodeList.h" |
| 19 #include "core/inspector/ConsoleMessage.h" | 19 #include "core/inspector/ConsoleMessage.h" |
| 20 #include "core/inspector/InspectorDOMDebuggerAgent.h" | 20 #include "core/inspector/InspectorDOMDebuggerAgent.h" |
| 21 #include "core/inspector/InspectorTraceEvents.h" | 21 #include "core/inspector/InspectorTraceEvents.h" |
| 22 #include "core/inspector/ScriptArguments.h" | 22 #include "core/inspector/ScriptArguments.h" |
| 23 #include "platform/ScriptForbiddenScope.h" | 23 #include "platform/ScriptForbiddenScope.h" |
| 24 #include "wtf/CurrentTime.h" | 24 #include "wtf/CurrentTime.h" |
| 25 #include "wtf/OwnPtr.h" | 25 #include "wtf/PtrUtil.h" |
| 26 #include <memory> |
| 26 | 27 |
| 27 namespace blink { | 28 namespace blink { |
| 28 | 29 |
| 29 ThreadDebugger::ThreadDebugger(v8::Isolate* isolate) | 30 ThreadDebugger::ThreadDebugger(v8::Isolate* isolate) |
| 30 : m_isolate(isolate) | 31 : m_isolate(isolate) |
| 31 , m_debugger(V8Debugger::create(isolate, this)) | 32 , m_debugger(V8Debugger::create(isolate, this)) |
| 32 { | 33 { |
| 33 } | 34 } |
| 34 | 35 |
| 35 ThreadDebugger::~ThreadDebugger() | 36 ThreadDebugger::~ThreadDebugger() |
| (...skipping 23 matching lines...) Expand all Loading... |
| 59 | 60 |
| 60 void ThreadDebugger::idleFinished(v8::Isolate* isolate) | 61 void ThreadDebugger::idleFinished(v8::Isolate* isolate) |
| 61 { | 62 { |
| 62 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 63 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
| 63 if (data && data->threadDebugger()) | 64 if (data && data->threadDebugger()) |
| 64 data->threadDebugger()->debugger()->idleFinished(); | 65 data->threadDebugger()->debugger()->idleFinished(); |
| 65 } | 66 } |
| 66 | 67 |
| 67 void ThreadDebugger::beginUserGesture() | 68 void ThreadDebugger::beginUserGesture() |
| 68 { | 69 { |
| 69 m_userGestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcess
ingNewUserGesture)); | 70 m_userGestureIndicator = wrapUnique(new UserGestureIndicator(DefinitelyProce
ssingNewUserGesture)); |
| 70 } | 71 } |
| 71 | 72 |
| 72 void ThreadDebugger::endUserGesture() | 73 void ThreadDebugger::endUserGesture() |
| 73 { | 74 { |
| 74 m_userGestureIndicator.reset(); | 75 m_userGestureIndicator.reset(); |
| 75 } | 76 } |
| 76 | 77 |
| 77 String16 ThreadDebugger::valueSubtype(v8::Local<v8::Value> value) | 78 String16 ThreadDebugger::valueSubtype(v8::Local<v8::Value> value) |
| 78 { | 79 { |
| 79 if (V8Node::hasInstance(value, m_isolate)) | 80 if (V8Node::hasInstance(value, m_isolate)) |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 { | 327 { |
| 327 v8::Isolate* isolate = m_isolate; | 328 v8::Isolate* isolate = m_isolate; |
| 328 TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THR
EAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), tit
le)); | 329 TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THR
EAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), tit
le)); |
| 329 } | 330 } |
| 330 | 331 |
| 331 void ThreadDebugger::startRepeatingTimer(double interval, V8DebuggerClient::Time
rCallback callback, void* data) | 332 void ThreadDebugger::startRepeatingTimer(double interval, V8DebuggerClient::Time
rCallback callback, void* data) |
| 332 { | 333 { |
| 333 m_timerData.append(data); | 334 m_timerData.append(data); |
| 334 m_timerCallbacks.append(callback); | 335 m_timerCallbacks.append(callback); |
| 335 | 336 |
| 336 OwnPtr<Timer<ThreadDebugger>> timer = adoptPtr(new Timer<ThreadDebugger>(thi
s, &ThreadDebugger::onTimer)); | 337 std::unique_ptr<Timer<ThreadDebugger>> timer = wrapUnique(new Timer<ThreadDe
bugger>(this, &ThreadDebugger::onTimer)); |
| 337 Timer<ThreadDebugger>* timerPtr = timer.get(); | 338 Timer<ThreadDebugger>* timerPtr = timer.get(); |
| 338 m_timers.append(std::move(timer)); | 339 m_timers.append(std::move(timer)); |
| 339 timerPtr->startRepeating(interval, BLINK_FROM_HERE); | 340 timerPtr->startRepeating(interval, BLINK_FROM_HERE); |
| 340 } | 341 } |
| 341 | 342 |
| 342 void ThreadDebugger::cancelTimer(void* data) | 343 void ThreadDebugger::cancelTimer(void* data) |
| 343 { | 344 { |
| 344 for (size_t index = 0; index < m_timerData.size(); ++index) { | 345 for (size_t index = 0; index < m_timerData.size(); ++index) { |
| 345 if (m_timerData[index] == data) { | 346 if (m_timerData[index] == data) { |
| 346 m_timers[index]->stop(); | 347 m_timers[index]->stop(); |
| 347 m_timerCallbacks.remove(index); | 348 m_timerCallbacks.remove(index); |
| 348 m_timers.remove(index); | 349 m_timers.remove(index); |
| 349 m_timerData.remove(index); | 350 m_timerData.remove(index); |
| 350 return; | 351 return; |
| 351 } | 352 } |
| 352 } | 353 } |
| 353 } | 354 } |
| 354 | 355 |
| 355 void ThreadDebugger::onTimer(Timer<ThreadDebugger>* timer) | 356 void ThreadDebugger::onTimer(Timer<ThreadDebugger>* timer) |
| 356 { | 357 { |
| 357 for (size_t index = 0; index < m_timers.size(); ++index) { | 358 for (size_t index = 0; index < m_timers.size(); ++index) { |
| 358 if (m_timers[index] == timer) { | 359 if (m_timers[index].get() == timer) { |
| 359 m_timerCallbacks[index](m_timerData[index]); | 360 m_timerCallbacks[index](m_timerData[index]); |
| 360 return; | 361 return; |
| 361 } | 362 } |
| 362 } | 363 } |
| 363 } | 364 } |
| 364 | 365 |
| 365 } // namespace blink | 366 } // namespace blink |
| OLD | NEW |