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/ScriptCallStack.h" | 7 #include "bindings/core/v8/ScriptCallStack.h" |
8 #include "bindings/core/v8/ScriptValue.h" | 8 #include "bindings/core/v8/ScriptValue.h" |
9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
10 #include "bindings/core/v8/V8DOMException.h" | 10 #include "bindings/core/v8/V8DOMException.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 return; | 130 return; |
131 func->SetName(funcName); | 131 func->SetName(funcName); |
132 v8::Local<v8::String> returnValue = v8String(context->GetIsolate(), descript
ion); | 132 v8::Local<v8::String> returnValue = v8String(context->GetIsolate(), descript
ion); |
133 v8::Local<v8::Function> toStringFunction; | 133 v8::Local<v8::Function> toStringFunction; |
134 if (v8::Function::New(context, returnDataCallback, returnValue).ToLocal(&toS
tringFunction)) | 134 if (v8::Function::New(context, returnDataCallback, returnValue).ToLocal(&toS
tringFunction)) |
135 func->Set(v8String(context->GetIsolate(), "toString"), toStringFunction)
; | 135 func->Set(v8String(context->GetIsolate(), "toString"), toStringFunction)
; |
136 if (!object->Set(context, funcName, func).FromMaybe(false)) | 136 if (!object->Set(context, funcName, func).FromMaybe(false)) |
137 return; | 137 return; |
138 } | 138 } |
139 | 139 |
140 bool ThreadDebugger::isCommandLineAPIMethod(const String& name) | |
141 { | |
142 DEFINE_STATIC_LOCAL(HashSet<String>, methods, ()); | |
143 if (methods.size() == 0) { | |
144 const char* members[] = { "monitorEvents", "unmonitorEvents", "getEventL
isteners" }; | |
145 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i) | |
146 methods.add(members[i]); | |
147 } | |
148 return methods.find(name) != methods.end() || V8Debugger::isCommandLineAPIMe
thod(name); | |
149 } | |
150 | |
151 void ThreadDebugger::installAdditionalCommandLineAPI(v8::Local<v8::Context> cont
ext, v8::Local<v8::Object> object) | 140 void ThreadDebugger::installAdditionalCommandLineAPI(v8::Local<v8::Context> cont
ext, v8::Local<v8::Object> object) |
152 { | 141 { |
153 createFunctionProperty(context, object, "monitorEvents", ThreadDebugger::mon
itorEventsCallback, "function monitorEvents(object, [types]) { [Command Line API
] }"); | 142 createFunctionProperty(context, object, "monitorEvents", ThreadDebugger::mon
itorEventsCallback, "function monitorEvents(object, [types]) { [Command Line API
] }"); |
154 createFunctionProperty(context, object, "unmonitorEvents", ThreadDebugger::u
nmonitorEventsCallback, "function unmonitorEvents(object, [types]) { [Command Li
ne API] }"); | 143 createFunctionProperty(context, object, "unmonitorEvents", ThreadDebugger::u
nmonitorEventsCallback, "function unmonitorEvents(object, [types]) { [Command Li
ne API] }"); |
155 createFunctionProperty(context, object, "getEventListeners", ThreadDebugger:
:getEventListenersCallback, "function getEventListeners(node) { [Command Line AP
I] }"); | 144 createFunctionProperty(context, object, "getEventListeners", ThreadDebugger:
:getEventListenersCallback, "function getEventListeners(node) { [Command Line AP
I] }"); |
156 } | 145 } |
157 | 146 |
158 static Vector<String> normalizeEventTypes(const v8::FunctionCallbackInfo<v8::Val
ue>& info) | 147 static Vector<String> normalizeEventTypes(const v8::FunctionCallbackInfo<v8::Val
ue>& info) |
159 { | 148 { |
160 Vector<String> types; | 149 Vector<String> types; |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 { | 379 { |
391 for (size_t index = 0; index < m_timers.size(); ++index) { | 380 for (size_t index = 0; index < m_timers.size(); ++index) { |
392 if (m_timers[index] == timer) { | 381 if (m_timers[index] == timer) { |
393 m_timerCallbacks[index](m_timerData[index]); | 382 m_timerCallbacks[index](m_timerData[index]); |
394 return; | 383 return; |
395 } | 384 } |
396 } | 385 } |
397 } | 386 } |
398 | 387 |
399 } // namespace blink | 388 } // namespace blink |
OLD | NEW |