OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 16 matching lines...) Expand all Loading... |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" | 31 #include "platform/v8_inspector/V8RuntimeAgentImpl.h" |
32 | 32 |
33 #include "platform/inspector_protocol/Values.h" | 33 #include "platform/inspector_protocol/Values.h" |
34 #include "platform/v8_inspector/InjectedScript.h" | 34 #include "platform/v8_inspector/InjectedScript.h" |
35 #include "platform/v8_inspector/InspectedContext.h" | 35 #include "platform/v8_inspector/InspectedContext.h" |
36 #include "platform/v8_inspector/RemoteObjectId.h" | 36 #include "platform/v8_inspector/RemoteObjectId.h" |
| 37 #include "platform/v8_inspector/V8ConsoleMessage.h" |
37 #include "platform/v8_inspector/V8DebuggerImpl.h" | 38 #include "platform/v8_inspector/V8DebuggerImpl.h" |
38 #include "platform/v8_inspector/V8InspectorSessionImpl.h" | 39 #include "platform/v8_inspector/V8InspectorSessionImpl.h" |
39 #include "platform/v8_inspector/V8StringUtil.h" | 40 #include "platform/v8_inspector/V8StringUtil.h" |
40 #include "platform/v8_inspector/public/V8DebuggerClient.h" | 41 #include "platform/v8_inspector/public/V8DebuggerClient.h" |
41 | 42 |
42 namespace blink { | 43 namespace blink { |
43 | 44 |
44 namespace V8RuntimeAgentImplState { | 45 namespace V8RuntimeAgentImplState { |
45 static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled
"; | 46 static const char customObjectFormatterEnabled[] = "customObjectFormatterEnabled
"; |
46 static const char runtimeEnabled[] = "runtimeEnabled"; | 47 static const char runtimeEnabled[] = "runtimeEnabled"; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 m_session->setCustomObjectFormatterEnabled(true); | 359 m_session->setCustomObjectFormatterEnabled(true); |
359 } | 360 } |
360 | 361 |
361 void V8RuntimeAgentImpl::enable(ErrorString* errorString) | 362 void V8RuntimeAgentImpl::enable(ErrorString* errorString) |
362 { | 363 { |
363 if (m_enabled) | 364 if (m_enabled) |
364 return; | 365 return; |
365 m_session->changeInstrumentationCounter(+1); | 366 m_session->changeInstrumentationCounter(+1); |
366 m_enabled = true; | 367 m_enabled = true; |
367 m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, true); | 368 m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, true); |
368 v8::HandleScope handles(m_debugger->isolate()); | 369 m_session->debugger()->enableStackCapturingIfNeeded(); |
369 m_session->reportAllContexts(this); | 370 m_session->reportAllContexts(this); |
| 371 V8ConsoleMessageStorage* storage = m_session->debugger()->ensureConsoleMessa
geStorage(m_session->contextGroupId()); |
| 372 for (const auto& message : storage->messages()) { |
| 373 if (message->origin() == V8MessageOrigin::kException || message->origin(
) == V8MessageOrigin::kRevokedException) |
| 374 reportMessage(message.get(), false); |
| 375 } |
370 } | 376 } |
371 | 377 |
372 void V8RuntimeAgentImpl::disable(ErrorString* errorString) | 378 void V8RuntimeAgentImpl::disable(ErrorString* errorString) |
373 { | 379 { |
374 if (!m_enabled) | 380 if (!m_enabled) |
375 return; | 381 return; |
376 m_enabled = false; | 382 m_enabled = false; |
377 m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, false); | 383 m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, false); |
| 384 m_session->debugger()->disableStackCapturingIfNeeded(); |
378 m_session->discardInjectedScripts(); | 385 m_session->discardInjectedScripts(); |
379 reset(); | 386 reset(); |
380 m_session->changeInstrumentationCounter(-1); | 387 m_session->changeInstrumentationCounter(-1); |
381 } | 388 } |
382 | 389 |
383 void V8RuntimeAgentImpl::reset() | 390 void V8RuntimeAgentImpl::reset() |
384 { | 391 { |
385 m_compiledScripts.clear(); | 392 m_compiledScripts.clear(); |
386 if (m_enabled) { | 393 if (m_enabled) { |
387 if (const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->context
Group(m_session->contextGroupId())) { | 394 if (const V8DebuggerImpl::ContextByIdMap* contexts = m_debugger->context
Group(m_session->contextGroupId())) { |
(...skipping 25 matching lines...) Expand all Loading... |
413 m_frontend.executionContextDestroyed(context->contextId()); | 420 m_frontend.executionContextDestroyed(context->contextId()); |
414 } | 421 } |
415 } | 422 } |
416 | 423 |
417 void V8RuntimeAgentImpl::inspect(std::unique_ptr<protocol::Runtime::RemoteObject
> objectToInspect, std::unique_ptr<protocol::DictionaryValue> hints) | 424 void V8RuntimeAgentImpl::inspect(std::unique_ptr<protocol::Runtime::RemoteObject
> objectToInspect, std::unique_ptr<protocol::DictionaryValue> hints) |
418 { | 425 { |
419 if (m_enabled) | 426 if (m_enabled) |
420 m_frontend.inspectRequested(std::move(objectToInspect), std::move(hints)
); | 427 m_frontend.inspectRequested(std::move(objectToInspect), std::move(hints)
); |
421 } | 428 } |
422 | 429 |
| 430 void V8RuntimeAgentImpl::exceptionMessageAdded(V8ConsoleMessage* message) |
| 431 { |
| 432 if (m_enabled) |
| 433 reportMessage(message, true); |
| 434 } |
| 435 |
| 436 void V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, bool generateP
review) |
| 437 { |
| 438 DCHECK(message->origin() == V8MessageOrigin::kException || message->origin()
== V8MessageOrigin::kRevokedException); |
| 439 message->reportToFrontend(&m_frontend, m_session, generatePreview); |
| 440 m_frontend.flush(); |
| 441 } |
| 442 |
423 } // namespace blink | 443 } // namespace blink |
OLD | NEW |