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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 , m_type(ConsoleAPIType::kLog) | 184 , m_type(ConsoleAPIType::kLog) |
185 , m_exceptionId(0) | 185 , m_exceptionId(0) |
186 , m_revokedExceptionId(0) | 186 , m_revokedExceptionId(0) |
187 { | 187 { |
188 } | 188 } |
189 | 189 |
190 V8ConsoleMessage::~V8ConsoleMessage() | 190 V8ConsoleMessage::~V8ConsoleMessage() |
191 { | 191 { |
192 } | 192 } |
193 | 193 |
194 void V8ConsoleMessage::setLocation(const String16& url, unsigned lineNumber, uns
igned columnNumber, std::unique_ptr<V8StackTrace> stackTrace, int scriptId) | 194 void V8ConsoleMessage::setLocation(const String16& url, unsigned lineNumber, uns
igned columnNumber, std::unique_ptr<V8StackTraceImpl> stackTrace, int scriptId) |
195 { | 195 { |
196 m_url = url; | 196 m_url = url; |
197 m_lineNumber = lineNumber; | 197 m_lineNumber = lineNumber; |
198 m_columnNumber = columnNumber; | 198 m_columnNumber = columnNumber; |
199 m_stackTrace = std::move(stackTrace); | 199 m_stackTrace = std::move(stackTrace); |
200 m_scriptId = scriptId; | 200 m_scriptId = scriptId; |
201 } | 201 } |
202 | 202 |
203 void V8ConsoleMessage::reportToFrontend(protocol::Console::Frontend* frontend) c
onst | 203 void V8ConsoleMessage::reportToFrontend(protocol::Console::Frontend* frontend) c
onst |
204 { | 204 { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // TODO(dgozman): unify with InjectedScript::createExceptionDetails. | 255 // TODO(dgozman): unify with InjectedScript::createExceptionDetails. |
256 std::unique_ptr<protocol::Runtime::ExceptionDetails> details = protocol:
:Runtime::ExceptionDetails::create() | 256 std::unique_ptr<protocol::Runtime::ExceptionDetails> details = protocol:
:Runtime::ExceptionDetails::create() |
257 .setText(m_message) | 257 .setText(m_message) |
258 .setLineNumber(m_lineNumber ? m_lineNumber - 1 : 0) | 258 .setLineNumber(m_lineNumber ? m_lineNumber - 1 : 0) |
259 .setColumnNumber(m_columnNumber ? m_columnNumber - 1 : 0) | 259 .setColumnNumber(m_columnNumber ? m_columnNumber - 1 : 0) |
260 .setScriptId(m_scriptId ? String16::fromInteger(m_scriptId) : String
16()) | 260 .setScriptId(m_scriptId ? String16::fromInteger(m_scriptId) : String
16()) |
261 .build(); | 261 .build(); |
262 if (!m_url.isEmpty()) | 262 if (!m_url.isEmpty()) |
263 details->setUrl(m_url); | 263 details->setUrl(m_url); |
264 if (m_stackTrace) | 264 if (m_stackTrace) |
265 details->setStackTrace(m_stackTrace->buildInspectorObject()); | 265 details->setStackTrace(m_stackTrace->buildInspectorObjectImpl()); |
266 | 266 |
267 std::unique_ptr<protocol::Runtime::RemoteObject> exception = wrapExcepti
on(session, generatePreview); | 267 std::unique_ptr<protocol::Runtime::RemoteObject> exception = wrapExcepti
on(session, generatePreview); |
268 | 268 |
269 if (exception) | 269 if (exception) |
270 frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(deta
ils), std::move(exception), m_contextId); | 270 frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(deta
ils), std::move(exception), m_contextId); |
271 else | 271 else |
272 frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(deta
ils)); | 272 frontend->exceptionThrown(m_exceptionId, m_timestamp, std::move(deta
ils)); |
273 return; | 273 return; |
274 } | 274 } |
275 if (m_origin == V8MessageOrigin::kRevokedException) { | 275 if (m_origin == V8MessageOrigin::kRevokedException) { |
276 frontend->exceptionRevoked(m_message, m_revokedExceptionId); | 276 frontend->exceptionRevoked(m_message, m_revokedExceptionId); |
277 return; | 277 return; |
278 } | 278 } |
279 if (m_origin == V8MessageOrigin::kConsole) { | 279 if (m_origin == V8MessageOrigin::kConsole) { |
280 std::unique_ptr<protocol::Array<protocol::Runtime::RemoteObject>> argume
nts = wrapArguments(session, generatePreview); | 280 std::unique_ptr<protocol::Array<protocol::Runtime::RemoteObject>> argume
nts = wrapArguments(session, generatePreview); |
281 if (!arguments) { | 281 if (!arguments) { |
282 arguments = protocol::Array<protocol::Runtime::RemoteObject>::create
(); | 282 arguments = protocol::Array<protocol::Runtime::RemoteObject>::create
(); |
283 if (!m_message.isEmpty()) { | 283 if (!m_message.isEmpty()) { |
284 std::unique_ptr<protocol::Runtime::RemoteObject> messageArg = pr
otocol::Runtime::RemoteObject::create().setType(protocol::Runtime::RemoteObject:
:TypeEnum::String).build(); | 284 std::unique_ptr<protocol::Runtime::RemoteObject> messageArg = pr
otocol::Runtime::RemoteObject::create().setType(protocol::Runtime::RemoteObject:
:TypeEnum::String).build(); |
285 messageArg->setValue(protocol::StringValue::create(m_message)); | 285 messageArg->setValue(protocol::StringValue::create(m_message)); |
286 arguments->addItem(std::move(messageArg)); | 286 arguments->addItem(std::move(messageArg)); |
287 } | 287 } |
288 } | 288 } |
289 frontend->consoleAPICalled(consoleAPITypeValue(m_type), std::move(argume
nts), m_contextId, m_timestamp, m_stackTrace ? m_stackTrace->buildInspectorObjec
t() : nullptr); | 289 frontend->consoleAPICalled(consoleAPITypeValue(m_type), std::move(argume
nts), m_contextId, m_timestamp, m_stackTrace ? m_stackTrace->buildInspectorObjec
tImpl() : nullptr); |
290 return; | 290 return; |
291 } | 291 } |
292 NOTREACHED(); | 292 NOTREACHED(); |
293 } | 293 } |
294 | 294 |
295 std::unique_ptr<protocol::Runtime::RemoteObject> V8ConsoleMessage::wrapException
(V8InspectorSessionImpl* session, bool generatePreview) const | 295 std::unique_ptr<protocol::Runtime::RemoteObject> V8ConsoleMessage::wrapException
(V8InspectorSessionImpl* session, bool generatePreview) const |
296 { | 296 { |
297 if (!m_arguments.size() || !m_contextId) | 297 if (!m_arguments.size() || !m_contextId) |
298 return nullptr; | 298 return nullptr; |
299 DCHECK_EQ(1u, m_arguments.size()); | 299 DCHECK_EQ(1u, m_arguments.size()); |
(...skipping 11 matching lines...) Expand all Loading... |
311 { | 311 { |
312 return m_origin; | 312 return m_origin; |
313 } | 313 } |
314 | 314 |
315 ConsoleAPIType V8ConsoleMessage::type() const | 315 ConsoleAPIType V8ConsoleMessage::type() const |
316 { | 316 { |
317 return m_type; | 317 return m_type; |
318 } | 318 } |
319 | 319 |
320 // static | 320 // static |
321 std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(double t
imestamp, ConsoleAPIType type, const std::vector<v8::Local<v8::Value>>& argument
s, std::unique_ptr<V8StackTrace> stackTrace, InspectedContext* context) | 321 std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(double t
imestamp, ConsoleAPIType type, const std::vector<v8::Local<v8::Value>>& argument
s, std::unique_ptr<V8StackTraceImpl> stackTrace, InspectedContext* context) |
322 { | 322 { |
323 std::unique_ptr<V8ConsoleMessage> message = wrapUnique(new V8ConsoleMessage(
V8MessageOrigin::kConsole, timestamp, String16())); | 323 std::unique_ptr<V8ConsoleMessage> message = wrapUnique(new V8ConsoleMessage(
V8MessageOrigin::kConsole, timestamp, String16())); |
324 if (stackTrace && !stackTrace->isEmpty()) { | 324 if (stackTrace && !stackTrace->isEmpty()) { |
325 message->m_url = stackTrace->topSourceURL(); | 325 message->m_url = stackTrace->topSourceURL(); |
326 message->m_lineNumber = stackTrace->topLineNumber(); | 326 message->m_lineNumber = stackTrace->topLineNumber(); |
327 message->m_columnNumber = stackTrace->topColumnNumber(); | 327 message->m_columnNumber = stackTrace->topColumnNumber(); |
328 } | 328 } |
329 message->m_stackTrace = std::move(stackTrace); | 329 message->m_stackTrace = std::move(stackTrace); |
330 message->m_type = type; | 330 message->m_type = type; |
331 message->m_contextId = context->contextId(); | 331 message->m_contextId = context->contextId(); |
(...skipping 10 matching lines...) Expand all Loading... |
342 if (type == ConsoleAPIType::kWarning) | 342 if (type == ConsoleAPIType::kWarning) |
343 level = WarningMessageLevel; | 343 level = WarningMessageLevel; |
344 if (type == ConsoleAPIType::kInfo) | 344 if (type == ConsoleAPIType::kInfo) |
345 level = InfoMessageLevel; | 345 level = InfoMessageLevel; |
346 context->debugger()->client()->consoleAPIMessage(context->contextGroupId(),
level, message->m_message, message->m_url, message->m_lineNumber, message->m_col
umnNumber, message->m_stackTrace.get()); | 346 context->debugger()->client()->consoleAPIMessage(context->contextGroupId(),
level, message->m_message, message->m_url, message->m_lineNumber, message->m_col
umnNumber, message->m_stackTrace.get()); |
347 | 347 |
348 return message; | 348 return message; |
349 } | 349 } |
350 | 350 |
351 // static | 351 // static |
352 std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForException(double ti
mestamp, const String16& messageText, const String16& url, unsigned lineNumber,
unsigned columnNumber, std::unique_ptr<V8StackTrace> stackTrace, int scriptId, v
8::Isolate* isolate, int contextId, v8::Local<v8::Value> exception, unsigned exc
eptionId) | 352 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 { | 353 { |
354 std::unique_ptr<V8ConsoleMessage> message = wrapUnique(new V8ConsoleMessage(
V8MessageOrigin::kException, timestamp, messageText)); | 354 std::unique_ptr<V8ConsoleMessage> message = wrapUnique(new V8ConsoleMessage(
V8MessageOrigin::kException, timestamp, messageText)); |
355 message->setLocation(url, lineNumber, columnNumber, std::move(stackTrace), s
criptId); | 355 message->setLocation(url, lineNumber, columnNumber, std::move(stackTrace), s
criptId); |
356 message->m_exceptionId = exceptionId; | 356 message->m_exceptionId = exceptionId; |
357 if (contextId && !exception.IsEmpty()) { | 357 if (contextId && !exception.IsEmpty()) { |
358 message->m_contextId = contextId; | 358 message->m_contextId = contextId; |
359 message->m_arguments.push_back(wrapUnique(new v8::Global<v8::Value>(isol
ate, exception))); | 359 message->m_arguments.push_back(wrapUnique(new v8::Global<v8::Value>(isol
ate, exception))); |
360 } | 360 } |
361 return message; | 361 return message; |
362 } | 362 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 m_messages[i]->contextDestroyed(contextId); | 431 m_messages[i]->contextDestroyed(contextId); |
432 } | 432 } |
433 | 433 |
434 void V8ConsoleMessageStorage::notifyClear() | 434 void V8ConsoleMessageStorage::notifyClear() |
435 { | 435 { |
436 if (V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_c
ontextGroupId)) | 436 if (V8InspectorSessionImpl* session = m_debugger->sessionForContextGroup(m_c
ontextGroupId)) |
437 session->client()->consoleCleared(); | 437 session->client()->consoleCleared(); |
438 } | 438 } |
439 | 439 |
440 } // namespace blink | 440 } // namespace blink |
OLD | NEW |