| 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/V8ConsoleMessage.h" | 5 #include "platform/v8_inspector/V8ConsoleMessage.h" |
| 6 | 6 |
| 7 #include "platform/v8_inspector/InspectedContext.h" | 7 #include "platform/v8_inspector/InspectedContext.h" |
| 8 #include "platform/v8_inspector/V8ConsoleAgentImpl.h" | 8 #include "platform/v8_inspector/V8ConsoleAgentImpl.h" |
| 9 #include "platform/v8_inspector/V8DebuggerImpl.h" | 9 #include "platform/v8_inspector/V8DebuggerImpl.h" |
| 10 #include "platform/v8_inspector/V8InspectorSessionImpl.h" | 10 #include "platform/v8_inspector/V8InspectorSessionImpl.h" |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } | 245 } |
| 246 args->addItem(std::move(wrapped)); | 246 args->addItem(std::move(wrapped)); |
| 247 } | 247 } |
| 248 } | 248 } |
| 249 return args; | 249 return args; |
| 250 } | 250 } |
| 251 | 251 |
| 252 void V8ConsoleMessage::reportToFrontend(protocol::Runtime::Frontend* frontend, V
8InspectorSessionImpl* session, bool generatePreview) const | 252 void V8ConsoleMessage::reportToFrontend(protocol::Runtime::Frontend* frontend, V
8InspectorSessionImpl* session, bool generatePreview) const |
| 253 { | 253 { |
| 254 if (m_origin == V8MessageOrigin::kException) { | 254 if (m_origin == V8MessageOrigin::kException) { |
| 255 std::unique_ptr<protocol::Runtime::RemoteObject> exception = wrapExcepti
on(session, generatePreview); |
| 255 // TODO(dgozman): unify with InjectedScript::createExceptionDetails. | 256 // TODO(dgozman): unify with InjectedScript::createExceptionDetails. |
| 256 std::unique_ptr<protocol::Runtime::ExceptionDetails> details = protocol:
:Runtime::ExceptionDetails::create() | 257 std::unique_ptr<protocol::Runtime::ExceptionDetails> details = protocol:
:Runtime::ExceptionDetails::create() |
| 257 .setText(m_message) | 258 .setText(exception ? m_message : m_detailedMessage) |
| 258 .setLineNumber(m_lineNumber ? m_lineNumber - 1 : 0) | 259 .setLineNumber(m_lineNumber ? m_lineNumber - 1 : 0) |
| 259 .setColumnNumber(m_columnNumber ? m_columnNumber - 1 : 0) | 260 .setColumnNumber(m_columnNumber ? m_columnNumber - 1 : 0) |
| 260 .setScriptId(m_scriptId ? String16::fromInteger(m_scriptId) : String
16()) | 261 .setScriptId(m_scriptId ? String16::fromInteger(m_scriptId) : String
16()) |
| 261 .build(); | 262 .build(); |
| 262 if (!m_url.isEmpty()) | 263 if (!m_url.isEmpty()) |
| 263 details->setUrl(m_url); | 264 details->setUrl(m_url); |
| 264 if (m_stackTrace) | 265 if (m_stackTrace) |
| 265 details->setStackTrace(m_stackTrace->buildInspectorObjectImpl()); | 266 details->setStackTrace(m_stackTrace->buildInspectorObjectImpl()); |
| 266 | 267 |
| 267 std::unique_ptr<protocol::Runtime::RemoteObject> exception = wrapExcepti
on(session, generatePreview); | |
| 268 | |
| 269 if (exception) | 268 if (exception) |
| 270 frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(deta
ils), std::move(exception), m_contextId); | 269 frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(deta
ils), std::move(exception), m_contextId); |
| 271 else | 270 else |
| 272 frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(deta
ils)); | 271 frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(deta
ils)); |
| 273 return; | 272 return; |
| 274 } | 273 } |
| 275 if (m_origin == V8MessageOrigin::kRevokedException) { | 274 if (m_origin == V8MessageOrigin::kRevokedException) { |
| 276 frontend->exceptionRevoked(m_message, m_revokedExceptionId); | 275 frontend->exceptionRevoked(m_message, m_revokedExceptionId); |
| 277 return; | 276 return; |
| 278 } | 277 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 else if (type == ConsoleAPIType::kInfo) | 343 else if (type == ConsoleAPIType::kInfo) |
| 345 clientType = V8ConsoleAPIType::kInfo; | 344 clientType = V8ConsoleAPIType::kInfo; |
| 346 else if (type == ConsoleAPIType::kClear) | 345 else if (type == ConsoleAPIType::kClear) |
| 347 clientType = V8ConsoleAPIType::kClear; | 346 clientType = V8ConsoleAPIType::kClear; |
| 348 context->debugger()->client()->consoleAPIMessage(context->contextGroupId(),
clientType, message->m_message, message->m_url, message->m_lineNumber, message->
m_columnNumber, message->m_stackTrace.get()); | 347 context->debugger()->client()->consoleAPIMessage(context->contextGroupId(),
clientType, message->m_message, message->m_url, message->m_lineNumber, message->
m_columnNumber, message->m_stackTrace.get()); |
| 349 | 348 |
| 350 return message; | 349 return message; |
| 351 } | 350 } |
| 352 | 351 |
| 353 // static | 352 // static |
| 354 std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForException(double ti
mestamp, const String16& messageText, const String16& url, unsigned lineNumber,
unsigned columnNumber, std::unique_ptr<V8StackTraceImpl> stackTrace, int scriptI
d, v8::Isolate* isolate, int contextId, v8::Local<v8::Value> exception, unsigned
exceptionId) | 353 std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForException(double ti
mestamp, const String16& detailedMessage, const String16& url, unsigned lineNumb
er, unsigned columnNumber, std::unique_ptr<V8StackTraceImpl> stackTrace, int scr
iptId, v8::Isolate* isolate, const String16& message, int contextId, v8::Local<v
8::Value> exception, unsigned exceptionId) |
| 355 { | 354 { |
| 356 std::unique_ptr<V8ConsoleMessage> message = wrapUnique(new V8ConsoleMessage(
V8MessageOrigin::kException, timestamp, messageText)); | 355 std::unique_ptr<V8ConsoleMessage> consoleMessage = wrapUnique(new V8ConsoleM
essage(V8MessageOrigin::kException, timestamp, message)); |
| 357 message->setLocation(url, lineNumber, columnNumber, std::move(stackTrace), s
criptId); | 356 consoleMessage->setLocation(url, lineNumber, columnNumber, std::move(stackTr
ace), scriptId); |
| 358 message->m_exceptionId = exceptionId; | 357 consoleMessage->m_exceptionId = exceptionId; |
| 358 consoleMessage->m_detailedMessage = detailedMessage; |
| 359 if (contextId && !exception.IsEmpty()) { | 359 if (contextId && !exception.IsEmpty()) { |
| 360 message->m_contextId = contextId; | 360 consoleMessage->m_contextId = contextId; |
| 361 message->m_arguments.push_back(wrapUnique(new v8::Global<v8::Value>(isol
ate, exception))); | 361 consoleMessage->m_arguments.push_back(wrapUnique(new v8::Global<v8::Valu
e>(isolate, exception))); |
| 362 } | 362 } |
| 363 return message; | 363 return consoleMessage; |
| 364 } | 364 } |
| 365 | 365 |
| 366 // static | 366 // static |
| 367 std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForRevokedException(do
uble timestamp, const String16& messageText, unsigned revokedExceptionId) | 367 std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForRevokedException(do
uble timestamp, const String16& messageText, unsigned revokedExceptionId) |
| 368 { | 368 { |
| 369 std::unique_ptr<V8ConsoleMessage> message = wrapUnique(new V8ConsoleMessage(
V8MessageOrigin::kRevokedException, timestamp, messageText)); | 369 std::unique_ptr<V8ConsoleMessage> message = wrapUnique(new V8ConsoleMessage(
V8MessageOrigin::kRevokedException, timestamp, messageText)); |
| 370 message->m_revokedExceptionId = revokedExceptionId; | 370 message->m_revokedExceptionId = revokedExceptionId; |
| 371 return message; | 371 return message; |
| 372 } | 372 } |
| 373 | 373 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 session->releaseObjectGroup("console"); | 424 session->releaseObjectGroup("console"); |
| 425 } | 425 } |
| 426 | 426 |
| 427 void V8ConsoleMessageStorage::contextDestroyed(int contextId) | 427 void V8ConsoleMessageStorage::contextDestroyed(int contextId) |
| 428 { | 428 { |
| 429 for (size_t i = 0; i < m_messages.size(); ++i) | 429 for (size_t i = 0; i < m_messages.size(); ++i) |
| 430 m_messages[i]->contextDestroyed(contextId); | 430 m_messages[i]->contextDestroyed(contextId); |
| 431 } | 431 } |
| 432 | 432 |
| 433 } // namespace blink | 433 } // namespace blink |
| OLD | NEW |