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; |
}); |
} |