| 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 "platform/v8_inspector/V8Console.h" | 5 #include "platform/v8_inspector/V8Console.h" | 
| 6 | 6 | 
| 7 #include "platform/v8_inspector/InjectedScript.h" | 7 #include "platform/v8_inspector/InjectedScript.h" | 
| 8 #include "platform/v8_inspector/InspectedContext.h" | 8 #include "platform/v8_inspector/InspectedContext.h" | 
| 9 #include "platform/v8_inspector/V8Compat.h" | 9 #include "platform/v8_inspector/V8Compat.h" | 
| 10 #include "platform/v8_inspector/V8ConsoleMessage.h" | 10 #include "platform/v8_inspector/V8ConsoleMessage.h" | 
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 351 | 351 | 
| 352 void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) | 352 void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) | 
| 353 { | 353 { | 
| 354     ConsoleHelper helper(info); | 354     ConsoleHelper helper(info); | 
| 355 | 355 | 
| 356     String16 title = helper.firstArgToString(String16()); | 356     String16 title = helper.firstArgToString(String16()); | 
| 357     String16 identifier; | 357     String16 identifier; | 
| 358     if (title.isEmpty()) { | 358     if (title.isEmpty()) { | 
| 359         std::unique_ptr<V8StackTraceImpl> stackTrace = V8StackTraceImpl::capture
     (nullptr, 0, 1); | 359         std::unique_ptr<V8StackTraceImpl> stackTrace = V8StackTraceImpl::capture
     (nullptr, 0, 1); | 
| 360         if (stackTrace) | 360         if (stackTrace) | 
| 361             identifier = stackTrace->topSourceURL() + ":" + String16::fromIntege
     r(stackTrace->topLineNumber()); | 361             identifier = toString16(stackTrace->topSourceURL()) + ":" + String16
     ::fromInteger(stackTrace->topLineNumber()); | 
| 362     } else { | 362     } else { | 
| 363         identifier = title + "@"; | 363         identifier = title + "@"; | 
| 364     } | 364     } | 
| 365 | 365 | 
| 366     v8::Local<v8::Map> countMap; | 366     v8::Local<v8::Map> countMap; | 
| 367     if (!helper.privateMap("V8Console#countMap").ToLocal(&countMap)) | 367     if (!helper.privateMap("V8Console#countMap").ToLocal(&countMap)) | 
| 368         return; | 368         return; | 
| 369     int64_t count = helper.getIntFromMap(countMap, identifier, 0) + 1; | 369     int64_t count = helper.getIntFromMap(countMap, identifier, 0) + 1; | 
| 370     helper.setIntOnMap(countMap, identifier, count); | 370     helper.setIntOnMap(countMap, identifier, count); | 
| 371     helper.reportCallWithArgument(ConsoleAPIType::kCount, title + ": " + String1
     6::fromInteger(count)); | 371     helper.reportCallWithArgument(ConsoleAPIType::kCount, title + ": " + String1
     6::fromInteger(count)); | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 408         profilerAgent->consoleProfileEnd(helper.firstArgToString(String16())); | 408         profilerAgent->consoleProfileEnd(helper.firstArgToString(String16())); | 
| 409 } | 409 } | 
| 410 | 410 | 
| 411 static void timeFunction(const v8::FunctionCallbackInfo<v8::Value>& info, bool t
     imelinePrefix) | 411 static void timeFunction(const v8::FunctionCallbackInfo<v8::Value>& info, bool t
     imelinePrefix) | 
| 412 { | 412 { | 
| 413     ConsoleHelper helper(info); | 413     ConsoleHelper helper(info); | 
| 414     if (V8InspectorClient* client = helper.ensureDebuggerClient()) { | 414     if (V8InspectorClient* client = helper.ensureDebuggerClient()) { | 
| 415         String16 protocolTitle = helper.firstArgToString("default"); | 415         String16 protocolTitle = helper.firstArgToString("default"); | 
| 416         if (timelinePrefix) | 416         if (timelinePrefix) | 
| 417             protocolTitle = "Timeline '" + protocolTitle + "'"; | 417             protocolTitle = "Timeline '" + protocolTitle + "'"; | 
| 418         client->consoleTime(protocolTitle); | 418         client->consoleTime(toStringView(protocolTitle)); | 
| 419 | 419 | 
| 420         v8::Local<v8::Map> timeMap; | 420         v8::Local<v8::Map> timeMap; | 
| 421         if (!helper.privateMap("V8Console#timeMap").ToLocal(&timeMap)) | 421         if (!helper.privateMap("V8Console#timeMap").ToLocal(&timeMap)) | 
| 422             return; | 422             return; | 
| 423         helper.setDoubleOnMap(timeMap, protocolTitle, client->currentTimeMS()); | 423         helper.setDoubleOnMap(timeMap, protocolTitle, client->currentTimeMS()); | 
| 424     } | 424     } | 
| 425 } | 425 } | 
| 426 | 426 | 
| 427 static void timeEndFunction(const v8::FunctionCallbackInfo<v8::Value>& info, boo
     l timelinePrefix) | 427 static void timeEndFunction(const v8::FunctionCallbackInfo<v8::Value>& info, boo
     l timelinePrefix) | 
