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

Unified Diff: Source/bindings/dart/DartController.cpp

Issue 24989007: Model each Dart library as its own ScriptState when devtools are enabled. (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/dart/DartController.h ('k') | Source/bindings/dart/DartDebugHooks.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/dart/DartController.cpp
diff --git a/Source/bindings/dart/DartController.cpp b/Source/bindings/dart/DartController.cpp
index 141d85c7619fd9d8be8320892f2867aa5c57dbb5..356e0683eaa556dac35daa3719133010a343a320 100644
--- a/Source/bindings/dart/DartController.cpp
+++ b/Source/bindings/dart/DartController.cpp
@@ -41,6 +41,7 @@
#include "bindings/dart/DartGCController.h"
#include "bindings/dart/DartIsolateDestructionObserver.h"
#include "bindings/dart/DartNativeUtilities.h"
+#include "bindings/dart/DartScriptState.h"
#include "bindings/dart/DartTimeline.h"
#include "bindings/dart/DartUtilities.h"
#include "bindings/dart/ThreadSafeDartIsolateWrapper.h"
@@ -65,6 +66,9 @@
#include <ctype.h>
+#include <dart_api.h>
+#include <dart_debugger_api.h>
+
namespace WebCore {
static void copyValue(Dart_Handle source, const char* fieldName,
@@ -243,6 +247,15 @@ void DartController::clearWindowShell()
Dart_EnterIsolate(currentIsolate);
m_isolates.clear();
+
+ for (ScriptStatesMap::iterator it = m_scriptStates.begin(); it != m_scriptStates.end(); ++it) {
+ LibraryIdMap* libraryIdMap = it->value;
+ for (LibraryIdMap::iterator scriptStateIt = libraryIdMap->begin(); scriptStateIt != libraryIdMap->end(); ++scriptStateIt) {
+ delete scriptStateIt->value;
+ }
+ delete libraryIdMap;
+ }
+ m_scriptStates.clear();
}
static void cleanupAfterCall()
@@ -714,7 +727,6 @@ void DartController::loadScripts()
initVMIfNeeded();
Document* document = frame()->document();
-
RefPtr<NodeList> scripts = document->getElementsByTagName("script");
Vector< RefPtr<Node> > scriptsCopy(scripts->length());
for (unsigned i = 0; i < scripts->length(); ++i)
@@ -875,4 +887,47 @@ DartController* DartController::retrieve(ScriptExecutionContext* context)
return retrieve(static_cast<Document*>(context)->frame());
}
+void DartController::collectScriptStates(ScriptState* v8ScriptState, Vector<ScriptState*>& result)
+{
+ v8::HandleScope handleScope;
+ v8::Handle<v8::Context> v8Context = v8ScriptState->context();
+
+ for (Vector<Dart_Isolate>::iterator it = m_isolates.begin(); it != m_isolates.end(); ++it)
+ collectScriptStatesForIsolate(*it, v8Context, result);
+}
+
+void DartController::collectScriptStatesForIsolate(Dart_Isolate isolate, v8::Handle<v8::Context> v8Context, Vector<ScriptState*>& result)
+{
+ DartIsolateScope scope(isolate);
+ DartApiScope apiScope;
+ ScriptStatesMap::iterator it = m_scriptStates.find(isolate);
+ LibraryIdMap* libraryIdMap;
+ if (it == m_scriptStates.end()) {
+ libraryIdMap = new LibraryIdMap();
+ m_scriptStates.add(isolate, libraryIdMap);
+ } else {
+ libraryIdMap = it->value;
+ }
+ Dart_Handle libraryIdList = Dart_GetLibraryIds();
+
+ intptr_t length = 0;
+ Dart_Handle res = Dart_ListLength(libraryIdList, &length);
+
+ for (intptr_t i = 0; i < length; i++) {
+ Dart_Handle libraryIdHandle = Dart_ListGetAt(libraryIdList, i);
+ Dart_Handle exception = 0;
+ intptr_t libraryId = DartUtilities::toInteger(libraryIdHandle, exception);
+ ASSERT(!exception);
+ LibraryIdMap::iterator libraryIter = libraryIdMap->find(libraryId);
+ DartScriptState* scriptState;
+ if (libraryIter == libraryIdMap->end()) {
+ scriptState = new DartScriptState(isolate, libraryId, v8Context);
+ libraryIdMap->add(libraryId, scriptState);
+ } else {
+ scriptState = libraryIter->value;
+ }
+ result.append(scriptState);
+ }
+}
+
}
« no previous file with comments | « Source/bindings/dart/DartController.h ('k') | Source/bindings/dart/DartDebugHooks.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698