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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8Console.cpp

Issue 1951773002: [DevTools] add console.time/timeEnd default value for argument (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/console/console-time-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "platform/v8_inspector/V8Console.h" 5 #include "platform/v8_inspector/V8Console.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/v8_inspector/InjectedScript.h" 8 #include "platform/v8_inspector/InjectedScript.h"
9 #include "platform/v8_inspector/InspectedContext.h" 9 #include "platform/v8_inspector/InspectedContext.h"
10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h" 10 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 { 366 {
367 ConsoleHelper helper(info); 367 ConsoleHelper helper(info);
368 if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent()) 368 if (V8ProfilerAgentImpl* profilerAgent = helper.profilerAgent())
369 profilerAgent->consoleProfileEnd(helper.firstArgToString(String16())); 369 profilerAgent->consoleProfileEnd(helper.firstArgToString(String16()));
370 } 370 }
371 371
372 static void timeFunction(const v8::FunctionCallbackInfo<v8::Value>& info, bool t imelinePrefix) 372 static void timeFunction(const v8::FunctionCallbackInfo<v8::Value>& info, bool t imelinePrefix)
373 { 373 {
374 ConsoleHelper helper(info); 374 ConsoleHelper helper(info);
375 if (V8DebuggerClient* client = helper.ensureDebuggerClient()) { 375 if (V8DebuggerClient* client = helper.ensureDebuggerClient()) {
376 String16 protocolTitle = helper.firstArgToString(String16()); 376 String16 protocolTitle = helper.firstArgToString("default");
377 if (timelinePrefix) 377 if (timelinePrefix)
378 protocolTitle = "Timeline '" + protocolTitle + "'"; 378 protocolTitle = "Timeline '" + protocolTitle + "'";
379 client->consoleTime(protocolTitle); 379 client->consoleTime(protocolTitle);
380 380
381 if (info.Length() < 1)
382 return;
383 v8::Local<v8::Map> timeMap; 381 v8::Local<v8::Map> timeMap;
384 if (!helper.privateMap("V8Console#timeMap").ToLocal(&timeMap)) 382 if (!helper.privateMap("V8Console#timeMap").ToLocal(&timeMap))
385 return; 383 return;
386 helper.setDoubleOnMap(timeMap, protocolTitle, client->currentTimeMS()); 384 helper.setDoubleOnMap(timeMap, protocolTitle, client->currentTimeMS());
387 } 385 }
388 } 386 }
389 387
390 static void timeEndFunction(const v8::FunctionCallbackInfo<v8::Value>& info, boo l timelinePrefix) 388 static void timeEndFunction(const v8::FunctionCallbackInfo<v8::Value>& info, boo l timelinePrefix)
391 { 389 {
392 ConsoleHelper helper(info); 390 ConsoleHelper helper(info);
393 if (V8DebuggerClient* client = helper.ensureDebuggerClient()) { 391 if (V8DebuggerClient* client = helper.ensureDebuggerClient()) {
394 String16 protocolTitle = helper.firstArgToString(String16()); 392 String16 protocolTitle = helper.firstArgToString("default");
395 if (timelinePrefix) 393 if (timelinePrefix)
396 protocolTitle = "Timeline '" + protocolTitle + "'"; 394 protocolTitle = "Timeline '" + protocolTitle + "'";
397 client->consoleTimeEnd(protocolTitle); 395 client->consoleTimeEnd(protocolTitle);
398 396
399 if (info.Length() < 1)
400 return;
401 v8::Local<v8::Map> timeMap; 397 v8::Local<v8::Map> timeMap;
402 if (!helper.privateMap("V8Console#timeMap").ToLocal(&timeMap)) 398 if (!helper.privateMap("V8Console#timeMap").ToLocal(&timeMap))
403 return; 399 return;
404 double elapsed = client->currentTimeMS() - helper.getDoubleFromMap(timeM ap, protocolTitle, 0.0); 400 double elapsed = client->currentTimeMS() - helper.getDoubleFromMap(timeM ap, protocolTitle, 0.0);
405 String16 message = protocolTitle + ": " + String16::fromDoubleFixedPreci sion(elapsed, 3) + "ms"; 401 String16 message = protocolTitle + ": " + String16::fromDoubleFixedPreci sion(elapsed, 3) + "ms";
406 helper.addMessage(TimeEndMessageType, DebugMessageLevel, message); 402 helper.addMessage(TimeEndMessageType, DebugMessageLevel, message);
407 } 403 }
408 } 404 }
409 405
410 void V8Console::timelineCallback(const v8::FunctionCallbackInfo<v8::Value>& info ) 406 void V8Console::timelineCallback(const v8::FunctionCallbackInfo<v8::Value>& info )
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, getters, ()); 709 DEFINE_STATIC_LOCAL(protocol::HashSet<String16>, getters, ());
714 if (getters.size() == 0) { 710 if (getters.size() == 0) {
715 const char* members[] = { "$0", "$1", "$2", "$3", "$4", "$_" }; 711 const char* members[] = { "$0", "$1", "$2", "$3", "$4", "$_" };
716 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i) 712 for (size_t i = 0; i < WTF_ARRAY_LENGTH(members); ++i)
717 getters.add(members[i]); 713 getters.add(members[i]);
718 } 714 }
719 return getters.find(name) != getters.end(); 715 return getters.find(name) != getters.end();
720 } 716 }
721 717
722 } // namespace blink 718 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/console/console-time-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698