Chromium Code Reviews| 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) |
|
vsm
2013/09/30 22:08:03
This will become just a single isolate.
Note: n
Jacob
2013/10/01 00:07:05
You may be able to break into non-DOM isolates at
|
| + 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); |
| + } |
| +} |
| + |
| } |