| 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->reportAllContexts(this); | 369 m_session->reportAllContexts(this); |
| 370 V8ConsoleMessageStorage* storage = m_session->debugger()->ensureConsoleMessa
geStorage(m_session->contextGroupId()); |
| 371 for (const auto& message : storage->messages()) { |
| 372 if (message->origin() == V8MessageOrigin::kException || message->origin(
) == V8MessageOrigin::kRevokedException) |
| 373 reportMessage(message.get(), false); |
| 374 } |
| 370 } | 375 } |
| 371 | 376 |
| 372 void V8RuntimeAgentImpl::disable(ErrorString* errorString) | 377 void V8RuntimeAgentImpl::disable(ErrorString* errorString) |
| 373 { | 378 { |
| 374 if (!m_enabled) | 379 if (!m_enabled) |
| 375 return; | 380 return; |
| 376 m_enabled = false; | 381 m_enabled = false; |
| 377 m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, false); | 382 m_state->setBoolean(V8RuntimeAgentImplState::runtimeEnabled, false); |
| 378 m_session->discardInjectedScripts(); | 383 m_session->discardInjectedScripts(); |
| 379 reset(); | 384 reset(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 m_frontend.executionContextDestroyed(context->contextId()); | 418 m_frontend.executionContextDestroyed(context->contextId()); |
| 414 } | 419 } |
| 415 } | 420 } |
| 416 | 421 |
| 417 void V8RuntimeAgentImpl::inspect(std::unique_ptr<protocol::Runtime::RemoteObject
> objectToInspect, std::unique_ptr<protocol::DictionaryValue> hints) | 422 void V8RuntimeAgentImpl::inspect(std::unique_ptr<protocol::Runtime::RemoteObject
> objectToInspect, std::unique_ptr<protocol::DictionaryValue> hints) |
| 418 { | 423 { |
| 419 if (m_enabled) | 424 if (m_enabled) |
| 420 m_frontend.inspectRequested(std::move(objectToInspect), std::move(hints)
); | 425 m_frontend.inspectRequested(std::move(objectToInspect), std::move(hints)
); |
| 421 } | 426 } |
| 422 | 427 |
| 428 void V8RuntimeAgentImpl::exceptionMessageAdded(V8ConsoleMessage* message) |
| 429 { |
| 430 if (m_enabled) |
| 431 reportMessage(message, true); |
| 432 } |
| 433 |
| 434 void V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, bool generateP
review) |
| 435 { |
| 436 DCHECK(message->origin() == V8MessageOrigin::kException || message->origin()
== V8MessageOrigin::kRevokedException); |
| 437 message->reportToFrontend(&m_frontend, m_session, generatePreview); |
| 438 m_frontend.flush(); |
| 439 } |
| 440 |
| 423 } // namespace blink | 441 } // namespace blink |
| OLD | NEW |