| OLD | NEW |
| 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-message.h" | 5 #include "src/inspector/v8-console-message.h" |
| 6 | 6 |
| 7 #include "src/inspector/inspected-context.h" | 7 #include "src/inspector/inspected-context.h" |
| 8 #include "src/inspector/protocol/Protocol.h" | 8 #include "src/inspector/protocol/Protocol.h" |
| 9 #include "src/inspector/string-util.h" | 9 #include "src/inspector/string-util.h" |
| 10 #include "src/inspector/v8-console-agent-impl.h" | 10 #include "src/inspector/v8-console-agent-impl.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 return protocol::Runtime::ConsoleAPICalled::TypeEnum::Trace; | 43 return protocol::Runtime::ConsoleAPICalled::TypeEnum::Trace; |
| 44 case ConsoleAPIType::kStartGroup: | 44 case ConsoleAPIType::kStartGroup: |
| 45 return protocol::Runtime::ConsoleAPICalled::TypeEnum::StartGroup; | 45 return protocol::Runtime::ConsoleAPICalled::TypeEnum::StartGroup; |
| 46 case ConsoleAPIType::kStartGroupCollapsed: | 46 case ConsoleAPIType::kStartGroupCollapsed: |
| 47 return protocol::Runtime::ConsoleAPICalled::TypeEnum::StartGroupCollapsed; | 47 return protocol::Runtime::ConsoleAPICalled::TypeEnum::StartGroupCollapsed; |
| 48 case ConsoleAPIType::kEndGroup: | 48 case ConsoleAPIType::kEndGroup: |
| 49 return protocol::Runtime::ConsoleAPICalled::TypeEnum::EndGroup; | 49 return protocol::Runtime::ConsoleAPICalled::TypeEnum::EndGroup; |
| 50 case ConsoleAPIType::kAssert: | 50 case ConsoleAPIType::kAssert: |
| 51 return protocol::Runtime::ConsoleAPICalled::TypeEnum::Assert; | 51 return protocol::Runtime::ConsoleAPICalled::TypeEnum::Assert; |
| 52 case ConsoleAPIType::kTimeEnd: | 52 case ConsoleAPIType::kTimeEnd: |
| 53 return protocol::Runtime::ConsoleAPICalled::TypeEnum::Debug; | 53 return protocol::Runtime::ConsoleAPICalled::TypeEnum::TimeEnd; |
| 54 case ConsoleAPIType::kCount: | 54 case ConsoleAPIType::kCount: |
| 55 return protocol::Runtime::ConsoleAPICalled::TypeEnum::Debug; | 55 return protocol::Runtime::ConsoleAPICalled::TypeEnum::Count; |
| 56 } | 56 } |
| 57 return protocol::Runtime::ConsoleAPICalled::TypeEnum::Log; | 57 return protocol::Runtime::ConsoleAPICalled::TypeEnum::Log; |
| 58 } | 58 } |
| 59 | 59 |
| 60 const unsigned maxConsoleMessageCount = 1000; | 60 const unsigned maxConsoleMessageCount = 1000; |
| 61 const unsigned maxArrayItemsLimit = 10000; | 61 const unsigned maxArrayItemsLimit = 10000; |
| 62 const unsigned maxStackDepthLimit = 32; | 62 const unsigned maxStackDepthLimit = 32; |
| 63 | 63 |
| 64 class V8ValueStringBuilder { | 64 class V8ValueStringBuilder { |
| 65 public: | 65 public: |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 message->m_stackTrace = std::move(stackTrace); | 371 message->m_stackTrace = std::move(stackTrace); |
| 372 message->m_type = type; | 372 message->m_type = type; |
| 373 message->m_contextId = contextId; | 373 message->m_contextId = contextId; |
| 374 for (size_t i = 0; i < arguments.size(); ++i) | 374 for (size_t i = 0; i < arguments.size(); ++i) |
| 375 message->m_arguments.push_back(std::unique_ptr<v8::Global<v8::Value>>( | 375 message->m_arguments.push_back(std::unique_ptr<v8::Global<v8::Value>>( |
| 376 new v8::Global<v8::Value>(isolate, arguments.at(i)))); | 376 new v8::Global<v8::Value>(isolate, arguments.at(i)))); |
| 377 if (arguments.size()) | 377 if (arguments.size()) |
| 378 message->m_message = V8ValueStringBuilder::toString(arguments[0], context); | 378 message->m_message = V8ValueStringBuilder::toString(arguments[0], context); |
| 379 | 379 |
| 380 V8ConsoleAPIType clientType = V8ConsoleAPIType::kLog; | 380 V8ConsoleAPIType clientType = V8ConsoleAPIType::kLog; |
| 381 v8::Isolate::MessageErrorLevel clientLevel = v8::Isolate::kMessageInfo; |
| 381 if (type == ConsoleAPIType::kDebug || type == ConsoleAPIType::kCount || | 382 if (type == ConsoleAPIType::kDebug || type == ConsoleAPIType::kCount || |
| 382 type == ConsoleAPIType::kTimeEnd) | 383 type == ConsoleAPIType::kTimeEnd) { |
| 383 clientType = V8ConsoleAPIType::kDebug; | 384 clientType = V8ConsoleAPIType::kDebug; |
| 384 else if (type == ConsoleAPIType::kError || type == ConsoleAPIType::kAssert) | 385 clientLevel = v8::Isolate::kMessageDebug; |
| 386 } else if (type == ConsoleAPIType::kError || |
| 387 type == ConsoleAPIType::kAssert) { |
| 385 clientType = V8ConsoleAPIType::kError; | 388 clientType = V8ConsoleAPIType::kError; |
| 386 else if (type == ConsoleAPIType::kWarning) | 389 clientLevel = v8::Isolate::kMessageError; |
| 390 } else if (type == ConsoleAPIType::kWarning) { |
| 387 clientType = V8ConsoleAPIType::kWarning; | 391 clientType = V8ConsoleAPIType::kWarning; |
| 388 else if (type == ConsoleAPIType::kInfo) | 392 clientLevel = v8::Isolate::kMessageWarning; |
| 393 } else if (type == ConsoleAPIType::kInfo || type == ConsoleAPIType::kLog) { |
| 389 clientType = V8ConsoleAPIType::kInfo; | 394 clientType = V8ConsoleAPIType::kInfo; |
| 390 else if (type == ConsoleAPIType::kClear) | 395 clientLevel = v8::Isolate::kMessageInfo; |
| 396 } else if (type == ConsoleAPIType::kClear) { |
| 391 clientType = V8ConsoleAPIType::kClear; | 397 clientType = V8ConsoleAPIType::kClear; |
| 398 } |
| 399 |
| 392 inspector->client()->consoleAPIMessage( | 400 inspector->client()->consoleAPIMessage( |
| 393 contextGroupId, clientType, toStringView(message->m_message), | 401 contextGroupId, clientType, toStringView(message->m_message), |
| 394 toStringView(message->m_url), message->m_lineNumber, | 402 toStringView(message->m_url), message->m_lineNumber, |
| 395 message->m_columnNumber, message->m_stackTrace.get()); | 403 message->m_columnNumber, message->m_stackTrace.get()); |
| 396 | 404 |
| 405 if (type != ConsoleAPIType::kClear) { |
| 406 inspector->client()->consoleAPIMessage( |
| 407 contextGroupId, clientLevel, toStringView(message->m_message), |
| 408 toStringView(message->m_url), message->m_lineNumber, |
| 409 message->m_columnNumber, message->m_stackTrace.get()); |
| 410 } |
| 411 |
| 397 return message; | 412 return message; |
| 398 } | 413 } |
| 399 | 414 |
| 400 // static | 415 // static |
| 401 std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForException( | 416 std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForException( |
| 402 double timestamp, const String16& detailedMessage, const String16& url, | 417 double timestamp, const String16& detailedMessage, const String16& url, |
| 403 unsigned lineNumber, unsigned columnNumber, | 418 unsigned lineNumber, unsigned columnNumber, |
| 404 std::unique_ptr<V8StackTraceImpl> stackTrace, int scriptId, | 419 std::unique_ptr<V8StackTraceImpl> stackTrace, int scriptId, |
| 405 v8::Isolate* isolate, const String16& message, int contextId, | 420 v8::Isolate* isolate, const String16& message, int contextId, |
| 406 v8::Local<v8::Value> exception, unsigned exceptionId) { | 421 v8::Local<v8::Value> exception, unsigned exceptionId) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 m_inspector->sessionForContextGroup(m_contextGroupId)) | 492 m_inspector->sessionForContextGroup(m_contextGroupId)) |
| 478 session->releaseObjectGroup("console"); | 493 session->releaseObjectGroup("console"); |
| 479 } | 494 } |
| 480 | 495 |
| 481 void V8ConsoleMessageStorage::contextDestroyed(int contextId) { | 496 void V8ConsoleMessageStorage::contextDestroyed(int contextId) { |
| 482 for (size_t i = 0; i < m_messages.size(); ++i) | 497 for (size_t i = 0; i < m_messages.size(); ++i) |
| 483 m_messages[i]->contextDestroyed(contextId); | 498 m_messages[i]->contextDestroyed(contextId); |
| 484 } | 499 } |
| 485 | 500 |
| 486 } // namespace v8_inspector | 501 } // namespace v8_inspector |
| OLD | NEW |