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

Unified Diff: runtime/observatory/lib/src/repositories/target.dart

Issue 3009013002: Allow port and host override in Observatory (Closed)
Patch Set: Added documentation Created 3 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/lib/src/repositories/target.dart
diff --git a/runtime/observatory/lib/src/repositories/target.dart b/runtime/observatory/lib/src/repositories/target.dart
index 0756956e6badedf7eeeee7cdd67d39a61845b057..482dd7d4bcaad22954d77e963a1aad04b60490ec 100644
--- a/runtime/observatory/lib/src/repositories/target.dart
+++ b/runtime/observatory/lib/src/repositories/target.dart
@@ -107,12 +107,20 @@ class TargetRepository implements M.TargetRepository {
}
static String _networkAddressOfDefaultTarget() {
- if (!identical(1, 1.0)) {
- // Dartium, assume we are developing.
- return 'ws://127.0.0.1:8181/ws';
- }
- Uri serverAddress = Uri.parse(window.location.toString());
- return 'ws://${serverAddress.authority}${serverAddress.path}ws';
+ // It is possible to override the default port and host by adding extra
+ // query parameters:
+ // http://localhost:8080?override-port=8181
+ // http://localhost:8080?override-port=8181&override-host=10.0.0.2
+ final Uri serverAddress = Uri.parse(window.location.toString());
+ final String port = serverAddress.queryParameters['override-port'];
+ final String host = serverAddress.queryParameters['override-host'];
+ final Uri wsAddress = new Uri(
+ scheme: 'ws',
+ host: host ?? serverAddress.host,
+ port: int.parse(port ?? '', onError: (_) => null),
+ path: '/ws',
+ );
+ return wsAddress.toString();
}
bool isConnectedVMTarget(M.Target target) => _isConnectedVMTarget(target);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698