| 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/SourceLocation.h" | 7 #include "bindings/core/v8/SourceLocation.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" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 createFunctionPropertyWithData( | 269 createFunctionPropertyWithData( |
| 270 context, object, "unmonitorEvents", | 270 context, object, "unmonitorEvents", |
| 271 ThreadDebugger::unmonitorEventsCallback, functionValue, | 271 ThreadDebugger::unmonitorEventsCallback, functionValue, |
| 272 "function unmonitorEvents(object, [types]) { [Command Line API] }"); | 272 "function unmonitorEvents(object, [types]) { [Command Line API] }"); |
| 273 } | 273 } |
| 274 | 274 |
| 275 static Vector<String> normalizeEventTypes( | 275 static Vector<String> normalizeEventTypes( |
| 276 const v8::FunctionCallbackInfo<v8::Value>& info) { | 276 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 277 Vector<String> types; | 277 Vector<String> types; |
| 278 if (info.Length() > 1 && info[1]->IsString()) | 278 if (info.Length() > 1 && info[1]->IsString()) |
| 279 types.append(toCoreString(info[1].As<v8::String>())); | 279 types.push_back(toCoreString(info[1].As<v8::String>())); |
| 280 if (info.Length() > 1 && info[1]->IsArray()) { | 280 if (info.Length() > 1 && info[1]->IsArray()) { |
| 281 v8::Local<v8::Array> typesArray = v8::Local<v8::Array>::Cast(info[1]); | 281 v8::Local<v8::Array> typesArray = v8::Local<v8::Array>::Cast(info[1]); |
| 282 for (size_t i = 0; i < typesArray->Length(); ++i) { | 282 for (size_t i = 0; i < typesArray->Length(); ++i) { |
| 283 v8::Local<v8::Value> typeValue; | 283 v8::Local<v8::Value> typeValue; |
| 284 if (!typesArray->Get(info.GetIsolate()->GetCurrentContext(), i) | 284 if (!typesArray->Get(info.GetIsolate()->GetCurrentContext(), i) |
| 285 .ToLocal(&typeValue) || | 285 .ToLocal(&typeValue) || |
| 286 !typeValue->IsString()) | 286 !typeValue->IsString()) |
| 287 continue; | 287 continue; |
| 288 types.append(toCoreString(v8::Local<v8::String>::Cast(typeValue))); | 288 types.push_back(toCoreString(v8::Local<v8::String>::Cast(typeValue))); |
| 289 } | 289 } |
| 290 } | 290 } |
| 291 if (info.Length() == 1) | 291 if (info.Length() == 1) |
| 292 types.appendVector( | 292 types.appendVector( |
| 293 Vector<String>({"mouse", "key", "touch", | 293 Vector<String>({"mouse", "key", "touch", |
| 294 "pointer", "control", "load", | 294 "pointer", "control", "load", |
| 295 "unload", "abort", "error", | 295 "unload", "abort", "error", |
| 296 "select", "input", "change", | 296 "select", "input", "change", |
| 297 "submit", "reset", "focus", | 297 "submit", "reset", "focus", |
| 298 "blur", "resize", "scroll", | 298 "blur", "resize", "scroll", |
| (...skipping 15 matching lines...) Expand all Loading... |
| 314 else if (types[i] == "pointer") | 314 else if (types[i] == "pointer") |
| 315 outputTypes.appendVector(Vector<String>( | 315 outputTypes.appendVector(Vector<String>( |
| 316 {"pointerover", "pointerout", "pointerenter", "pointerleave", | 316 {"pointerover", "pointerout", "pointerenter", "pointerleave", |
| 317 "pointerdown", "pointerup", "pointermove", "pointercancel", | 317 "pointerdown", "pointerup", "pointermove", "pointercancel", |
| 318 "gotpointercapture", "lostpointercapture"})); | 318 "gotpointercapture", "lostpointercapture"})); |
| 319 else if (types[i] == "control") | 319 else if (types[i] == "control") |
| 320 outputTypes.appendVector( | 320 outputTypes.appendVector( |
| 321 Vector<String>({"resize", "scroll", "zoom", "focus", "blur", "select", | 321 Vector<String>({"resize", "scroll", "zoom", "focus", "blur", "select", |
| 322 "input", "change", "submit", "reset"})); | 322 "input", "change", "submit", "reset"})); |
| 323 else | 323 else |
| 324 outputTypes.append(types[i]); | 324 outputTypes.push_back(types[i]); |
| 325 } | 325 } |
| 326 return outputTypes; | 326 return outputTypes; |
| 327 } | 327 } |
| 328 | 328 |
| 329 static EventTarget* firstArgumentAsEventTarget( | 329 static EventTarget* firstArgumentAsEventTarget( |
| 330 const v8::FunctionCallbackInfo<v8::Value>& info) { | 330 const v8::FunctionCallbackInfo<v8::Value>& info) { |
| 331 if (info.Length() < 1) | 331 if (info.Length() < 1) |
| 332 return nullptr; | 332 return nullptr; |
| 333 if (EventTarget* target = | 333 if (EventTarget* target = |
| 334 V8EventTarget::toImplWithTypeCheck(info.GetIsolate(), info[0])) | 334 V8EventTarget::toImplWithTypeCheck(info.GetIsolate(), info[0])) |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 TRACE_EVENT_INSTANT1( | 449 TRACE_EVENT_INSTANT1( |
| 450 "devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THREAD, "data", | 450 "devtools.timeline", "TimeStamp", TRACE_EVENT_SCOPE_THREAD, "data", |
| 451 InspectorTimeStampEvent::data(currentExecutionContext(isolate), | 451 InspectorTimeStampEvent::data(currentExecutionContext(isolate), |
| 452 toCoreString(title))); | 452 toCoreString(title))); |
| 453 } | 453 } |
| 454 | 454 |
| 455 void ThreadDebugger::startRepeatingTimer( | 455 void ThreadDebugger::startRepeatingTimer( |
| 456 double interval, | 456 double interval, |
| 457 V8InspectorClient::TimerCallback callback, | 457 V8InspectorClient::TimerCallback callback, |
| 458 void* data) { | 458 void* data) { |
| 459 m_timerData.append(data); | 459 m_timerData.push_back(data); |
| 460 m_timerCallbacks.append(callback); | 460 m_timerCallbacks.push_back(callback); |
| 461 | 461 |
| 462 std::unique_ptr<Timer<ThreadDebugger>> timer = WTF::wrapUnique( | 462 std::unique_ptr<Timer<ThreadDebugger>> timer = WTF::wrapUnique( |
| 463 new Timer<ThreadDebugger>(this, &ThreadDebugger::onTimer)); | 463 new Timer<ThreadDebugger>(this, &ThreadDebugger::onTimer)); |
| 464 Timer<ThreadDebugger>* timerPtr = timer.get(); | 464 Timer<ThreadDebugger>* timerPtr = timer.get(); |
| 465 m_timers.append(std::move(timer)); | 465 m_timers.push_back(std::move(timer)); |
| 466 timerPtr->startRepeating(interval, BLINK_FROM_HERE); | 466 timerPtr->startRepeating(interval, BLINK_FROM_HERE); |
| 467 } | 467 } |
| 468 | 468 |
| 469 void ThreadDebugger::cancelTimer(void* data) { | 469 void ThreadDebugger::cancelTimer(void* data) { |
| 470 for (size_t index = 0; index < m_timerData.size(); ++index) { | 470 for (size_t index = 0; index < m_timerData.size(); ++index) { |
| 471 if (m_timerData[index] == data) { | 471 if (m_timerData[index] == data) { |
| 472 m_timers[index]->stop(); | 472 m_timers[index]->stop(); |
| 473 m_timerCallbacks.remove(index); | 473 m_timerCallbacks.remove(index); |
| 474 m_timers.remove(index); | 474 m_timers.remove(index); |
| 475 m_timerData.remove(index); | 475 m_timerData.remove(index); |
| 476 return; | 476 return; |
| 477 } | 477 } |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 | 480 |
| 481 void ThreadDebugger::onTimer(TimerBase* timer) { | 481 void ThreadDebugger::onTimer(TimerBase* timer) { |
| 482 for (size_t index = 0; index < m_timers.size(); ++index) { | 482 for (size_t index = 0; index < m_timers.size(); ++index) { |
| 483 if (m_timers[index].get() == timer) { | 483 if (m_timers[index].get() == timer) { |
| 484 m_timerCallbacks[index](m_timerData[index]); | 484 m_timerCallbacks[index](m_timerData[index]); |
| 485 return; | 485 return; |
| 486 } | 486 } |
| 487 } | 487 } |
| 488 } | 488 } |
| 489 | 489 |
| 490 } // namespace blink | 490 } // namespace blink |
| OLD | NEW |