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 12 matching lines...) Expand all Loading... | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
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 "src/inspector/v8-runtime-agent-impl.h" | 31 #include "src/inspector/v8-runtime-agent-impl.h" |
32 | 32 |
33 #include "src/debug/debug-interface.h" | |
33 #include "src/inspector/injected-script.h" | 34 #include "src/inspector/injected-script.h" |
34 #include "src/inspector/inspected-context.h" | 35 #include "src/inspector/inspected-context.h" |
35 #include "src/inspector/protocol/Protocol.h" | 36 #include "src/inspector/protocol/Protocol.h" |
36 #include "src/inspector/remote-object-id.h" | 37 #include "src/inspector/remote-object-id.h" |
37 #include "src/inspector/string-util.h" | 38 #include "src/inspector/string-util.h" |
38 #include "src/inspector/v8-console-message.h" | 39 #include "src/inspector/v8-console-message.h" |
39 #include "src/inspector/v8-debugger-agent-impl.h" | 40 #include "src/inspector/v8-debugger-agent-impl.h" |
40 #include "src/inspector/v8-debugger.h" | 41 #include "src/inspector/v8-debugger.h" |
41 #include "src/inspector/v8-inspector-impl.h" | 42 #include "src/inspector/v8-inspector-impl.h" |
42 #include "src/inspector/v8-inspector-session-impl.h" | 43 #include "src/inspector/v8-inspector-session-impl.h" |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
638 } | 639 } |
639 ProtocolPromiseHandler<RunScriptCallback>::add( | 640 ProtocolPromiseHandler<RunScriptCallback>::add( |
640 m_inspector, scope.context(), maybeResultValue.ToLocalChecked(), | 641 m_inspector, scope.context(), maybeResultValue.ToLocalChecked(), |
641 "Result of the script execution is not a promise", | 642 "Result of the script execution is not a promise", |
642 m_session->contextGroupId(), | 643 m_session->contextGroupId(), |
643 scope.injectedScript()->context()->contextId(), objectGroup.fromMaybe(""), | 644 scope.injectedScript()->context()->contextId(), objectGroup.fromMaybe(""), |
644 returnByValue.fromMaybe(false), generatePreview.fromMaybe(false), | 645 returnByValue.fromMaybe(false), generatePreview.fromMaybe(false), |
645 std::move(callback)); | 646 std::move(callback)); |
646 } | 647 } |
647 | 648 |
649 Response V8RuntimeAgentImpl::startPreciseCoverage() { | |
650 v8::debug::Coverage::TogglePrecise(m_inspector->isolate(), true); | |
kozy
2017/02/16 16:47:19
We can be prepared for more then one runtime agent
Yang
2017/02/20 11:24:42
Done.
| |
651 return Response::OK(); | |
652 } | |
653 | |
654 Response V8RuntimeAgentImpl::stopPreciseCoverage() { | |
655 v8::debug::Coverage::TogglePrecise(m_inspector->isolate(), false); | |
kozy
2017/02/16 16:47:19
- please toggle precise off in V8RuntimeAgentImpl:
Yang
2017/02/20 11:24:42
Done.
| |
656 return Response::OK(); | |
657 } | |
658 | |
659 namespace { | |
660 std::unique_ptr<protocol::Runtime::CoverageRange> CreateCoverageRange( | |
kozy
2017/02/16 16:47:19
We still use not V8 code style here, let's don't m
Yang
2017/02/20 11:24:42
Acknowledged.
| |
661 v8::debug::Coverage::Range range) { | |
662 std::unique_ptr<protocol::Array<protocol::Runtime::CoverageRange>> nested = | |
663 protocol::Array<protocol::Runtime::CoverageRange>::create(); | |
664 for (size_t i = 0; i < range.NestedCount(); i++) { | |
665 nested->addItem(CreateCoverageRange(range.GetNested(i))); | |
666 } | |
667 return protocol::Runtime::CoverageRange::create() | |
668 .setFunctionName( | |
669 toProtocolString(range.Name().FromMaybe(v8::Local<v8::String>()))) | |
670 .setStartLineNumber(range.Start().GetLineNumber()) | |
671 .setStartColumnNumber(range.Start().GetColumnNumber()) | |
672 .setEndLineNumber(range.End().GetLineNumber()) | |
673 .setEndColumnNumber(range.End().GetColumnNumber()) | |
674 .setNested(std::move(nested)) | |
675 .setCount(range.Count()) | |
676 .build(); | |
677 } | |
678 } // anonymous namespace | |
679 | |
680 Response V8RuntimeAgentImpl::collectCoverage( | |
681 std::unique_ptr<protocol::Array<protocol::Runtime::ScriptCoverage>>* | |
682 out_result) { | |
683 std::unique_ptr<protocol::Array<protocol::Runtime::ScriptCoverage>> result = | |
684 protocol::Array<protocol::Runtime::ScriptCoverage>::create(); | |
685 v8::HandleScope handle_scope(m_inspector->isolate()); | |
686 v8::debug::Coverage coverage = | |
687 v8::debug::Coverage::Collect(m_inspector->isolate()); | |
688 for (size_t i = 0; i < coverage.ScriptCount(); i++) { | |
689 v8::Local<v8::debug::Script> script = coverage.GetScript(i); | |
690 String16 url; | |
691 v8::Local<v8::String> name; | |
692 if (script->Name().ToLocal(&name) || script->SourceURL().ToLocal(&name)) { | |
693 url = toProtocolString(name); | |
694 } | |
695 result->addItem(protocol::Runtime::ScriptCoverage::create() | |
696 .setScriptId(String16::fromInteger(script->Id())) | |
697 .setUrl(url) | |
698 .setToplevel(CreateCoverageRange(coverage.GetRange(i))) | |
699 .build()); | |
700 } | |
701 *out_result = std::move(result); | |
702 return Response::OK(); | |
703 } | |
704 | |
648 void V8RuntimeAgentImpl::restore() { | 705 void V8RuntimeAgentImpl::restore() { |
649 if (!m_state->booleanProperty(V8RuntimeAgentImplState::runtimeEnabled, false)) | 706 if (!m_state->booleanProperty(V8RuntimeAgentImplState::runtimeEnabled, false)) |
650 return; | 707 return; |
651 m_frontend.executionContextsCleared(); | 708 m_frontend.executionContextsCleared(); |
652 enable(); | 709 enable(); |
653 if (m_state->booleanProperty( | 710 if (m_state->booleanProperty( |
654 V8RuntimeAgentImplState::customObjectFormatterEnabled, false)) | 711 V8RuntimeAgentImplState::customObjectFormatterEnabled, false)) |
655 m_session->setCustomObjectFormatterEnabled(true); | 712 m_session->setCustomObjectFormatterEnabled(true); |
656 } | 713 } |
657 | 714 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
730 } | 787 } |
731 | 788 |
732 bool V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, | 789 bool V8RuntimeAgentImpl::reportMessage(V8ConsoleMessage* message, |
733 bool generatePreview) { | 790 bool generatePreview) { |
734 message->reportToFrontend(&m_frontend, m_session, generatePreview); | 791 message->reportToFrontend(&m_frontend, m_session, generatePreview); |
735 m_frontend.flush(); | 792 m_frontend.flush(); |
736 return m_inspector->hasConsoleMessageStorage(m_session->contextGroupId()); | 793 return m_inspector->hasConsoleMessageStorage(m_session->contextGroupId()); |
737 } | 794 } |
738 | 795 |
739 } // namespace v8_inspector | 796 } // namespace v8_inspector |
OLD | NEW |