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

Unified Diff: runtime/observatory/lib/src/elements/vm_connect.dart

Issue 2340973002: Improve VM connection flow in Observatory (Closed)
Patch Set: ... Created 4 years, 3 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 | « runtime/observatory/lib/src/app/page.dart ('k') | runtime/observatory/lib/src/repositories/isolate.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/lib/src/elements/vm_connect.dart
diff --git a/runtime/observatory/lib/src/elements/vm_connect.dart b/runtime/observatory/lib/src/elements/vm_connect.dart
index 3f20e264765d96599b00bf285ed1ee681ced2de7..9ec96c576f6b7066a3d84cd73aaa14f8e6aa9d5e 100644
--- a/runtime/observatory/lib/src/elements/vm_connect.dart
+++ b/runtime/observatory/lib/src/elements/vm_connect.dart
@@ -8,6 +8,7 @@ import 'dart:html';
import 'dart:async';
import 'dart:convert';
import 'package:observatory/models.dart' as M;
+import 'package:observatory/app.dart';
import 'package:observatory/src/elements/helpers/tag.dart';
import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
import 'package:observatory/src/elements/helpers/nav_bar.dart';
@@ -93,9 +94,12 @@ class VMConnectElement extends HtmlElement implements Renderable {
new BRElement(),
new UListElement()
..children = _targets.list().map((target) {
+ final ObservatoryApplication app =
+ ObservatoryApplication.app;
+ final bool current = app.isConnectedVMTarget(target);
return new LIElement()
..children = [new VMConnectTargetElement(target,
- current: target == _targets.current, queue: _r.queue)
+ current: current, queue: _r.queue)
..onConnect.listen(_connect)
..onDelete.listen(_delete)
];
@@ -170,13 +174,22 @@ class VMConnectElement extends HtmlElement implements Renderable {
if (_address == null || _address.isEmpty) return;
_targets.add(_normalizeStandaloneAddress(_address));
}
- void _connect(TargetEvent e) => _targets.setCurrent(e.target);
+ void _connect(TargetEvent e) {
+ _targets.setCurrent(e.target);
+ }
void _delete(TargetEvent e) => _targets.delete(e.target);
static String _normalizeStandaloneAddress(String networkAddress) {
- if (networkAddress.startsWith('ws://')) {
+ if (!networkAddress.startsWith('http') && !networkAddress.startsWith('ws')) {
+ networkAddress = 'http://$networkAddress';
+ }
+ try {
+ Uri uri = Uri.parse(networkAddress);
+ print('returning ${uri.host} ${uri.port}');
+ return 'ws://${uri.host}:${uri.port}/ws';
+ } catch (e) {
+ print('caught exception with: $networkAddress -- $e');
return networkAddress;
}
- return 'ws://${networkAddress}/ws';
}
}
« no previous file with comments | « runtime/observatory/lib/src/app/page.dart ('k') | runtime/observatory/lib/src/repositories/isolate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698