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

Unified Diff: runtime/bin/vmservice/client/lib/service_html.dart

Issue 208243006: Allow built in Observatory to work on any port (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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
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({

Powered by Google App Engine
This is Rietveld 408576698