Chromium Code Reviews| Index: runtime/bin/vmservice/client/lib/service_html.dart |
| diff --git a/runtime/bin/vmservice/client/lib/service_html.dart b/runtime/bin/vmservice/client/lib/service_html.dart |
| index 83df4d299babf58f5e12ff43bb9dc189746a3615..eae9e5a3adb287312fd631b594db831f15fb55fe 100644 |
| --- a/runtime/bin/vmservice/client/lib/service_html.dart |
| +++ b/runtime/bin/vmservice/client/lib/service_html.dart |
| @@ -15,13 +15,25 @@ import 'package:observatory/service.dart'; |
| export 'package:observatory/service.dart'; |
| class HttpVM extends VM { |
| - final String address; |
| + String host; |
| - HttpVM(this.address) : super(); |
| + bool runningInJavaScript() => identical(1.0, 1); |
| + |
| + HttpVM() : super() { |
| + if (runningInJavaScript()) { |
| + // When we are running as JavaScript use the same hostname:port |
| + // that the Observatory is loaded from. |
| + host = 'http://${window.location.host}/'; |
| + } else { |
| + // Otherwise, assume we are running from the Dart Editor and |
| + // want to connect on the defaul port. |
|
turnidge
2014/03/21 19:48:45
defaul -> default
|
| + host = 'http://127.0.0.1:8181/'; |
| + } |
| + } |
| Future<String> getString(String id) { |
| - Logger.root.info('Fetching $id from $address'); |
| - return HttpRequest.getString(address + id).catchError((error) { |
| + Logger.root.info('Fetching $id from $host'); |
| + return HttpRequest.getString(host + id).catchError((error) { |
| // If we get an error here, the network request has failed. |
| Logger.root.severe('HttpRequest.getString failed.'); |
| return JSON.encode({ |