Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerAgentImpl.cpp

Issue 1810283003: [DevTools] Move getCollectionEntries to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-get-function-details
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/V8DebuggerAgentImpl.h" 5 #include "platform/v8_inspector/V8DebuggerAgentImpl.h"
6 6
7 #include "platform/inspector_protocol/String16.h" 7 #include "platform/inspector_protocol/String16.h"
8 #include "platform/inspector_protocol/Values.h" 8 #include "platform/inspector_protocol/Values.h"
9 #include "platform/v8_inspector/IgnoreExceptionsScope.h" 9 #include "platform/v8_inspector/IgnoreExceptionsScope.h"
10 #include "platform/v8_inspector/InjectedScript.h" 10 #include "platform/v8_inspector/InjectedScript.h"
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 if (!injectedScript->findObject(errorString, *remoteId, &value)) 695 if (!injectedScript->findObject(errorString, *remoteId, &value))
696 return; 696 return;
697 if (!value->IsFunction()) { 697 if (!value->IsFunction()) {
698 *errorString = "Value with given id is not a function"; 698 *errorString = "Value with given id is not a function";
699 return; 699 return;
700 } 700 }
701 v8::Local<v8::Function> function = value.As<v8::Function>(); 701 v8::Local<v8::Function> function = value.As<v8::Function>();
702 702
703 v8::Local<v8::Value> scopesValue; 703 v8::Local<v8::Value> scopesValue;
704 v8::Local<v8::Array> scopes; 704 v8::Local<v8::Array> scopes;
705 String16 objectGroupName = injectedScript->objectGroupName(*remoteId); 705 String16 groupName = injectedScript->objectGroupName(*remoteId);
706 if (m_debugger->functionScopes(function).ToLocal(&scopesValue) && scopesValu e->IsArray()) { 706 if (m_debugger->functionScopes(function).ToLocal(&scopesValue) && scopesValu e->IsArray()) {
707 scopes = scopesValue.As<v8::Array>(); 707 scopes = scopesValue.As<v8::Array>();
708 for (size_t i = 0; i < scopes->Length(); ++i) { 708 if (!injectedScript->wrapObjectsInArray(errorString, scopes, toV8StringI nternalized(injectedScript->isolate(), "object"), groupName))
709 v8::Local<v8::Value> scope; 709 return;
710 if (!scopes->Get(injectedScript->context(), i).ToLocal(&scope) || !s cope->IsObject()) {
711 *errorString = "Internal error";
712 return;
713 }
714 if (!injectedScript->wrapObjectProperty(errorString, scope.As<v8::Ob ject>(), toV8String(injectedScript->isolate(), "object"), objectGroupName))
715 return;
716 }
717 } 710 }
718 711
719 OwnPtr<protocol::Debugger::Location> location = protocol::Debugger::Location ::create() 712 OwnPtr<protocol::Debugger::Location> location = protocol::Debugger::Location ::create()
720 .setScriptId(String16::number(function->ScriptId())) 713 .setScriptId(String16::number(function->ScriptId()))
721 .setLineNumber(function->GetScriptLineNumber()) 714 .setLineNumber(function->GetScriptLineNumber())
722 .setColumnNumber(function->GetScriptColumnNumber()).build(); 715 .setColumnNumber(function->GetScriptColumnNumber()).build();
723 716
724 OwnPtr<FunctionDetails> functionDetails = FunctionDetails::create() 717 OwnPtr<FunctionDetails> functionDetails = FunctionDetails::create()
725 .setLocation(location.release()) 718 .setLocation(location.release())
726 .setFunctionName(toProtocolStringWithTypeCheck(function->GetDebugName()) ) 719 .setFunctionName(toProtocolStringWithTypeCheck(function->GetDebugName()) )
727 .setIsGenerator(function->IsGeneratorFunction()).build(); 720 .setIsGenerator(function->IsGeneratorFunction()).build();
728 721
729 if (!scopes.IsEmpty()) { 722 if (!scopes.IsEmpty()) {
730 protocol::ErrorSupport errorSupport; 723 protocol::ErrorSupport errorSupport;
731 OwnPtr<protocol::Array<protocol::Debugger::Scope>> scopeChain = protocol ::Array<protocol::Debugger::Scope>::parse(toProtocolValue(injectedScript->contex t(), scopes).get(), &errorSupport); 724 OwnPtr<protocol::Array<protocol::Debugger::Scope>> scopeChain = protocol ::Array<protocol::Debugger::Scope>::parse(toProtocolValue(injectedScript->contex t(), scopes).get(), &errorSupport);
732 if (errorSupport.hasErrors()) { 725 if (V8RuntimeAgentImpl::hasInternalError(errorString, errorSupport.hasEr rors()))
dgozman 2016/03/21 17:21:02 Let's have a copy per file.
kozy 2016/03/21 19:45:01 Done.
733 *errorString = "Internal error";
734 return; 726 return;
735 }
736 functionDetails->setScopeChain(scopeChain.release()); 727 functionDetails->setScopeChain(scopeChain.release());
737 } 728 }
738 729
739 *details = functionDetails.release(); 730 *details = functionDetails.release();
740 } 731 }
741 732
742 void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, co nst String16& objectId, OwnPtr<GeneratorObjectDetails>* outDetails) 733 void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, co nst String16& objectId, OwnPtr<GeneratorObjectDetails>* outDetails)
743 { 734 {
744 if (!checkEnabled(errorString)) 735 if (!checkEnabled(errorString))
745 return; 736 return;
(...skipping 12 matching lines...) Expand all
758 v8::Local<v8::Value> value; 749 v8::Local<v8::Value> value;
759 if (!injectedScript->findObject(errorString, *remoteId, &value)) 750 if (!injectedScript->findObject(errorString, *remoteId, &value))
760 return; 751 return;
761 if (!value->IsObject() || !value->ToObject(context).ToLocal(&object)) { 752 if (!value->IsObject() || !value->ToObject(context).ToLocal(&object)) {
762 *errorString = "Value with given id is not an Object"; 753 *errorString = "Value with given id is not an Object";
763 return; 754 return;
764 } 755 }
765 756
766 v8::Local<v8::Object> detailsObject; 757 v8::Local<v8::Object> detailsObject;
767 v8::Local<v8::Value> detailsValue = debugger().generatorObjectDetails(object ); 758 v8::Local<v8::Value> detailsValue = debugger().generatorObjectDetails(object );
768 if (!detailsValue->IsObject() || !detailsValue->ToObject(context).ToLocal(&d etailsObject)) { 759 if (V8RuntimeAgentImpl::hasInternalError(errorString, !detailsValue->IsObjec t() || !detailsValue->ToObject(context).ToLocal(&detailsObject)))
769 *errorString = "Internal error";
770 return; 760 return;
771 }
772 761
773 String16 groupName = injectedScript->objectGroupName(*remoteId); 762 String16 groupName = injectedScript->objectGroupName(*remoteId);
774 if (!injectedScript->wrapObjectProperty(errorString, detailsObject, toV8Stri ng(m_isolate, "function"), groupName)) 763 if (!injectedScript->wrapObjectProperty(errorString, detailsObject, toV8Stri ngInternalized(m_isolate, "function"), groupName))
775 return; 764 return;
776 765
777 protocol::ErrorSupport errors; 766 protocol::ErrorSupport errors;
778 OwnPtr<GeneratorObjectDetails> protocolDetails = GeneratorObjectDetails::par se(toProtocolValue(context, detailsObject).get(), &errors); 767 OwnPtr<GeneratorObjectDetails> protocolDetails = GeneratorObjectDetails::par se(toProtocolValue(context, detailsObject).get(), &errors);
779 if (!protocolDetails) { 768 if (V8RuntimeAgentImpl::hasInternalError(errorString, !protocolDetails))
780 *errorString = "Internal error";
781 return; 769 return;
782 }
783 *outDetails = protocolDetails.release(); 770 *outDetails = protocolDetails.release();
784 } 771 }
785 772
786 void V8DebuggerAgentImpl::getCollectionEntries(ErrorString* errorString, const S tring16& objectId, OwnPtr<protocol::Array<CollectionEntry>>* entries) 773 void V8DebuggerAgentImpl::getCollectionEntries(ErrorString* errorString, const S tring16& objectId, OwnPtr<protocol::Array<CollectionEntry>>* outEntries)
787 { 774 {
788 if (!checkEnabled(errorString)) 775 if (!checkEnabled(errorString))
789 return; 776 return;
790 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectI d); 777 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectI d);
791 if (!remoteId) 778 if (!remoteId)
792 return; 779 return;
793 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get()); 780 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get());
794 if (!injectedScript) 781 if (!injectedScript)
795 return; 782 return;
796 injectedScript->getCollectionEntries(errorString, objectId, entries); 783
784 v8::HandleScope scope(m_isolate);
785 v8::Local<v8::Context> context = injectedScript->context();
786 v8::Context::Scope contextScope(context);
787
788 v8::Local<v8::Value> value;
789 if (!injectedScript->findObject(errorString, *remoteId, &value))
790 return;
791 if (!value->IsObject()) {
792 *errorString = "Object with given id is not a collection";
793 return;
794 }
795 v8::Local<v8::Object> object = value.As<v8::Object>();
796 v8::Local<v8::Value> entriesValue = m_debugger->collectionEntries(object);
797 if (V8RuntimeAgentImpl::hasInternalError(errorString, entriesValue.IsEmpty() ))
798 return;
799 if (entriesValue->IsUndefined()) {
800 *errorString = "Object with given id is not a collection";
801 return;
802 }
803 if (V8RuntimeAgentImpl::hasInternalError(errorString, !entriesValue->IsArray ()))
804 return;
805 String16 groupName = injectedScript->objectGroupName(*remoteId);
806 v8::Local<v8::Array> entriesArray = entriesValue.As<v8::Array>();
807 if (!injectedScript->wrapObjectsInArray(errorString, entriesArray, toV8Strin gInternalized(injectedScript->isolate(), "key"), groupName))
808 return;
809 if (!injectedScript->wrapObjectsInArray(errorString, entriesArray, toV8Strin gInternalized(injectedScript->isolate(), "value"), groupName))
810 return;
811 protocol::ErrorSupport errors;
812 OwnPtr<protocol::Array<CollectionEntry>> entries = protocol::Array<Collectio nEntry>::parse(toProtocolValue(injectedScript->context(), entriesArray).get(), & errors);
813 if (V8RuntimeAgentImpl::hasInternalError(errorString, !entries))
814 return;
815 *outEntries = entries.release();
797 } 816 }
798 817
799 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReas on, PassOwnPtr<protocol::DictionaryValue> data) 818 void V8DebuggerAgentImpl::schedulePauseOnNextStatement(const String16& breakReas on, PassOwnPtr<protocol::DictionaryValue> data)
800 { 819 {
801 ASSERT(enabled()); 820 ASSERT(enabled());
802 if (m_scheduledDebuggerStep == StepInto || m_javaScriptPauseScheduled || isP aused()) 821 if (m_scheduledDebuggerStep == StepInto || m_javaScriptPauseScheduled || isP aused())
803 return; 822 return;
804 m_breakReason = breakReason; 823 m_breakReason = breakReason;
805 m_breakAuxData = data; 824 m_breakAuxData = data;
806 m_pausingOnNativeEvent = true; 825 m_pausingOnNativeEvent = true;
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 return; 1642 return;
1624 m_scheduledDebuggerStep = NoStep; 1643 m_scheduledDebuggerStep = NoStep;
1625 m_scripts.clear(); 1644 m_scripts.clear();
1626 m_blackboxedPositions.clear(); 1645 m_blackboxedPositions.clear();
1627 m_breakpointIdToDebuggerBreakpointIds.clear(); 1646 m_breakpointIdToDebuggerBreakpointIds.clear();
1628 resetAsyncCallTracker(); 1647 resetAsyncCallTracker();
1629 m_promiseTracker->clear(); 1648 m_promiseTracker->clear();
1630 } 1649 }
1631 1650
1632 } // namespace blink 1651 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698