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

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

Issue 1815753002: [DevTools] Move getFunctionDetails to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-get-internal-properties
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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str ing16& functionId, OwnPtr<FunctionDetails>* details) 680 void V8DebuggerAgentImpl::getFunctionDetails(ErrorString* errorString, const Str ing16& functionId, OwnPtr<FunctionDetails>* details)
681 { 681 {
682 if (!checkEnabled(errorString)) 682 if (!checkEnabled(errorString))
683 return; 683 return;
684 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, functio nId); 684 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, functio nId);
685 if (!remoteId) 685 if (!remoteId)
686 return; 686 return;
687 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get()); 687 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get());
688 if (!injectedScript) 688 if (!injectedScript)
689 return; 689 return;
690 injectedScript->getFunctionDetails(errorString, functionId, details); 690
691 v8::HandleScope scope(m_isolate);
692 v8::Local<v8::Context> context = injectedScript->context();
693 v8::Context::Scope contextScope(context);
694
695 v8::Local<v8::Value> value;
696 if (!injectedScript->findObject(errorString, *remoteId, &value))
697 return;
698 if (!value->IsObject() || !value->IsFunction()) {
dgozman 2016/03/18 23:27:55 Only function.
kozy 2016/03/19 00:40:23 Done.
699 *errorString = "Cannot resolve function by id";
dgozman 2016/03/18 23:27:55 Value with given id is not a function.
kozy 2016/03/19 00:40:23 Done.
700 return;
701 }
702 v8::Local<v8::Function> function = value.As<v8::Function>();
703
704 v8::Local<v8::Value> scopesValue;
705 v8::Local<v8::Array> scopes;
706 String16 objectGroupName = injectedScript->objectGroupName(*remoteId);
707 if (m_debugger->functionScopes(function).ToLocal(&scopesValue) && scopesValu e->IsArray()) {
708 scopes = scopesValue.As<v8::Array>();
709 for (size_t i = 0; i < scopes->Length(); ++i) {
710 v8::Local<v8::Value> scope;
711 if (!scopes->Get(injectedScript->context(), i).ToLocal(&scope) || !s cope->IsObject()) {
712 *errorString = "Internal error";
713 return;
714 }
715 if (!injectedScript->wrapObjectProperty(errorString, scope.As<v8::Ob ject>(), toV8String(injectedScript->isolate(), "object"), objectGroupName))
716 return;
717 }
718 }
719
720 OwnPtr<protocol::Debugger::Location> location = protocol::Debugger::Location ::create()
721 .setScriptId(String16::number(function->ScriptId()))
722 .setLineNumber(function->GetScriptLineNumber())
723 .setColumnNumber(function->GetScriptColumnNumber()).build();
724
725 OwnPtr<FunctionDetails> functionDetails = FunctionDetails::create()
726 .setLocation(location.release())
727 .setFunctionName(toProtocolStringWithTypeCheck(function->GetDebugName()) )
728 .setIsGenerator(function->IsGeneratorFunction()).build();
729
730 if (!scopes.IsEmpty()) {
731 protocol::ErrorSupport errorSupport;
732 OwnPtr<protocol::Array<protocol::Debugger::Scope>> scopeChain = protocol ::Array<protocol::Debugger::Scope>::parse(toProtocolValue(injectedScript->contex t(), scopes).get(), &errorSupport);
733 if (errorSupport.hasErrors()) {
734 *errorString = "Internal error";
735 return;
736 }
737 functionDetails->setScopeChain(scopeChain.release());
738 }
739
740 *details = functionDetails.release();
691 } 741 }
692 742
693 void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, co nst String16& objectId, OwnPtr<GeneratorObjectDetails>* outDetails) 743 void V8DebuggerAgentImpl::getGeneratorObjectDetails(ErrorString* errorString, co nst String16& objectId, OwnPtr<GeneratorObjectDetails>* outDetails)
694 { 744 {
695 if (!checkEnabled(errorString)) 745 if (!checkEnabled(errorString))
696 return; 746 return;
697 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectI d); 747 OwnPtr<RemoteObjectId> remoteId = RemoteObjectId::parse(errorString, objectI d);
698 if (!remoteId) 748 if (!remoteId)
699 return; 749 return;
700 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get()); 750 InjectedScript* injectedScript = m_injectedScriptManager->findInjectedScript (errorString, remoteId.get());
701 if (!injectedScript) 751 if (!injectedScript)
702 return; 752 return;
703 753
704 v8::HandleScope scope(m_isolate); 754 v8::HandleScope scope(m_isolate);
705 v8::Local<v8::Context> context = injectedScript->context(); 755 v8::Local<v8::Context> context = injectedScript->context();
706 v8::Context::Scope contextScope(context); 756 v8::Context::Scope contextScope(context);
707 757
708 v8::Local<v8::Object> object; 758 v8::Local<v8::Object> object;
709 v8::Local<v8::Value> value; 759 v8::Local<v8::Value> value;
710 if (!injectedScript->findObject(errorString, *remoteId, &value)) 760 if (!injectedScript->findObject(errorString, *remoteId, &value))
711 return; 761 return;
712 if (!value->IsObject() || !value->ToObject(context).ToLocal(&object)) { 762 if (!value->IsObject() || !value->ToObject(context).ToLocal(&object)) {
713 *errorString = "Could not find object with type Object and given id"; 763 *errorString = "Cannot resolve function by id.";
dgozman 2016/03/18 23:27:55 revert
kozy 2016/03/19 00:40:23 Done.
714 return; 764 return;
715 } 765 }
716 766
717 v8::Local<v8::Object> detailsObject; 767 v8::Local<v8::Object> detailsObject;
718 v8::Local<v8::Value> detailsValue = debugger().generatorObjectDetails(object ); 768 v8::Local<v8::Value> detailsValue = debugger().generatorObjectDetails(object );
719 if (!detailsValue->IsObject() || !detailsValue->ToObject(context).ToLocal(&d etailsObject)) { 769 if (!detailsValue->IsObject() || !detailsValue->ToObject(context).ToLocal(&d etailsObject)) {
720 *errorString = "Internal error"; 770 *errorString = "Internal error";
721 return; 771 return;
722 } 772 }
723 773
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 m_scripts.clear(); 1624 m_scripts.clear();
1575 m_blackboxedPositions.clear(); 1625 m_blackboxedPositions.clear();
1576 m_breakpointIdToDebuggerBreakpointIds.clear(); 1626 m_breakpointIdToDebuggerBreakpointIds.clear();
1577 resetAsyncCallTracker(); 1627 resetAsyncCallTracker();
1578 m_promiseTracker->clear(); 1628 m_promiseTracker->clear();
1579 if (m_frontend) 1629 if (m_frontend)
1580 m_frontend->globalObjectCleared(); 1630 m_frontend->globalObjectCleared();
1581 } 1631 }
1582 1632
1583 } // namespace blink 1633 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698