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

Unified Diff: runtime/bin/vmservice/client/lib/src/observatory/request_manager.dart

Issue 59283007: List scripts in library and display script source (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
Index: runtime/bin/vmservice/client/lib/src/observatory/request_manager.dart
diff --git a/runtime/bin/vmservice/client/lib/src/observatory/request_manager.dart b/runtime/bin/vmservice/client/lib/src/observatory/request_manager.dart
index 328601d187ae2eccc65dba846a17bfb7f469771f..9a26b54db315a120a005e7bfd302bb953f20cc86 100644
--- a/runtime/bin/vmservice/client/lib/src/observatory/request_manager.dart
+++ b/runtime/bin/vmservice/client/lib/src/observatory/request_manager.dart
@@ -47,11 +47,47 @@ abstract class RequestManager extends Observable {
/// Request [requestString] from the VM service. Updates [responses].
/// Will trigger [interceptor] if one is set.
- Future<Map> get(String requestString) {
- request(requestString).then((responseString) {
- parseResponses(responseString);
+ void get(String requestString) {
+ if (_application.locationManager.isScriptLink) {
+ // We cache script sources.
+ String scriptName = _application.locationManager.scriptName;
+ getScriptSource(scriptName, requestString).then((source) {
+ if (source != null) {
+ setResponses([{
+ 'type': 'Script',
+ 'source': source
+ }]);
+ } else {
+ setResponses([{
+ 'type': 'RequestError',
+ 'error': 'Source for $scriptName could not be loaded.'
+ }]);
+ }
+ });
+ } else {
+ request(requestString).then((responseString) {
+ parseResponses(responseString);
+ }).catchError((e) {
+ setResponseError(e.target);
+ });
+ }
+ }
+
+ Future<ScriptSource> getScriptSource(String name, String requestString) {
+ int isolateId = _application.locationManager.currentIsolateId();
+ Isolate isolate = _application.isolateManager.getIsolate(isolateId);
+ ScriptSource source = isolate.scripts[name];
+ if (source != null) {
+ return new Future.value(source);
+ }
+ return request(requestString).then((responseString) {
+ var r = JSON.decode(responseString);
+ ScriptSource scriptSource = new ScriptSource(r);
+ isolate.scripts[name] = scriptSource;
+ return scriptSource;
}).catchError((e) {
setResponseError(e.target);
+ return null;
});
}

Powered by Google App Engine
This is Rietveld 408576698