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" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 return; | 129 return; |
130 func->SetName(funcName); | 130 func->SetName(funcName); |
131 v8::Local<v8::String> returnValue = v8String(context->GetIsolate(), descript
ion); | 131 v8::Local<v8::String> returnValue = v8String(context->GetIsolate(), descript
ion); |
132 v8::Local<v8::Function> toStringFunction; | 132 v8::Local<v8::Function> toStringFunction; |
133 if (v8::Function::New(context, returnDataCallback, returnValue).ToLocal(&toS
tringFunction)) | 133 if (v8::Function::New(context, returnDataCallback, returnValue).ToLocal(&toS
tringFunction)) |
134 func->Set(v8String(context->GetIsolate(), "toString"), toStringFunction)
; | 134 func->Set(v8String(context->GetIsolate(), "toString"), toStringFunction)
; |
135 if (!object->Set(context, funcName, func).FromMaybe(false)) | 135 if (!object->Set(context, funcName, func).FromMaybe(false)) |
136 return; | 136 return; |
137 } | 137 } |
138 | 138 |
139 bool ThreadDebugger::isCommandLineAPIMethod(const String& name) | |
140 { | |
141 DEFINE_STATIC_LOCAL(HashSet<String>, methods, ()); | |
142 if (methods.size() == 0) { | |
143 const char* members[] = { "monitorEvents", "unmonitorEvents", "getEventL
isteners" }; | |
144 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i) | |
145 methods.add(members[i]); | |
146 } | |
147 return methods.find(name) != methods.end() || V8Debugger::isCommandLineAPIMe
thod(name); | |
148 } | |
149 | |
150 void ThreadDebugger::installAdditionalCommandLineAPI(v8::Local<v8::Context> cont
ext, v8::Local<v8::Object> object) | 139 void ThreadDebugger::installAdditionalCommandLineAPI(v8::Local<v8::Context> cont
ext, v8::Local<v8::Object> object) |
151 { | 140 { |
152 createFunctionProperty(context, object, "monitorEvents", ThreadDebugger::mon
itorEventsCallback, "function monitorEvents(object, [types]) { [Command Line API
] }"); | 141 createFunctionProperty(context, object, "monitorEvents", ThreadDebugger::mon
itorEventsCallback, "function monitorEvents(object, [types]) { [Command Line API
] }"); |
153 createFunctionProperty(context, object, "unmonitorEvents", ThreadDebugger::u
nmonitorEventsCallback, "function unmonitorEvents(object, [types]) { [Command Li
ne API] }"); | 142 createFunctionProperty(context, object, "unmonitorEvents", ThreadDebugger::u
nmonitorEventsCallback, "function unmonitorEvents(object, [types]) { [Command Li
ne API] }"); |
154 createFunctionProperty(context, object, "getEventListeners", ThreadDebugger:
:getEventListenersCallback, "function getEventListeners(node) { [Command Line AP
I] }"); | 143 createFunctionProperty(context, object, "getEventListeners", ThreadDebugger:
:getEventListenersCallback, "function getEventListeners(node) { [Command Line AP
I] }"); |
155 } | 144 } |
156 | 145 |
157 static Vector<String> normalizeEventTypes(const v8::FunctionCallbackInfo<v8::Val
ue>& info) | 146 static Vector<String> normalizeEventTypes(const v8::FunctionCallbackInfo<v8::Val
ue>& info) |
158 { | 147 { |
159 Vector<String> types; | 148 Vector<String> types; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 { | 345 { |
357 for (size_t index = 0; index < m_timers.size(); ++index) { | 346 for (size_t index = 0; index < m_timers.size(); ++index) { |
358 if (m_timers[index] == timer) { | 347 if (m_timers[index] == timer) { |
359 m_timerCallbacks[index](m_timerData[index]); | 348 m_timerCallbacks[index](m_timerData[index]); |
360 return; | 349 return; |
361 } | 350 } |
362 } | 351 } |
363 } | 352 } |
364 | 353 |
365 } // namespace blink | 354 } // namespace blink |
OLD | NEW |