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/PtrUtil.h" | 25 #include "wtf/OwnPtr.h" |
26 #include <memory> | |
27 | 26 |
28 namespace blink { | 27 namespace blink { |
29 | 28 |
30 ThreadDebugger::ThreadDebugger(v8::Isolate* isolate) | 29 ThreadDebugger::ThreadDebugger(v8::Isolate* isolate) |
31 : m_isolate(isolate) | 30 : m_isolate(isolate) |
32 , m_debugger(V8Debugger::create(isolate, this)) | 31 , m_debugger(V8Debugger::create(isolate, this)) |
33 { | 32 { |
34 } | 33 } |
35 | 34 |
36 ThreadDebugger::~ThreadDebugger() | 35 ThreadDebugger::~ThreadDebugger() |
(...skipping 23 matching lines...) Expand all Loading... |
60 | 59 |
61 void ThreadDebugger::idleFinished(v8::Isolate* isolate) | 60 void ThreadDebugger::idleFinished(v8::Isolate* isolate) |
62 { | 61 { |
63 V8PerIsolateData* data = V8PerIsolateData::from(isolate); | 62 V8PerIsolateData* data = V8PerIsolateData::from(isolate); |
64 if (data && data->threadDebugger()) | 63 if (data && data->threadDebugger()) |
65 data->threadDebugger()->debugger()->idleFinished(); | 64 data->threadDebugger()->debugger()->idleFinished(); |
66 } | 65 } |
67 | 66 |
68 void ThreadDebugger::beginUserGesture() | 67 void ThreadDebugger::beginUserGesture() |
69 { | 68 { |
70 m_userGestureIndicator = wrapUnique(new UserGestureIndicator(DefinitelyProce
ssingNewUserGesture)); | 69 m_userGestureIndicator = adoptPtr(new UserGestureIndicator(DefinitelyProcess
ingNewUserGesture)); |
71 } | 70 } |
72 | 71 |
73 void ThreadDebugger::endUserGesture() | 72 void ThreadDebugger::endUserGesture() |
74 { | 73 { |
75 m_userGestureIndicator.reset(); | 74 m_userGestureIndicator.reset(); |
76 } | 75 } |
77 | 76 |
78 String16 ThreadDebugger::valueSubtype(v8::Local<v8::Value> value) | 77 String16 ThreadDebugger::valueSubtype(v8::Local<v8::Value> value) |
79 { | 78 { |
80 if (V8Node::hasInstance(value, m_isolate)) | 79 if (V8Node::hasInstance(value, m_isolate)) |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 { | 315 { |
317 v8::Isolate* isolate = m_isolate; | 316 v8::Isolate* isolate = m_isolate; |
318 TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THR
EAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), tit
le)); | 317 TRACE_EVENT_INSTANT1("devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THR
EAD, "data", InspectorTimeStampEvent::data(currentExecutionContext(isolate), tit
le)); |
319 } | 318 } |
320 | 319 |
321 void ThreadDebugger::startRepeatingTimer(double interval, V8DebuggerClient::Time
rCallback callback, void* data) | 320 void ThreadDebugger::startRepeatingTimer(double interval, V8DebuggerClient::Time
rCallback callback, void* data) |
322 { | 321 { |
323 m_timerData.append(data); | 322 m_timerData.append(data); |
324 m_timerCallbacks.append(callback); | 323 m_timerCallbacks.append(callback); |
325 | 324 |
326 std::unique_ptr<Timer<ThreadDebugger>> timer = wrapUnique(new Timer<ThreadDe
bugger>(this, &ThreadDebugger::onTimer)); | 325 OwnPtr<Timer<ThreadDebugger>> timer = adoptPtr(new Timer<ThreadDebugger>(thi
s, &ThreadDebugger::onTimer)); |
327 Timer<ThreadDebugger>* timerPtr = timer.get(); | 326 Timer<ThreadDebugger>* timerPtr = timer.get(); |
328 m_timers.append(std::move(timer)); | 327 m_timers.append(std::move(timer)); |
329 timerPtr->startRepeating(interval, BLINK_FROM_HERE); | 328 timerPtr->startRepeating(interval, BLINK_FROM_HERE); |
330 } | 329 } |
331 | 330 |
332 void ThreadDebugger::cancelTimer(void* data) | 331 void ThreadDebugger::cancelTimer(void* data) |
333 { | 332 { |
334 for (size_t index = 0; index < m_timerData.size(); ++index) { | 333 for (size_t index = 0; index < m_timerData.size(); ++index) { |
335 if (m_timerData[index] == data) { | 334 if (m_timerData[index] == data) { |
336 m_timers[index]->stop(); | 335 m_timers[index]->stop(); |
337 m_timerCallbacks.remove(index); | 336 m_timerCallbacks.remove(index); |
338 m_timers.remove(index); | 337 m_timers.remove(index); |
339 m_timerData.remove(index); | 338 m_timerData.remove(index); |
340 return; | 339 return; |
341 } | 340 } |
342 } | 341 } |
343 } | 342 } |
344 | 343 |
345 void ThreadDebugger::onTimer(Timer<ThreadDebugger>* timer) | 344 void ThreadDebugger::onTimer(Timer<ThreadDebugger>* timer) |
346 { | 345 { |
347 for (size_t index = 0; index < m_timers.size(); ++index) { | 346 for (size_t index = 0; index < m_timers.size(); ++index) { |
348 if (m_timers[index].get() == timer) { | 347 if (m_timers[index] == timer) { |
349 m_timerCallbacks[index](m_timerData[index]); | 348 m_timerCallbacks[index](m_timerData[index]); |
350 return; | 349 return; |
351 } | 350 } |
352 } | 351 } |
353 } | 352 } |
354 | 353 |
355 } // namespace blink | 354 } // namespace blink |
OLD | NEW |