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

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

Issue 2112673003: [DevTools] Move suspended generator location to internal properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed comments Created 4 years, 5 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 /* 1 /*
2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. 2 * Copyright (c) 2010-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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 return v8::MaybeLocal<v8::Array>(); 661 return v8::MaybeLocal<v8::Array>();
662 if (!enabled()) 662 if (!enabled())
663 return properties; 663 return properties;
664 if (value->IsMap() || value->IsWeakMap() || value->IsSet() || value->IsWeakS et() || value->IsSetIterator() || value->IsMapIterator()) { 664 if (value->IsMap() || value->IsWeakMap() || value->IsSet() || value->IsWeakS et() || value->IsSetIterator() || value->IsMapIterator()) {
665 v8::Local<v8::Value> entries = collectionEntries(context, v8::Local<v8:: Object>::Cast(value)); 665 v8::Local<v8::Value> entries = collectionEntries(context, v8::Local<v8:: Object>::Cast(value));
666 if (entries->IsArray()) { 666 if (entries->IsArray()) {
667 properties->Set(properties->Length(), v8InternalizedString("[[Entrie s]]")); 667 properties->Set(properties->Length(), v8InternalizedString("[[Entrie s]]"));
668 properties->Set(properties->Length(), entries); 668 properties->Set(properties->Length(), entries);
669 } 669 }
670 } 670 }
671 if (value->IsGeneratorObject()) {
672 v8::Local<v8::Value> location = generatorObjectLocation(v8::Local<v8::Ob ject>::Cast(value));
673 if (location->IsObject()) {
674 properties->Set(properties->Length(), v8InternalizedString("[[Genera torLocation]]"));
675 properties->Set(properties->Length(), location);
676 }
677 }
671 return properties; 678 return properties;
672 } 679 }
673 680
674 v8::Local<v8::Value> V8DebuggerImpl::generatorObjectDetails(v8::Local<v8::Object >& object)
675 {
676 if (!enabled()) {
677 NOTREACHED();
678 return v8::Local<v8::Value>::New(m_isolate, v8::Undefined(m_isolate));
679 }
680 v8::Local<v8::Value> argv[] = { object };
681 return callDebuggerMethod("getGeneratorObjectDetails", 1, argv).ToLocalCheck ed();
682 }
683
684 v8::Local<v8::Value> V8DebuggerImpl::collectionEntries(v8::Local<v8::Context> co ntext, v8::Local<v8::Object> object) 681 v8::Local<v8::Value> V8DebuggerImpl::collectionEntries(v8::Local<v8::Context> co ntext, v8::Local<v8::Object> object)
685 { 682 {
686 if (!enabled()) { 683 if (!enabled()) {
687 NOTREACHED(); 684 NOTREACHED();
688 return v8::Undefined(m_isolate); 685 return v8::Undefined(m_isolate);
689 } 686 }
690 v8::Local<v8::Value> argv[] = { object }; 687 v8::Local<v8::Value> argv[] = { object };
691 v8::Local<v8::Value> entriesValue = callDebuggerMethod("getCollectionEntries ", 1, argv).ToLocalChecked(); 688 v8::Local<v8::Value> entriesValue = callDebuggerMethod("getCollectionEntries ", 1, argv).ToLocalChecked();
692 if (!entriesValue->IsArray()) 689 if (!entriesValue->IsArray())
693 return v8::Undefined(m_isolate); 690 return v8::Undefined(m_isolate);
694 v8::Local<v8::Array> entries = entriesValue.As<v8::Array>(); 691 v8::Local<v8::Array> entries = entriesValue.As<v8::Array>();
695 for (size_t i = 0; i < entries->Length(); ++i) { 692 for (size_t i = 0; i < entries->Length(); ++i) {
696 v8::Local<v8::Value> entry; 693 v8::Local<v8::Value> entry;
697 if (!entries->Get(context, i).ToLocal(&entry) || !entry->IsObject()) 694 if (!entries->Get(context, i).ToLocal(&entry) || !entry->IsObject())
698 continue; 695 continue;
699 if (!entry.As<v8::Object>()->SetPrivate(context, V8InjectedScriptHost::i nternalEntryPrivate(m_isolate), v8::True(m_isolate)).FromMaybe(false)) 696 if (!entry.As<v8::Object>()->SetPrivate(context, V8InjectedScriptHost::i nternalEntryPrivate(m_isolate), v8::True(m_isolate)).FromMaybe(false))
700 continue; 697 continue;
701 } 698 }
702 if (!entries->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false)) 699 if (!entries->SetPrototype(context, v8::Null(m_isolate)).FromMaybe(false))
703 return v8::Undefined(m_isolate); 700 return v8::Undefined(m_isolate);
704 return entries; 701 return entries;
705 } 702 }
706 703
704 v8::Local<v8::Value> V8DebuggerImpl::generatorObjectLocation(v8::Local<v8::Objec t> object)
705 {
706 if (!enabled()) {
707 NOTREACHED();
708 return v8::Null(m_isolate);
709 }
710 v8::Local<v8::Value> argv[] = { object };
711 v8::Local<v8::Value> location = callDebuggerMethod("getGeneratorObjectLocati on", 1, argv).ToLocalChecked();
712 if (!location->IsObject())
713 return v8::Null(m_isolate);
714 v8::Local<v8::Context> context = m_debuggerContext.Get(m_isolate);
715 if (!location.As<v8::Object>()->SetPrivate(context, V8InjectedScriptHost::in ternalLocationPrivate(m_isolate), v8::True(m_isolate)).FromMaybe(false))
716 return v8::Null(m_isolate);
717 return location;
718 }
719
707 bool V8DebuggerImpl::isPaused() 720 bool V8DebuggerImpl::isPaused()
708 { 721 {
709 return !m_pausedContext.IsEmpty(); 722 return !m_pausedContext.IsEmpty();
710 } 723 }
711 724
712 v8::MaybeLocal<v8::Value> V8DebuggerImpl::runCompiledScript(v8::Local<v8::Contex t> context, v8::Local<v8::Script> script) 725 v8::MaybeLocal<v8::Value> V8DebuggerImpl::runCompiledScript(v8::Local<v8::Contex t> context, v8::Local<v8::Script> script)
713 { 726 {
714 // TODO(dgozman): get rid of this check. 727 // TODO(dgozman): get rid of this check.
715 if (!m_client->isExecutionAllowed()) 728 if (!m_client->isExecutionAllowed())
716 return v8::MaybeLocal<v8::Value>(); 729 return v8::MaybeLocal<v8::Value>();
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1116 1129
1117 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI d) 1130 V8InspectorSessionImpl* V8DebuggerImpl::sessionForContextGroup(int contextGroupI d)
1118 { 1131 {
1119 if (!contextGroupId) 1132 if (!contextGroupId)
1120 return nullptr; 1133 return nullptr;
1121 SessionMap::iterator iter = m_sessions.find(contextGroupId); 1134 SessionMap::iterator iter = m_sessions.find(contextGroupId);
1122 return iter == m_sessions.end() ? nullptr : iter->second; 1135 return iter == m_sessions.end() ? nullptr : iter->second;
1123 } 1136 }
1124 1137
1125 } // namespace blink 1138 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698