| 428 { | 428 { | 
| 429     ConsoleHelper helper(info); | 429     ConsoleHelper helper(info); | 
| 430     if (V8InspectorClient* client = helper.ensureDebuggerClient()) { | 430     if (V8InspectorClient* client = helper.ensureDebuggerClient()) { | 
| 431         String16 protocolTitle = helper.firstArgToString("default"); | 431         String16 protocolTitle = helper.firstArgToString("default"); | 
| 432         if (timelinePrefix) | 432         if (timelinePrefix) | 
| 433             protocolTitle = "Timeline '" + protocolTitle + "'"; | 433             protocolTitle = "Timeline '" + protocolTitle + "'"; | 
| 434         client->consoleTimeEnd(protocolTitle); | 434         client->consoleTimeEnd(toStringView(protocolTitle)); | 
| 435 | 435 | 
| 436         v8::Local<v8::Map> timeMap; | 436         v8::Local<v8::Map> timeMap; | 
| 437         if (!helper.privateMap("V8Console#timeMap").ToLocal(&timeMap)) | 437         if (!helper.privateMap("V8Console#timeMap").ToLocal(&timeMap)) | 
| 438             return; | 438             return; | 
| 439         double elapsed = client->currentTimeMS() - helper.getDoubleFromMap(timeM
     ap, protocolTitle, 0.0); | 439         double elapsed = client->currentTimeMS() - helper.getDoubleFromMap(timeM
     ap, protocolTitle, 0.0); | 
| 440         String16 message = protocolTitle + ": " + String16::fromDoublePrecision3
     (elapsed) + "ms"; | 440         String16 message = protocolTitle + ": " + String16::fromDoublePrecision3
     (elapsed) + "ms"; | 
| 441         helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message); | 441         helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message); | 
| 442     } | 442     } | 
| 443 } | 443 } | 
| 444 | 444 | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 460 } | 460 } | 
| 461 | 461 | 
| 462 void V8Console::timeEndCallback(const v8::FunctionCallbackInfo<v8::Value>& info) | 462 void V8Console::timeEndCallback(const v8::FunctionCallbackInfo<v8::Value>& info) | 
| 463 { | 463 { | 
| 464     timeEndFunction(info, false); | 464     timeEndFunction(info, false); | 
| 465 } | 465 } | 
| 466 | 466 | 
| 467 void V8Console::timeStampCallback(const v8::FunctionCallbackInfo<v8::Value>& inf
     o) | 467 void V8Console::timeStampCallback(const v8::FunctionCallbackInfo<v8::Value>& inf
     o) | 
| 468 { | 468 { | 
| 469     ConsoleHelper helper(info); | 469     ConsoleHelper helper(info); | 
| 470     if (V8InspectorClient* client = helper.ensureDebuggerClient()) | 470     if (V8InspectorClient* client = helper.ensureDebuggerClient()) { | 
| 471         client->consoleTimeStamp(helper.firstArgToString(String16())); | 471         String16 title = helper.firstArgToString(String16()); | 
|  | 472         client->consoleTimeStamp(toStringView(title)); | 
|  | 473     } | 
| 472 } | 474 } | 
| 473 | 475 | 
| 474 void V8Console::memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& 
     info) | 476 void V8Console::memoryGetterCallback(const v8::FunctionCallbackInfo<v8::Value>& 
     info) | 
| 475 { | 477 { | 
| 476     if (V8InspectorClient* client = ConsoleHelper(info).ensureDebuggerClient()) 
     { | 478     if (V8InspectorClient* client = ConsoleHelper(info).ensureDebuggerClient()) 
     { | 
| 477         v8::Local<v8::Value> memoryValue; | 479         v8::Local<v8::Value> memoryValue; | 
| 478         if (!client->memoryInfo(info.GetIsolate(), info.GetIsolate()->GetCurrent
     Context()).ToLocal(&memoryValue)) | 480         if (!client->memoryInfo(info.GetIsolate(), info.GetIsolate()->GetCurrent
     Context()).ToLocal(&memoryValue)) | 
| 479             return; | 481             return; | 
| 480         info.GetReturnValue().Set(memoryValue); | 482         info.GetReturnValue().Set(memoryValue); | 
| 481     } | 483     } | 
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 821             continue; | 823             continue; | 
| 822         if (name->IsString()) { | 824         if (name->IsString()) { | 
| 823             v8::Local<v8::Value> descriptor; | 825             v8::Local<v8::Value> descriptor; | 
| 824             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); | 
| 825             DCHECK(success); | 827             DCHECK(success); | 
| 826         } | 828         } | 
| 827     } | 829     } | 
| 828 } | 830 } | 
| 829 | 831 | 
| 830 } // namespace v8_inspector | 832 } // namespace v8_inspector | 
| OLD | NEW | 
|---|