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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 { | 316 { |
316 v8::Isolate* isolate = m_isolate; | 317 v8::Isolate* isolate = m_isolate; |
317 TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THR
EAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), tit
le)); | 318 TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THR
EAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), tit
le)); |
318 } | 319 } |
319 | 320 |
320 void ThreadDebugger::startRepeatingTimer(double interval, V8DebuggerClient::Time
rCallback callback, void* data) | 321 void ThreadDebugger::startRepeatingTimer(double interval, V8DebuggerClient::Time
rCallback callback, void* data) |
321 { | 322 { |
322 m_timerData.append(data); | 323 m_timerData.append(data); |
323 m_timerCallbacks.append(callback); | 324 m_timerCallbacks.append(callback); |
324 | 325 |
325 OwnPtr<Timer<ThreadDebugger>> timer = adoptPtr(new Timer<ThreadDebugger>(thi
s, &ThreadDebugger::onTimer)); | 326 std::unique_ptr<Timer<ThreadDebugger>> timer = wrapUnique(new Timer<ThreadDe
bugger>(this, &ThreadDebugger::onTimer)); |
326 Timer<ThreadDebugger>* timerPtr = timer.get(); | 327 Timer<ThreadDebugger>* timerPtr = timer.get(); |
327 m_timers.append(std::move(timer)); | 328 m_timers.append(std::move(timer)); |
328 timerPtr->startRepeating(interval, BLINK_FROM_HERE); | 329 timerPtr->startRepeating(interval, BLINK_FROM_HERE); |
329 } | 330 } |
330 | 331 |
331 void ThreadDebugger::cancelTimer(void* data) | 332 void ThreadDebugger::cancelTimer(void* data) |
332 { | 333 { |
333 for (size_t index = 0; index < m_timerData.size(); ++index) { | 334 for (size_t index = 0; index < m_timerData.size(); ++index) { |
334 if (m_timerData[index] == data) { | 335 if (m_timerData[index] == data) { |
335 m_timers[index]->stop(); | 336 m_timers[index]->stop(); |
336 m_timerCallbacks.remove(index); | 337 m_timerCallbacks.remove(index); |
337 m_timers.remove(index); | 338 m_timers.remove(index); |
338 m_timerData.remove(index); | 339 m_timerData.remove(index); |
339 return; | 340 return; |
340 } | 341 } |
341 } | 342 } |
342 } | 343 } |
343 | 344 |
344 void ThreadDebugger::onTimer(Timer<ThreadDebugger>* timer) | 345 void ThreadDebugger::onTimer(Timer<ThreadDebugger>* timer) |
345 { | 346 { |
346 for (size_t index = 0; index < m_timers.size(); ++index) { | 347 for (size_t index = 0; index < m_timers.size(); ++index) { |
347 if (m_timers[index] == timer) { | 348 if (m_timers[index].get() == timer) { |
348 m_timerCallbacks[index](m_timerData[index]); | 349 m_timerCallbacks[index](m_timerData[index]); |
349 return; | 350 return; |
350 } | 351 } |
351 } | 352 } |
352 } | 353 } |
353 | 354 |
354 } // namespace blink | 355 } // namespace blink |
OLD | NEW |