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

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

Issue 2226863003: [DevTools] Reduce API surface of String16. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 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/Platform.h" 7 #include "platform/inspector_protocol/Platform.h"
8 #include "platform/inspector_protocol/String16.h" 8 #include "platform/inspector_protocol/String16.h"
9 #include "platform/v8_inspector/InjectedScript.h" 9 #include "platform/v8_inspector/InjectedScript.h"
10 #include "platform/v8_inspector/InspectedContext.h" 10 #include "platform/v8_inspector/InspectedContext.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 353
354 void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 354 void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
355 { 355 {
356 ConsoleHelper helper(info); 356 ConsoleHelper helper(info);
357 357
358 String16 title = helper.firstArgToString(String16()); 358 String16 title = helper.firstArgToString(String16());
359 String16 identifier; 359 String16 identifier;
360 if (title.isEmpty()) { 360 if (title.isEmpty()) {
361 std::unique_ptr<V8StackTraceImpl> stackTrace = V8StackTraceImpl::capture (nullptr, 0, 1); 361 std::unique_ptr<V8StackTraceImpl> stackTrace = V8StackTraceImpl::capture (nullptr, 0, 1);
362 if (stackTrace) 362 if (stackTrace)
363 identifier = stackTrace->topSourceURL() + ":" + String16::fromIntege r(stackTrace->topLineNumber()); 363 identifier = stackTrace->topSourceURL() + ":" + protocol::string16Fr omInteger(stackTrace->topLineNumber());
364 } else { 364 } else {
365 identifier = title + "@"; 365 identifier = title + "@";
366 } 366 }
367 367
368 v8::Local<v8::Map> countMap; 368 v8::Local<v8::Map> countMap;
369 if (!helper.privateMap("V8Console#countMap").ToLocal(&countMap)) 369 if (!helper.privateMap("V8Console#countMap").ToLocal(&countMap))
370 return; 370 return;
371 int64_t count = helper.getIntFromMap(countMap, identifier, 0) + 1; 371 int64_t count = helper.getIntFromMap(countMap, identifier, 0) + 1;
372 helper.setIntOnMap(countMap, identifier, count); 372 helper.setIntOnMap(countMap, identifier, count);
373 helper.reportCallWithArgument(ConsoleAPIType::kCount, title + ": " + String1 6::fromInteger(count)); 373 helper.reportCallWithArgument(ConsoleAPIType::kCount, title + ": " + protoco l::string16FromInteger(count));
374 } 374 }
375 375
376 void V8Console::assertCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 376 void V8Console::assertCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
377 { 377 {
378 ConsoleHelper helper(info); 378 ConsoleHelper helper(info);
379 if (helper.firstArgToBoolean(false)) 379 if (helper.firstArgToBoolean(false))
380 return; 380 return;
381 381
382 std::vector<v8::Local<v8::Value>> arguments; 382 std::vector<v8::Local<v8::Value>> arguments;
383 for (int i = 1; i < info.Length(); ++i) 383 for (int i = 1; i < info.Length(); ++i)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 if (V8InspectorClient* client = helper.ensureDebuggerClient()) { 432 if (V8InspectorClient* client = helper.ensureDebuggerClient()) {
433 String16 protocolTitle = helper.firstArgToString("default"); 433 String16 protocolTitle = helper.firstArgToString("default");
434 if (timelinePrefix) 434 if (timelinePrefix)
435 protocolTitle = "Timeline '" + protocolTitle + "'"; 435 protocolTitle = "Timeline '" + protocolTitle + "'";
436 client->consoleTimeEnd(protocolTitle); 436 client->consoleTimeEnd(protocolTitle);
437 437
438 v8::Local<v8::Map> timeMap; 438 v8::Local<v8::Map> timeMap;
439 if (!helper.privateMap("V8Console#timeMap").ToLocal(&timeMap)) 439 if (!helper.privateMap("V8Console#timeMap").ToLocal(&timeMap))
440 return; 440 return;
441 double elapsed = client->currentTimeMS() - helper.getDoubleFromMap(timeM ap, protocolTitle, 0.0); 441 double elapsed = client->currentTimeMS() - helper.getDoubleFromMap(timeM ap, protocolTitle, 0.0);
442 String16 message = protocolTitle + ": " + String16::fromDoubleFixedPreci sion(elapsed, 3) + "ms"; 442 String16 message = protocolTitle + ": " + protocol::string16FromDoublePr ecision3(elapsed) + "ms";
443 helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message); 443 helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message);
444 } 444 }
445 } 445 }
446 446
447 void V8Console::timelineCallback(const v8::FunctionCallbackInfo<v8::Value>& info ) 447 void V8Console::timelineCallback(const v8::FunctionCallbackInfo<v8::Value>& info )
448 { 448 {
449 ConsoleHelper(info).reportDeprecatedCall("V8Console#timeline", "'console.tim eline' is deprecated. Please use 'console.time' instead."); 449 ConsoleHelper(info).reportDeprecatedCall("V8Console#timeline", "'console.tim eline' is deprecated. Please use 'console.time' instead.");
450 timeFunction(info, true); 450 timeFunction(info, true);
451 } 451 }
452 452
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 continue; 528 continue;
529 } 529 }
530 info.GetReturnValue().Set(values); 530 info.GetReturnValue().Set(values);
531 } 531 }
532 532
533 static void setFunctionBreakpoint(ConsoleHelper& helper, v8::Local<v8::Function> function, V8DebuggerAgentImpl::BreakpointSource source, const String16& conditi on, bool enable) 533 static void setFunctionBreakpoint(ConsoleHelper& helper, v8::Local<v8::Function> function, V8DebuggerAgentImpl::BreakpointSource source, const String16& conditi on, bool enable)
534 { 534 {
535 V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent(); 535 V8DebuggerAgentImpl* debuggerAgent = helper.debuggerAgent();
536 if (!debuggerAgent) 536 if (!debuggerAgent)
537 return; 537 return;
538 String16 scriptId = String16::fromInteger(function->ScriptId()); 538 String16 scriptId = protocol::string16FromInteger(function->ScriptId());
539 int lineNumber = function->GetScriptLineNumber(); 539 int lineNumber = function->GetScriptLineNumber();
540 int columnNumber = function->GetScriptColumnNumber(); 540 int columnNumber = function->GetScriptColumnNumber();
541 if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::F unction::kLineOffsetNotFound) 541 if (lineNumber == v8::Function::kLineOffsetNotFound || columnNumber == v8::F unction::kLineOffsetNotFound)
542 return; 542 return;
543 if (enable) 543 if (enable)
544 debuggerAgent->setBreakpointAt(scriptId, lineNumber, columnNumber, sourc e, condition); 544 debuggerAgent->setBreakpointAt(scriptId, lineNumber, columnNumber, sourc e, condition);
545 else 545 else
546 debuggerAgent->removeBreakpointAt(scriptId, lineNumber, columnNumber, so urce); 546 debuggerAgent->removeBreakpointAt(scriptId, lineNumber, columnNumber, so urce);
547 } 547 }
548 548
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 continue; 823 continue;
824 if (name->IsString()) { 824 if (name->IsString()) {
825 v8::Local<v8::Value> descriptor; 825 v8::Local<v8::Value> descriptor;
826 bool success = m_global->GetOwnPropertyDescriptor(m_context, v8::Loc al<v8::String>::Cast(name)).ToLocal(&descriptor); 826 bool success = m_global->GetOwnPropertyDescriptor(m_context, v8::Loc al<v8::String>::Cast(name)).ToLocal(&descriptor);
827 DCHECK(success); 827 DCHECK(success);
828 } 828 }
829 } 829 }
830 } 830 }
831 831
832 } // namespace blink 832 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698