Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1626)

Side by Side Diff: src/inspector/v8-console.cc

Issue 2783073002: [inspector] convert V8Console static methods into members (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project 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 "src/inspector/v8-console.h" 5 #include "src/inspector/v8-console.h"
6 6
7 #include "src/base/macros.h" 7 #include "src/base/macros.h"
8 #include "src/inspector/injected-script.h" 8 #include "src/inspector/injected-script.h"
9 #include "src/inspector/inspected-context.h" 9 #include "src/inspector/inspected-context.h"
10 #include "src/inspector/string-util.h" 10 #include "src/inspector/string-util.h"
11 #include "src/inspector/v8-console-message.h" 11 #include "src/inspector/v8-console-message.h"
12 #include "src/inspector/v8-debugger-agent-impl.h" 12 #include "src/inspector/v8-debugger-agent-impl.h"
13 #include "src/inspector/v8-inspector-impl.h" 13 #include "src/inspector/v8-inspector-impl.h"
14 #include "src/inspector/v8-inspector-session-impl.h" 14 #include "src/inspector/v8-inspector-session-impl.h"
15 #include "src/inspector/v8-profiler-agent-impl.h" 15 #include "src/inspector/v8-profiler-agent-impl.h"
16 #include "src/inspector/v8-runtime-agent-impl.h" 16 #include "src/inspector/v8-runtime-agent-impl.h"
17 #include "src/inspector/v8-stack-trace-impl.h" 17 #include "src/inspector/v8-stack-trace-impl.h"
18 #include "src/inspector/v8-value-copier.h" 18 #include "src/inspector/v8-value-copier.h"
19 19
20 #include "include/v8-inspector.h" 20 #include "include/v8-inspector.h"
21 21
22 namespace v8_inspector { 22 namespace v8_inspector {
23 23
24 namespace { 24 namespace {
25 25
26 class ConsoleHelper { 26 class ConsoleHelper {
27 public: 27 public:
28 explicit ConsoleHelper(const v8::FunctionCallbackInfo<v8::Value>& info) 28 explicit ConsoleHelper(const v8::FunctionCallbackInfo<v8::Value>& info,
29 V8InspectorImpl* inspector)
29 : m_info(info), 30 : m_info(info),
30 m_isolate(info.GetIsolate()), 31 m_isolate(info.GetIsolate()),
31 m_context(info.GetIsolate()->GetCurrentContext()), 32 m_context(info.GetIsolate()->GetCurrentContext()),
32 m_contextId(InspectedContext::contextId(m_context)) { 33 m_inspector(inspector),
33 m_inspector = static_cast<V8InspectorImpl*>( 34 m_contextId(InspectedContext::contextId(m_context)),
34 m_info.Data().As<v8::External>()->Value()); 35 m_groupId(m_inspector->contextGroupId(m_contextId)) {}
35 m_groupId = m_inspector->contextGroupId(m_contextId);
36 }
37
38 V8InspectorImpl* inspector() { return m_inspector; }
39 36
40 int contextId() const { return m_contextId; } 37 int contextId() const { return m_contextId; }
41 int groupId() const { return m_groupId; } 38 int groupId() const { return m_groupId; }
42 39
43 InjectedScript* injectedScript() { 40 InjectedScript* injectedScript() {
44 InspectedContext* context = m_inspector->getContext(m_groupId, m_contextId); 41 InspectedContext* context = m_inspector->getContext(m_groupId, m_contextId);
45 if (!context) return nullptr; 42 if (!context) return nullptr;
46 return context->getInjectedScript(); 43 return context->getInjectedScript();
47 } 44 }
48 45
49 V8ConsoleMessageStorage* consoleMessageStorage() { 46 V8ConsoleMessageStorage* consoleMessageStorage() {
50 return inspector()->ensureConsoleMessageStorage(m_groupId); 47 return m_inspector->ensureConsoleMessageStorage(m_groupId);
51 } 48 }
52 49
53 void reportCall(ConsoleAPIType type) { 50 void reportCall(ConsoleAPIType type) {
54 if (!m_info.Length()) return; 51 if (!m_info.Length()) return;
55 std::vector<v8::Local<v8::Value>> arguments; 52 std::vector<v8::Local<v8::Value>> arguments;
56 for (int i = 0; i < m_info.Length(); ++i) arguments.push_back(m_info[i]); 53 for (int i = 0; i < m_info.Length(); ++i) arguments.push_back(m_info[i]);
57 reportCall(type, arguments); 54 reportCall(type, arguments);
58 } 55 }
59 56
60 void reportCallWithDefaultArgument(ConsoleAPIType type, 57 void reportCallWithDefaultArgument(ConsoleAPIType type,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 } 141 }
145 142
146 V8InspectorSessionImpl* currentSession() { 143 V8InspectorSessionImpl* currentSession() {
147 return m_inspector->sessionForContextGroup(m_groupId); 144 return m_inspector->sessionForContextGroup(m_groupId);
148 } 145 }
149 146
150 private: 147 private:
151 const v8::FunctionCallbackInfo<v8::Value>& m_info; 148 const v8::FunctionCallbackInfo<v8::Value>& m_info;
152 v8::Isolate* m_isolate; 149 v8::Isolate* m_isolate;
153 v8::Local<v8::Context> m_context; 150 v8::Local<v8::Context> m_context;
154 v8::Local<v8::Object> m_console;
155 V8InspectorImpl* m_inspector = nullptr; 151 V8InspectorImpl* m_inspector = nullptr;
156 int m_contextId; 152 int m_contextId;
157 int m_groupId; 153 int m_groupId;
158 154
159 DISALLOW_COPY_AND_ASSIGN(ConsoleHelper); 155 DISALLOW_COPY_AND_ASSIGN(ConsoleHelper);
160 }; 156 };
161 157
162 void returnDataCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 158 void returnDataCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
163 info.GetReturnValue().Set(info.Data()); 159 info.GetReturnValue().Set(info.Data());
164 } 160 }
(...skipping 21 matching lines...) Expand all
186 createDataProperty(context, func, toV8StringInternalized( 182 createDataProperty(context, func, toV8StringInternalized(
187 context->GetIsolate(), "toString"), 183 context->GetIsolate(), "toString"),
188 toStringFunction); 184 toStringFunction);
189 } 185 }
190 createDataProperty(context, console, funcName, func); 186 createDataProperty(context, console, funcName, func);
191 } 187 }
192 188
193 } // namespace 189 } // namespace
194 190
195 void V8Console::debugCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 191 void V8Console::debugCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
196 ConsoleHelper(info).reportCall(ConsoleAPIType::kDebug); 192 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kDebug);
197 } 193 }
198 194
199 void V8Console::errorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 195 void V8Console::errorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
200 ConsoleHelper(info).reportCall(ConsoleAPIType::kError); 196 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kError);
201 } 197 }
202 198
203 void V8Console::infoCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 199 void V8Console::infoCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
204 ConsoleHelper(info).reportCall(ConsoleAPIType::kInfo); 200 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kInfo);
205 } 201 }
206 202
207 void V8Console::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 203 void V8Console::logCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
208 ConsoleHelper(info).reportCall(ConsoleAPIType::kLog); 204 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kLog);
209 } 205 }
210 206
211 void V8Console::warnCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 207 void V8Console::warnCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
212 ConsoleHelper(info).reportCall(ConsoleAPIType::kWarning); 208 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kWarning);
213 } 209 }
214 210
215 void V8Console::dirCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 211 void V8Console::dirCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
216 ConsoleHelper(info).reportCall(ConsoleAPIType::kDir); 212 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kDir);
217 } 213 }
218 214
219 void V8Console::dirxmlCallback( 215 void V8Console::dirxmlCallback(
220 const v8::FunctionCallbackInfo<v8::Value>& info) { 216 const v8::FunctionCallbackInfo<v8::Value>& info) {
221 ConsoleHelper(info).reportCall(ConsoleAPIType::kDirXML); 217 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kDirXML);
222 } 218 }
223 219
224 void V8Console::tableCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 220 void V8Console::tableCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
225 ConsoleHelper(info).reportCall(ConsoleAPIType::kTable); 221 ConsoleHelper(info, m_inspector).reportCall(ConsoleAPIType::kTable);
226 } 222 }
227 223
228 void V8Console::traceCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 224 void V8Console::traceCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
229 ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kTrace, 225 ConsoleHelper(info, m_inspector)
230 String16("console.trace")); 226 .reportCallWithDefaultArgument(ConsoleAPIType::kTrace,
227 String16("console.trace"));
231 } 228 }
232 229
233 void V8Console::groupCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 230 void V8Console::groupCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
234 ConsoleHelper(info).reportCallWithDefaultArgument(ConsoleAPIType::kStartGroup, 231 ConsoleHelper(info, m_inspector)
235 String16("console.group")); 232 .reportCallWithDefaultArgument(ConsoleAPIType::kStartGroup,
233 String16("console.group"));
236 } 234 }
237 235
238 void V8Console::groupCollapsedCallback( 236 void V8Console::groupCollapsedCallback(
239 const v8::FunctionCallbackInfo<v8::Value>& info) { 237 const v8::FunctionCallbackInfo<v8::Value>& info) {
240 ConsoleHelper(info).reportCallWithDefaultArgument( 238 ConsoleHelper(info, m_inspector)
241 ConsoleAPIType::kStartGroupCollapsed, String16("console.groupCollapsed")); 239 .reportCallWithDefaultArgument(ConsoleAPIType::kStartGroupCollapsed,
240 String16("console.groupCollapsed"));
242 } 241 }
243 242
244 void V8Console::groupEndCallback( 243 void V8Console::groupEndCallback(
245 const v8::FunctionCallbackInfo<v8::Value>& info) { 244 const v8::FunctionCallbackInfo<v8::Value>& info) {
246 ConsoleHelper(info).reportCallWithDefaultArgument( 245 ConsoleHelper(info, m_inspector)
247 ConsoleAPIType::kEndGroup, String16("console.groupEnd")); 246 .reportCallWithDefaultArgument(ConsoleAPIType::kEndGroup,
247 String16("console.groupEnd"));
248 } 248 }
249 249
250 void V8Console::clearCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 250 void V8Console::clearCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
251 ConsoleHelper helper(info); 251 ConsoleHelper helper(info, m_inspector);
252 if (!helper.groupId()) return; 252 if (!helper.groupId()) return;
253 helper.inspector()->client()->consoleClear(helper.groupId()); 253 m_inspector->client()->consoleClear(helper.groupId());
254 helper.reportCallWithDefaultArgument(ConsoleAPIType::kClear, 254 helper.reportCallWithDefaultArgument(ConsoleAPIType::kClear,
255 String16("console.clear")); 255 String16("console.clear"));
256 } 256 }
257 257
258 void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 258 void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
259 ConsoleHelper helper(info); 259 ConsoleHelper helper(info, m_inspector);
260 String16 title = helper.firstArgToString(String16()); 260 String16 title = helper.firstArgToString(String16());
261 String16 identifier; 261 String16 identifier;
262 if (title.isEmpty()) { 262 if (title.isEmpty()) {
263 std::unique_ptr<V8StackTraceImpl> stackTrace = 263 std::unique_ptr<V8StackTraceImpl> stackTrace =
264 V8StackTraceImpl::capture(nullptr, 0, 1); 264 V8StackTraceImpl::capture(nullptr, 0, 1);
265 if (stackTrace && !stackTrace->isEmpty()) { 265 if (stackTrace && !stackTrace->isEmpty()) {
266 identifier = toString16(stackTrace->topSourceURL()) + ":" + 266 identifier = toString16(stackTrace->topSourceURL()) + ":" +
267 String16::fromInteger(stackTrace->topLineNumber()); 267 String16::fromInteger(stackTrace->topLineNumber());
268 } 268 }
269 } else { 269 } else {
270 identifier = title + "@"; 270 identifier = title + "@";
271 } 271 }
272 272
273 int count = 273 int count =
274 helper.consoleMessageStorage()->count(helper.contextId(), identifier); 274 helper.consoleMessageStorage()->count(helper.contextId(), identifier);
275 String16 countString = String16::fromInteger(count); 275 String16 countString = String16::fromInteger(count);
276 helper.reportCallWithArgument( 276 helper.reportCallWithArgument(
277 ConsoleAPIType::kCount, 277 ConsoleAPIType::kCount,
278 title.isEmpty() ? countString : (title + ": " + countString)); 278 title.isEmpty() ? countString : (title + ": " + countString));
279 } 279 }
280 280
281 void V8Console::assertCallback( 281 void V8Console::assertCallback(
282 const v8::FunctionCallbackInfo<v8::Value>& info) { 282 const v8::FunctionCallbackInfo<v8::Value>& info) {
283 ConsoleHelper helper(info); 283 ConsoleHelper helper(info, m_inspector);
284 if (helper.firstArgToBoolean(false)) return; 284 if (helper.firstArgToBoolean(false)) return;
285 285
286 std::vector<v8::Local<v8::Value>> arguments; 286 std::vector<v8::Local<v8::Value>> arguments;
287 for (int i = 1; i < info.Length(); ++i) arguments.push_back(info[i]); 287 for (int i = 1; i < info.Length(); ++i) arguments.push_back(info[i]);
288 if (info.Length() < 2) 288 if (info.Length() < 2)
289 arguments.push_back( 289 arguments.push_back(
290 toV8String(info.GetIsolate(), String16("console.assert"))); 290 toV8String(info.GetIsolate(), String16("console.assert")));
291 helper.reportCall(ConsoleAPIType::kAssert, arguments); 291 helper.reportCall(ConsoleAPIType::kAssert, arguments);
292 292
293 if (V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent()) 293 if (V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent())
294 debuggerAgent->breakProgramOnException( 294 debuggerAgent->breakProgramOnException(
295 protocol::Debugger::Paused::ReasonEnum::Assert, nullptr); 295 protocol::Debugger::Paused::ReasonEnum::Assert, nullptr);
296 } 296 }
297 297
298 void V8Console::markTimelineCallback( 298 void V8Console::markTimelineCallback(
299 const v8::FunctionCallbackInfo<v8::Value>& info) { 299 const v8::FunctionCallbackInfo<v8::Value>& info) {
300 ConsoleHelper(info).reportDeprecatedCall("V8Console#markTimelineDeprecated", 300 ConsoleHelper(info, m_inspector)
301 "'console.markTimeline' is " 301 .reportDeprecatedCall("V8Console#markTimelineDeprecated",
302 "deprecated. Please use " 302 "'console.markTimeline' is "
303 "'console.timeStamp' instead."); 303 "deprecated. Please use "
304 "'console.timeStamp' instead.");
304 timeStampCallback(info); 305 timeStampCallback(info);
305 } 306 }
306 307
307 void V8Console::profileCallback( 308 void V8Console::profileCallback(
308 const v8::FunctionCallbackInfo<v8::Value>& info) { 309 const v8::FunctionCallbackInfo<v8::Value>& info) {
309 ConsoleHelper helper(info); 310 ConsoleHelper helper(info, m_inspector);
310 if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent()) 311 if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent())
311 profilerAgent->consoleProfile(helper.firstArgToString(String16())); 312 profilerAgent->consoleProfile(helper.firstArgToString(String16()));
312 } 313 }
313 314
314 void V8Console::profileEndCallback( 315 void V8Console::profileEndCallback(
315 const v8::FunctionCallbackInfo<v8::Value>& info) { 316 const v8::FunctionCallbackInfo<v8::Value>& info) {
316 ConsoleHelper helper(info); 317 ConsoleHelper helper(info, m_inspector);
317 if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent()) 318 if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent())
318 profilerAgent->consoleProfileEnd(helper.firstArgToString(String16())); 319 profilerAgent->consoleProfileEnd(helper.firstArgToString(String16()));
319 } 320 }
320 321
321 static void timeFunction(const v8::FunctionCallbackInfo<v8::Value>& info, 322 static void timeFunction(const v8::FunctionCallbackInfo<v8::Value>& info,
322 bool timelinePrefix) { 323 bool timelinePrefix, V8InspectorImpl* inspector) {
323 ConsoleHelper helper(info); 324 ConsoleHelper helper(info, inspector);
324 V8InspectorClient* client = helper.inspector()->client();
325 String16 protocolTitle = helper.firstArgToString("default"); 325 String16 protocolTitle = helper.firstArgToString("default");
326 if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'"; 326 if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'";
327 client->consoleTime(toStringView(protocolTitle)); 327 inspector->client()->consoleTime(toStringView(protocolTitle));
328 helper.consoleMessageStorage()->time(helper.contextId(), protocolTitle); 328 helper.consoleMessageStorage()->time(helper.contextId(), protocolTitle);
329 } 329 }
330 330
331 static void timeEndFunction(const v8::FunctionCallbackInfo<v8::Value>& info, 331 static void timeEndFunction(const v8::FunctionCallbackInfo<v8::Value>& info,
332 bool timelinePrefix) { 332 bool timelinePrefix, V8InspectorImpl* inspector) {
333 ConsoleHelper helper(info); 333 ConsoleHelper helper(info, inspector);
334 V8InspectorClient* client = helper.inspector()->client();
335 String16 protocolTitle = helper.firstArgToString("default"); 334 String16 protocolTitle = helper.firstArgToString("default");
336 if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'"; 335 if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'";
337 client->consoleTimeEnd(toStringView(protocolTitle)); 336 inspector->client()->consoleTimeEnd(toStringView(protocolTitle));
338 double elapsed = helper.consoleMessageStorage()->timeEnd(helper.contextId(), 337 double elapsed = helper.consoleMessageStorage()->timeEnd(helper.contextId(),
339 protocolTitle); 338 protocolTitle);
340 String16 message = 339 String16 message =
341 protocolTitle + ": " + String16::fromDouble(elapsed) + "ms"; 340 protocolTitle + ": " + String16::fromDouble(elapsed) + "ms";
342 helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message); 341 helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message);
343 } 342 }
344 343
345 void V8Console::timelineCallback( 344 void V8Console::timelineCallback(
346 const v8::FunctionCallbackInfo<v8::Value>& info) { 345 const v8::FunctionCallbackInfo<v8::Value>& info) {
347 ConsoleHelper(info).reportDeprecatedCall( 346 ConsoleHelper(info, m_inspector)
348 "V8Console#timeline", 347 .reportDeprecatedCall("V8Console#timeline",
349 "'console.timeline' is deprecated. Please use 'console.time' instead."); 348 "'console.timeline' is deprecated. Please use "
350 timeFunction(info, true); 349 "'console.time' instead.");
350 timeFunction(info, true, m_inspector);
351 } 351 }
352 352
353 void V8Console::timelineEndCallback( 353 void V8Console::timelineEndCallback(
354 const v8::FunctionCallbackInfo<v8::Value>& info) { 354 const v8::FunctionCallbackInfo<v8::Value>& info) {
355 ConsoleHelper(info).reportDeprecatedCall("V8Console#timelineEnd", 355 ConsoleHelper(info, m_inspector)
356 "'console.timelineEnd' is " 356 .reportDeprecatedCall("V8Console#timelineEnd",
357 "deprecated. Please use " 357 "'console.timelineEnd' is "
358 "'console.timeEnd' instead."); 358 "deprecated. Please use "
359 timeEndFunction(info, true); 359 "'console.timeEnd' instead.");
360 timeEndFunction(info, true, m_inspector);
360 } 361 }
361 362
362 void V8Console::timeCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 363 void V8Console::timeCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
363 timeFunction(info, false); 364 timeFunction(info, false, m_inspector);
364 } 365 }
365 366
366 void V8Console::timeEndCallback( 367 void V8Console::timeEndCallback(
367 const v8::FunctionCallbackInfo<v8::Value>& info) { 368 const v8::FunctionCallbackInfo<v8::Value>& info) {
368 timeEndFunction(info, false); 369 timeEndFunction(info, false, m_inspector);
369 } 370 }
370 371
371 void V8Console::timeStampCallback( 372 void V8Console::timeStampCallback(
372 const v8::FunctionCallbackInfo<v8::Value>& info) { 373 const v8::FunctionCallbackInfo<v8::Value>& info) {
373 ConsoleHelper helper(info); 374 ConsoleHelper helper(info, m_inspector);
374 String16 title = helper.firstArgToString(String16()); 375 String16 title = helper.firstArgToString(String16());
375 helper.inspector()->client()->consoleTimeStamp(toStringView(title)); 376 m_inspector->client()->consoleTimeStamp(toStringView(title));
376 } 377 }
377 378
378 void V8Console::memoryGetterCallback( 379 void V8Console::memoryGetterCallback(
379 const v8::FunctionCallbackInfo<v8::Value>& info) { 380 const v8::FunctionCallbackInfo<v8::Value>& info) {
380 V8InspectorClient* client = ConsoleHelper(info).inspector()->client();
381 v8::Local<v8::Value> memoryValue; 381 v8::Local<v8::Value> memoryValue;
382 if (!client 382 if (!m_inspector->client()
383 ->memoryInfo(info.GetIsolate(), 383 ->memoryInfo(info.GetIsolate(),
384 info.GetIsolate()->GetCurrentContext()) 384 info.GetIsolate()->GetCurrentContext())
385 .ToLocal(&memoryValue)) 385 .ToLocal(&memoryValue))
386 return; 386 return;
387 info.GetReturnValue().Set(memoryValue); 387 info.GetReturnValue().Set(memoryValue);
388 } 388 }
389 389
390 void V8Console::memorySetterCallback( 390 void V8Console::memorySetterCallback(
391 const v8::FunctionCallbackInfo<v8::Value>& info) { 391 const v8::FunctionCallbackInfo<v8::Value>& info) {
392 // We can't make the attribute readonly as it breaks existing code that relies 392 // We can't make the attribute readonly as it breaks existing code that relies
393 // on being able to assign to console.memory in strict mode. Instead, the 393 // on being able to assign to console.memory in strict mode. Instead, the
394 // setter just ignores the passed value. http://crbug.com/468611 394 // setter just ignores the passed value. http://crbug.com/468611
395 } 395 }
396 396
397 void V8Console::keysCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 397 void V8Console::keysCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
398 v8::Isolate* isolate = info.GetIsolate(); 398 v8::Isolate* isolate = info.GetIsolate();
399 info.GetReturnValue().Set(v8::Array::New(isolate)); 399 info.GetReturnValue().Set(v8::Array::New(isolate));
400 400
401 ConsoleHelper helper(info); 401 ConsoleHelper helper(info, m_inspector);
402 v8::Local<v8::Object> obj; 402 v8::Local<v8::Object> obj;
403 if (!helper.firstArgAsObject().ToLocal(&obj)) return; 403 if (!helper.firstArgAsObject().ToLocal(&obj)) return;
404 v8::Local<v8::Array> names; 404 v8::Local<v8::Array> names;
405 if (!obj->GetOwnPropertyNames(isolate->GetCurrentContext()).ToLocal(&names)) 405 if (!obj->GetOwnPropertyNames(isolate->GetCurrentContext()).ToLocal(&names))
406 return; 406 return;
407 info.GetReturnValue().Set(names); 407 info.GetReturnValue().Set(names);
408 } 408 }
409 409
410 void V8Console::valuesCallback( 410 void V8Console::valuesCallback(
411 const v8::FunctionCallbackInfo<v8::Value>& info) { 411 const v8::FunctionCallbackInfo<v8::Value>& info) {
412 v8::Isolate* isolate = info.GetIsolate(); 412 v8::Isolate* isolate = info.GetIsolate();
413 info.GetReturnValue().Set(v8::Array::New(isolate)); 413 info.GetReturnValue().Set(v8::Array::New(isolate));
414 414
415 ConsoleHelper helper(info); 415 ConsoleHelper helper(info, m_inspector);
416 v8::Local<v8::Object> obj; 416 v8::Local<v8::Object> obj;
417 if (!helper.firstArgAsObject().ToLocal(&obj)) return; 417 if (!helper.firstArgAsObject().ToLocal(&obj)) return;
418 v8::Local<v8::Array> names; 418 v8::Local<v8::Array> names;
419 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 419 v8::Local<v8::Context> context = isolate->GetCurrentContext();
420 if (!obj->GetOwnPropertyNames(context).ToLocal(&names)) return; 420 if (!obj->GetOwnPropertyNames(context).ToLocal(&names)) return;
421 v8::Local<v8::Array> values = v8::Array::New(isolate, names->Length()); 421 v8::Local<v8::Array> values = v8::Array::New(isolate, names->Length());
422 for (uint32_t i = 0; i < names->Length(); ++i) { 422 for (uint32_t i = 0; i < names->Length(); ++i) {
423 v8::Local<v8::Value> key; 423 v8::Local<v8::Value> key;
424 if (!names->Get(context, i).ToLocal(&key)) continue; 424 if (!names->Get(context, i).ToLocal(&key)) continue;
425 v8::Local<v8::Value> value; 425 v8::Local<v8::Value> value;
(...skipping 18 matching lines...) Expand all
444 if (enable) 444 if (enable)
445 debuggerAgent->setBreakpointAt(scriptId, lineNumber, columnNumber, source, 445 debuggerAgent->setBreakpointAt(scriptId, lineNumber, columnNumber, source,
446 condition); 446 condition);
447 else 447 else
448 debuggerAgent->removeBreakpointAt(scriptId, lineNumber, columnNumber, 448 debuggerAgent->removeBreakpointAt(scriptId, lineNumber, columnNumber,
449 source); 449 source);
450 } 450 }
451 451
452 void V8Console::debugFunctionCallback( 452 void V8Console::debugFunctionCallback(
453 const v8::FunctionCallbackInfo<v8::Value>& info) { 453 const v8::FunctionCallbackInfo<v8::Value>& info) {
454 ConsoleHelper helper(info); 454 ConsoleHelper helper(info, m_inspector);
455 v8::Local<v8::Function> function; 455 v8::Local<v8::Function> function;
456 if (!helper.firstArgAsFunction().ToLocal(&function)) return; 456 if (!helper.firstArgAsFunction().ToLocal(&function)) return;
457 setFunctionBreakpoint(helper, function, 457 setFunctionBreakpoint(helper, function,
458 V8DebuggerAgentImpl::DebugCommandBreakpointSource, 458 V8DebuggerAgentImpl::DebugCommandBreakpointSource,
459 String16(), true); 459 String16(), true);
460 } 460 }
461 461
462 void V8Console::undebugFunctionCallback( 462 void V8Console::undebugFunctionCallback(
463 const v8::FunctionCallbackInfo<v8::Value>& info) { 463 const v8::FunctionCallbackInfo<v8::Value>& info) {
464 ConsoleHelper helper(info); 464 ConsoleHelper helper(info, m_inspector);
465 v8::Local<v8::Function> function; 465 v8::Local<v8::Function> function;
466 if (!helper.firstArgAsFunction().ToLocal(&function)) return; 466 if (!helper.firstArgAsFunction().ToLocal(&function)) return;
467 setFunctionBreakpoint(helper, function, 467 setFunctionBreakpoint(helper, function,
468 V8DebuggerAgentImpl::DebugCommandBreakpointSource, 468 V8DebuggerAgentImpl::DebugCommandBreakpointSource,
469 String16(), false); 469 String16(), false);
470 } 470 }
471 471
472 void V8Console::monitorFunctionCallback( 472 void V8Console::monitorFunctionCallback(
473 const v8::FunctionCallbackInfo<v8::Value>& info) { 473 const v8::FunctionCallbackInfo<v8::Value>& info) {
474 ConsoleHelper helper(info); 474 ConsoleHelper helper(info, m_inspector);
475 v8::Local<v8::Function> function; 475 v8::Local<v8::Function> function;
476 if (!helper.firstArgAsFunction().ToLocal(&function)) return; 476 if (!helper.firstArgAsFunction().ToLocal(&function)) return;
477 v8::Local<v8::Value> name = function->GetName(); 477 v8::Local<v8::Value> name = function->GetName();
478 if (!name->IsString() || !v8::Local<v8::String>::Cast(name)->Length()) 478 if (!name->IsString() || !v8::Local<v8::String>::Cast(name)->Length())
479 name = function->GetInferredName(); 479 name = function->GetInferredName();
480 String16 functionName = toProtocolStringWithTypeCheck(name); 480 String16 functionName = toProtocolStringWithTypeCheck(name);
481 String16Builder builder; 481 String16Builder builder;
482 builder.append("console.log(\"function "); 482 builder.append("console.log(\"function ");
483 if (functionName.isEmpty()) 483 if (functionName.isEmpty())
484 builder.append("(anonymous function)"); 484 builder.append("(anonymous function)");
485 else 485 else
486 builder.append(functionName); 486 builder.append(functionName);
487 builder.append( 487 builder.append(
488 " called\" + (arguments.length > 0 ? \" with arguments: \" + " 488 " called\" + (arguments.length > 0 ? \" with arguments: \" + "
489 "Array.prototype.join.call(arguments, \", \") : \"\")) && false"); 489 "Array.prototype.join.call(arguments, \", \") : \"\")) && false");
490 setFunctionBreakpoint(helper, function, 490 setFunctionBreakpoint(helper, function,
491 V8DebuggerAgentImpl::MonitorCommandBreakpointSource, 491 V8DebuggerAgentImpl::MonitorCommandBreakpointSource,
492 builder.toString(), true); 492 builder.toString(), true);
493 } 493 }
494 494
495 void V8Console::unmonitorFunctionCallback( 495 void V8Console::unmonitorFunctionCallback(
496 const v8::FunctionCallbackInfo<v8::Value>& info) { 496 const v8::FunctionCallbackInfo<v8::Value>& info) {
497 ConsoleHelper helper(info); 497 ConsoleHelper helper(info, m_inspector);
498 v8::Local<v8::Function> function; 498 v8::Local<v8::Function> function;
499 if (!helper.firstArgAsFunction().ToLocal(&function)) return; 499 if (!helper.firstArgAsFunction().ToLocal(&function)) return;
500 setFunctionBreakpoint(helper, function, 500 setFunctionBreakpoint(helper, function,
501 V8DebuggerAgentImpl::MonitorCommandBreakpointSource, 501 V8DebuggerAgentImpl::MonitorCommandBreakpointSource,
502 String16(), false); 502 String16(), false);
503 } 503 }
504 504
505 void V8Console::lastEvaluationResultCallback( 505 void V8Console::lastEvaluationResultCallback(
506 const v8::FunctionCallbackInfo<v8::Value>& info) { 506 const v8::FunctionCallbackInfo<v8::Value>& info) {
507 ConsoleHelper helper(info); 507 ConsoleHelper helper(info, m_inspector);
508 InjectedScript* injectedScript = helper.injectedScript(); 508 InjectedScript* injectedScript = helper.injectedScript();
509 if (!injectedScript) return; 509 if (!injectedScript) return;
510 info.GetReturnValue().Set(injectedScript->lastEvaluationResult()); 510 info.GetReturnValue().Set(injectedScript->lastEvaluationResult());
511 } 511 }
512 512
513 static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info, 513 static void inspectImpl(const v8::FunctionCallbackInfo<v8::Value>& info,
514 bool copyToClipboard) { 514 bool copyToClipboard, V8InspectorImpl* inspector) {
515 if (info.Length() < 1) return; 515 if (info.Length() < 1) return;
516 if (!copyToClipboard) info.GetReturnValue().Set(info[0]); 516 if (!copyToClipboard) info.GetReturnValue().Set(info[0]);
517 517
518 ConsoleHelper helper(info); 518 ConsoleHelper helper(info, inspector);
519 InjectedScript* injectedScript = helper.injectedScript(); 519 InjectedScript* injectedScript = helper.injectedScript();
520 if (!injectedScript) return; 520 if (!injectedScript) return;
521 std::unique_ptr<protocol::Runtime::RemoteObject> wrappedObject; 521 std::unique_ptr<protocol::Runtime::RemoteObject> wrappedObject;
522 protocol::Response response = 522 protocol::Response response =
523 injectedScript->wrapObject(info[0], "", false /** forceValueType */, 523 injectedScript->wrapObject(info[0], "", false /** forceValueType */,
524 false /** generatePreview */, &wrappedObject); 524 false /** generatePreview */, &wrappedObject);
525 if (!response.isSuccess()) return; 525 if (!response.isSuccess()) return;
526 526
527 std::unique_ptr<protocol::DictionaryValue> hints = 527 std::unique_ptr<protocol::DictionaryValue> hints =
528 protocol::DictionaryValue::create(); 528 protocol::DictionaryValue::create();
529 if (copyToClipboard) hints->setBoolean("copyToClipboard", true); 529 if (copyToClipboard) hints->setBoolean("copyToClipboard", true);
530 if (V8InspectorSessionImpl* session = helper.currentSession()) { 530 if (V8InspectorSessionImpl* session = helper.currentSession()) {
531 session->runtimeAgent()->inspect(std::move(wrappedObject), 531 session->runtimeAgent()->inspect(std::move(wrappedObject),
532 std::move(hints)); 532 std::move(hints));
533 } 533 }
534 } 534 }
535 535
536 void V8Console::inspectCallback( 536 void V8Console::inspectCallback(
537 const v8::FunctionCallbackInfo<v8::Value>& info) { 537 const v8::FunctionCallbackInfo<v8::Value>& info) {
538 inspectImpl(info, false); 538 inspectImpl(info, false, m_inspector);
539 } 539 }
540 540
541 void V8Console::copyCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { 541 void V8Console::copyCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
542 inspectImpl(info, true); 542 inspectImpl(info, true, m_inspector);
543 } 543 }
544 544
545 void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info, 545 void V8Console::inspectedObject(const v8::FunctionCallbackInfo<v8::Value>& info,
546 unsigned num) { 546 unsigned num) {
547 DCHECK(num < V8InspectorSessionImpl::kInspectedObjectBufferSize); 547 DCHECK(num < V8InspectorSessionImpl::kInspectedObjectBufferSize);
548 ConsoleHelper helper(info); 548 ConsoleHelper helper(info, m_inspector);
549 if (V8InspectorSessionImpl* session = helper.currentSession()) { 549 if (V8InspectorSessionImpl* session = helper.currentSession()) {
550 V8InspectorSession::Inspectable* object = session->inspectedObject(num); 550 V8InspectorSession::Inspectable* object = session->inspectedObject(num);
551 v8::Isolate* isolate = info.GetIsolate(); 551 v8::Isolate* isolate = info.GetIsolate();
552 if (object) 552 if (object)
553 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext())); 553 info.GetReturnValue().Set(object->get(isolate->GetCurrentContext()));
554 else 554 else
555 info.GetReturnValue().Set(v8::Undefined(isolate)); 555 info.GetReturnValue().Set(v8::Undefined(isolate));
556 } 556 }
557 } 557 }
558 558
559 v8::Local<v8::Object> V8Console::createConsole( 559 v8::Local<v8::Object> V8Console::createConsole(v8::Local<v8::Context> context) {
560 InspectedContext* inspectedContext) {
561 v8::Local<v8::Context> context = inspectedContext->context();
562 v8::Context::Scope contextScope(context); 560 v8::Context::Scope contextScope(context);
563 v8::Isolate* isolate = context->GetIsolate(); 561 v8::Isolate* isolate = context->GetIsolate();
564 v8::MicrotasksScope microtasksScope(isolate, 562 v8::MicrotasksScope microtasksScope(isolate,
565 v8::MicrotasksScope::kDoNotRunMicrotasks); 563 v8::MicrotasksScope::kDoNotRunMicrotasks);
566 564
567 v8::Local<v8::Object> console = v8::Object::New(isolate); 565 v8::Local<v8::Object> console = v8::Object::New(isolate);
568 bool success = 566 bool success =
569 console->SetPrototype(context, v8::Object::New(isolate)).FromMaybe(false); 567 console->SetPrototype(context, v8::Object::New(isolate)).FromMaybe(false);
570 DCHECK(success); 568 DCHECK(success);
571 USE(success); 569 USE(success);
572 570
573 v8::Local<v8::External> data = 571 v8::Local<v8::External> data = v8::External::New(isolate, this);
574 v8::External::New(isolate, inspectedContext->inspector());
575 createBoundFunctionProperty(context, console, data, "debug", 572 createBoundFunctionProperty(context, console, data, "debug",
576 V8Console::debugCallback); 573 &V8Console::call<&V8Console::debugCallback>);
577 createBoundFunctionProperty(context, console, data, "error", 574 createBoundFunctionProperty(context, console, data, "error",
578 V8Console::errorCallback); 575 &V8Console::call<&V8Console::errorCallback>);
579 createBoundFunctionProperty(context, console, data, "info", 576 createBoundFunctionProperty(context, console, data, "info",
580 V8Console::infoCallback); 577 &V8Console::call<&V8Console::infoCallback>);
581 createBoundFunctionProperty(context, console, data, "log", 578 createBoundFunctionProperty(context, console, data, "log",
582 V8Console::logCallback); 579 &V8Console::call<&V8Console::logCallback>);
583 createBoundFunctionProperty(context, console, data, "warn", 580 createBoundFunctionProperty(context, console, data, "warn",
584 V8Console::warnCallback); 581 &V8Console::call<&V8Console::warnCallback>);
585 createBoundFunctionProperty(context, console, data, "dir", 582 createBoundFunctionProperty(context, console, data, "dir",
586 V8Console::dirCallback); 583 &V8Console::call<&V8Console::dirCallback>);
587 createBoundFunctionProperty(context, console, data, "dirxml", 584 createBoundFunctionProperty(context, console, data, "dirxml",
588 V8Console::dirxmlCallback); 585 &V8Console::call<&V8Console::dirxmlCallback>);
589 createBoundFunctionProperty(context, console, data, "table", 586 createBoundFunctionProperty(context, console, data, "table",
590 V8Console::tableCallback); 587 &V8Console::call<&V8Console::tableCallback>);
591 createBoundFunctionProperty(context, console, data, "trace", 588 createBoundFunctionProperty(context, console, data, "trace",
592 V8Console::traceCallback); 589 &V8Console::call<&V8Console::traceCallback>);
593 createBoundFunctionProperty(context, console, data, "group", 590 createBoundFunctionProperty(context, console, data, "group",
594 V8Console::groupCallback); 591 &V8Console::call<&V8Console::groupCallback>);
595 createBoundFunctionProperty(context, console, data, "groupCollapsed", 592 createBoundFunctionProperty(
596 V8Console::groupCollapsedCallback); 593 context, console, data, "groupCollapsed",
594 &V8Console::call<&V8Console::groupCollapsedCallback>);
597 createBoundFunctionProperty(context, console, data, "groupEnd", 595 createBoundFunctionProperty(context, console, data, "groupEnd",
598 V8Console::groupEndCallback); 596 &V8Console::call<&V8Console::groupEndCallback>);
599 createBoundFunctionProperty(context, console, data, "clear", 597 createBoundFunctionProperty(context, console, data, "clear",
600 V8Console::clearCallback); 598 &V8Console::call<&V8Console::clearCallback>);
601 createBoundFunctionProperty(context, console, data, "count", 599 createBoundFunctionProperty(context, console, data, "count",
602 V8Console::countCallback); 600 &V8Console::call<&V8Console::countCallback>);
603 createBoundFunctionProperty(context, console, data, "assert", 601 createBoundFunctionProperty(context, console, data, "assert",
604 V8Console::assertCallback); 602 &V8Console::call<&V8Console::assertCallback>);
605 createBoundFunctionProperty(context, console, data, "markTimeline", 603 createBoundFunctionProperty(
606 V8Console::markTimelineCallback); 604 context, console, data, "markTimeline",
605 &V8Console::call<&V8Console::markTimelineCallback>);
607 createBoundFunctionProperty(context, console, data, "profile", 606 createBoundFunctionProperty(context, console, data, "profile",
608 V8Console::profileCallback); 607 &V8Console::call<&V8Console::profileCallback>);
609 createBoundFunctionProperty(context, console, data, "profileEnd", 608 createBoundFunctionProperty(context, console, data, "profileEnd",
610 V8Console::profileEndCallback); 609 &V8Console::call<&V8Console::profileEndCallback>);
611 createBoundFunctionProperty(context, console, data, "timeline", 610 createBoundFunctionProperty(context, console, data, "timeline",
612 V8Console::timelineCallback); 611 &V8Console::call<&V8Console::timelineCallback>);
613 createBoundFunctionProperty(context, console, data, "timelineEnd", 612 createBoundFunctionProperty(
614 V8Console::timelineEndCallback); 613 context, console, data, "timelineEnd",
614 &V8Console::call<&V8Console::timelineEndCallback>);
615 createBoundFunctionProperty(context, console, data, "time", 615 createBoundFunctionProperty(context, console, data, "time",
616 V8Console::timeCallback); 616 &V8Console::call<&V8Console::timeCallback>);
617 createBoundFunctionProperty(context, console, data, "timeEnd", 617 createBoundFunctionProperty(context, console, data, "timeEnd",
618 V8Console::timeEndCallback); 618 &V8Console::call<&V8Console::timeEndCallback>);
619 createBoundFunctionProperty(context, console, data, "timeStamp", 619 createBoundFunctionProperty(context, console, data, "timeStamp",
620 V8Console::timeStampCallback); 620 &V8Console::call<&V8Console::timeStampCallback>);
621 return console; 621 return console;
622 } 622 }
623 623
624 void V8Console::installMemoryGetter(V8InspectorImpl* inspector, 624 void V8Console::installMemoryGetter(v8::Local<v8::Context> context,
625 v8::Local<v8::Context> context,
626 v8::Local<v8::Object> console) { 625 v8::Local<v8::Object> console) {
627 v8::Local<v8::External> data = 626 v8::Isolate* isolate = context->GetIsolate();
628 v8::External::New(inspector->isolate(), inspector); 627 v8::Local<v8::External> data = v8::External::New(isolate, this);
629 console->SetAccessorProperty( 628 console->SetAccessorProperty(
630 toV8StringInternalized(inspector->isolate(), "memory"), 629 toV8StringInternalized(isolate, "memory"),
631 v8::Function::New(context, V8Console::memoryGetterCallback, data, 0, 630 v8::Function::New(context,
632 v8::ConstructorBehavior::kThrow) 631 &V8Console::call<&V8Console::memoryGetterCallback>,
632 data, 0, v8::ConstructorBehavior::kThrow)
633 .ToLocalChecked(), 633 .ToLocalChecked(),
634 v8::Function::New(context, V8Console::memorySetterCallback, data, 0, 634 v8::Function::New(context,
635 v8::ConstructorBehavior::kThrow) 635 &V8Console::call<&V8Console::memorySetterCallback>,
636 data, 0, v8::ConstructorBehavior::kThrow)
636 .ToLocalChecked(), 637 .ToLocalChecked(),
637 static_cast<v8::PropertyAttribute>(v8::None), v8::DEFAULT); 638 static_cast<v8::PropertyAttribute>(v8::None), v8::DEFAULT);
638 } 639 }
639 640
640 v8::Local<v8::Object> V8Console::createCommandLineAPI( 641 v8::Local<v8::Object> V8Console::createCommandLineAPI(
641 InspectedContext* inspectedContext) { 642 v8::Local<v8::Context> context) {
642 v8::Local<v8::Context> context = inspectedContext->context();
643 v8::Isolate* isolate = context->GetIsolate(); 643 v8::Isolate* isolate = context->GetIsolate();
644 v8::MicrotasksScope microtasksScope(isolate, 644 v8::MicrotasksScope microtasksScope(isolate,
645 v8::MicrotasksScope::kDoNotRunMicrotasks); 645 v8::MicrotasksScope::kDoNotRunMicrotasks);
646 646
647 v8::Local<v8::Object> commandLineAPI = v8::Object::New(isolate); 647 v8::Local<v8::Object> commandLineAPI = v8::Object::New(isolate);
648 bool success = 648 bool success =
649 commandLineAPI->SetPrototype(context, v8::Null(isolate)).FromMaybe(false); 649 commandLineAPI->SetPrototype(context, v8::Null(isolate)).FromMaybe(false);
650 DCHECK(success); 650 DCHECK(success);
651 USE(success); 651 USE(success);
652 652
653 v8::Local<v8::External> data = 653 v8::Local<v8::External> data = v8::External::New(isolate, this);
654 v8::External::New(isolate, inspectedContext->inspector());
655 createBoundFunctionProperty(context, commandLineAPI, data, "dir", 654 createBoundFunctionProperty(context, commandLineAPI, data, "dir",
656 V8Console::dirCallback, 655 &V8Console::call<&V8Console::dirCallback>,
657 "function dir(value) { [Command Line API] }"); 656 "function dir(value) { [Command Line API] }");
658 createBoundFunctionProperty(context, commandLineAPI, data, "dirxml", 657 createBoundFunctionProperty(context, commandLineAPI, data, "dirxml",
659 V8Console::dirxmlCallback, 658 &V8Console::call<&V8Console::dirxmlCallback>,
660 "function dirxml(value) { [Command Line API] }"); 659 "function dirxml(value) { [Command Line API] }");
661 createBoundFunctionProperty(context, commandLineAPI, data, "profile", 660 createBoundFunctionProperty(context, commandLineAPI, data, "profile",
662 V8Console::profileCallback, 661 &V8Console::call<&V8Console::profileCallback>,
663 "function profile(title) { [Command Line API] }"); 662 "function profile(title) { [Command Line API] }");
664 createBoundFunctionProperty( 663 createBoundFunctionProperty(
665 context, commandLineAPI, data, "profileEnd", 664 context, commandLineAPI, data, "profileEnd",
666 V8Console::profileEndCallback, 665 &V8Console::call<&V8Console::profileEndCallback>,
667 "function profileEnd(title) { [Command Line API] }"); 666 "function profileEnd(title) { [Command Line API] }");
668 createBoundFunctionProperty(context, commandLineAPI, data, "clear", 667 createBoundFunctionProperty(context, commandLineAPI, data, "clear",
669 V8Console::clearCallback, 668 &V8Console::call<&V8Console::clearCallback>,
670 "function clear() { [Command Line API] }"); 669 "function clear() { [Command Line API] }");
671 createBoundFunctionProperty( 670 createBoundFunctionProperty(
672 context, commandLineAPI, data, "table", V8Console::tableCallback, 671 context, commandLineAPI, data, "table",
672 &V8Console::call<&V8Console::tableCallback>,
673 "function table(data, [columns]) { [Command Line API] }"); 673 "function table(data, [columns]) { [Command Line API] }");
674 674
675 createBoundFunctionProperty(context, commandLineAPI, data, "keys", 675 createBoundFunctionProperty(context, commandLineAPI, data, "keys",
676 V8Console::keysCallback, 676 &V8Console::call<&V8Console::keysCallback>,
677 "function keys(object) { [Command Line API] }"); 677 "function keys(object) { [Command Line API] }");
678 createBoundFunctionProperty(context, commandLineAPI, data, "values", 678 createBoundFunctionProperty(context, commandLineAPI, data, "values",
679 V8Console::valuesCallback, 679 &V8Console::call<&V8Console::valuesCallback>,
680 "function values(object) { [Command Line API] }"); 680 "function values(object) { [Command Line API] }");
681 createBoundFunctionProperty( 681 createBoundFunctionProperty(
682 context, commandLineAPI, data, "debug", V8Console::debugFunctionCallback, 682 context, commandLineAPI, data, "debug",
683 &V8Console::call<&V8Console::debugFunctionCallback>,
683 "function debug(function) { [Command Line API] }"); 684 "function debug(function) { [Command Line API] }");
684 createBoundFunctionProperty( 685 createBoundFunctionProperty(
685 context, commandLineAPI, data, "undebug", 686 context, commandLineAPI, data, "undebug",
686 V8Console::undebugFunctionCallback, 687 &V8Console::call<&V8Console::undebugFunctionCallback>,
687 "function undebug(function) { [Command Line API] }"); 688 "function undebug(function) { [Command Line API] }");
688 createBoundFunctionProperty( 689 createBoundFunctionProperty(
689 context, commandLineAPI, data, "monitor", 690 context, commandLineAPI, data, "monitor",
690 V8Console::monitorFunctionCallback, 691 &V8Console::call<&V8Console::monitorFunctionCallback>,
691 "function monitor(function) { [Command Line API] }"); 692 "function monitor(function) { [Command Line API] }");
692 createBoundFunctionProperty( 693 createBoundFunctionProperty(
693 context, commandLineAPI, data, "unmonitor", 694 context, commandLineAPI, data, "unmonitor",
694 V8Console::unmonitorFunctionCallback, 695 &V8Console::call<&V8Console::unmonitorFunctionCallback>,
695 "function unmonitor(function) { [Command Line API] }"); 696 "function unmonitor(function) { [Command Line API] }");
696 createBoundFunctionProperty( 697 createBoundFunctionProperty(
697 context, commandLineAPI, data, "inspect", V8Console::inspectCallback, 698 context, commandLineAPI, data, "inspect",
699 &V8Console::call<&V8Console::inspectCallback>,
698 "function inspect(object) { [Command Line API] }"); 700 "function inspect(object) { [Command Line API] }");
699 createBoundFunctionProperty(context, commandLineAPI, data, "copy", 701 createBoundFunctionProperty(context, commandLineAPI, data, "copy",
700 V8Console::copyCallback, 702 &V8Console::call<&V8Console::copyCallback>,
701 "function copy(value) { [Command Line API] }"); 703 "function copy(value) { [Command Line API] }");
702 createBoundFunctionProperty(context, commandLineAPI, data, "$_", 704 createBoundFunctionProperty(
703 V8Console::lastEvaluationResultCallback); 705 context, commandLineAPI, data, "$_",
706 &V8Console::call<&V8Console::lastEvaluationResultCallback>);
704 createBoundFunctionProperty(context, commandLineAPI, data, "$0", 707 createBoundFunctionProperty(context, commandLineAPI, data, "$0",
705 V8Console::inspectedObject0); 708 &V8Console::call<&V8Console::inspectedObject0>);
706 createBoundFunctionProperty(context, commandLineAPI, data, "$1", 709 createBoundFunctionProperty(context, commandLineAPI, data, "$1",
707 V8Console::inspectedObject1); 710 &V8Console::call<&V8Console::inspectedObject1>);
708 createBoundFunctionProperty(context, commandLineAPI, data, "$2", 711 createBoundFunctionProperty(context, commandLineAPI, data, "$2",
709 V8Console::inspectedObject2); 712 &V8Console::call<&V8Console::inspectedObject2>);
710 createBoundFunctionProperty(context, commandLineAPI, data, "$3", 713 createBoundFunctionProperty(context, commandLineAPI, data, "$3",
711 V8Console::inspectedObject3); 714 &V8Console::call<&V8Console::inspectedObject3>);
712 createBoundFunctionProperty(context, commandLineAPI, data, "$4", 715 createBoundFunctionProperty(context, commandLineAPI, data, "$4",
713 V8Console::inspectedObject4); 716 &V8Console::call<&V8Console::inspectedObject4>);
714 717
715 inspectedContext->inspector()->client()->installAdditionalCommandLineAPI( 718 m_inspector->client()->installAdditionalCommandLineAPI(context,
716 context, commandLineAPI); 719 commandLineAPI);
717 return commandLineAPI; 720 return commandLineAPI;
718 } 721 }
719 722
720 static bool isCommandLineAPIGetter(const String16& name) { 723 static bool isCommandLineAPIGetter(const String16& name) {
721 if (name.length() != 2) return false; 724 if (name.length() != 2) return false;
722 // $0 ... $4, $_ 725 // $0 ... $4, $_
723 return name[0] == '$' && 726 return name[0] == '$' &&
724 ((name[1] >= '0' && name[1] <= '4') || name[1] == '_'); 727 ((name[1] >= '0' && name[1] <= '4') || name[1] == '_');
725 } 728 }
726 729
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 ->GetOwnPropertyDescriptor( 816 ->GetOwnPropertyDescriptor(
814 m_context, v8::Local<v8::String>::Cast(name)) 817 m_context, v8::Local<v8::String>::Cast(name))
815 .ToLocal(&descriptor); 818 .ToLocal(&descriptor);
816 DCHECK(success); 819 DCHECK(success);
817 USE(success); 820 USE(success);
818 } 821 }
819 } 822 }
820 } 823 }
821 824
822 } // namespace v8_inspector 825 } // namespace v8_inspector
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698