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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library vm_connect_element; 5 library vm_connect_element;
6 6
7 import 'dart:html'; 7 import 'dart:html';
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'package:observatory/models.dart' as M; 10 import 'package:observatory/models.dart' as M;
11 import 'package:observatory/app.dart';
11 import 'package:observatory/src/elements/helpers/tag.dart'; 12 import 'package:observatory/src/elements/helpers/tag.dart';
12 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 13 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
13 import 'package:observatory/src/elements/helpers/nav_bar.dart'; 14 import 'package:observatory/src/elements/helpers/nav_bar.dart';
14 import 'package:observatory/src/elements/nav/notify.dart'; 15 import 'package:observatory/src/elements/nav/notify.dart';
15 import 'package:observatory/src/elements/nav/top_menu.dart'; 16 import 'package:observatory/src/elements/nav/top_menu.dart';
16 import 'package:observatory/src/elements/view_footer.dart'; 17 import 'package:observatory/src/elements/view_footer.dart';
17 import 'package:observatory/src/elements/vm_connect_target.dart'; 18 import 'package:observatory/src/elements/vm_connect_target.dart';
18 19
19 typedef void CrashDumpLoadCallback(Map dump); 20 typedef void CrashDumpLoadCallback(Map dump);
20 21
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 new DivElement() 87 new DivElement()
87 ..classes = ['flex-row'] 88 ..classes = ['flex-row']
88 ..children = [ 89 ..children = [
89 new DivElement() 90 new DivElement()
90 ..classes = ['flex-item-40-percent'] 91 ..classes = ['flex-item-40-percent']
91 ..children = [ 92 ..children = [
92 new HeadingElement.h2()..text = 'WebSocket', 93 new HeadingElement.h2()..text = 'WebSocket',
93 new BRElement(), 94 new BRElement(),
94 new UListElement() 95 new UListElement()
95 ..children = _targets.list().map((target) { 96 ..children = _targets.list().map((target) {
97 final ObservatoryApplication app =
98 ObservatoryApplication.app;
99 final bool current = app.isConnectedVMTarget(target);
96 return new LIElement() 100 return new LIElement()
97 ..children = [new VMConnectTargetElement(target, 101 ..children = [new VMConnectTargetElement(target,
98 current: target == _targets.current, queue: _r.queue) 102 current: current, queue: _r.queue)
99 ..onConnect.listen(_connect) 103 ..onConnect.listen(_connect)
100 ..onDelete.listen(_delete) 104 ..onDelete.listen(_delete)
101 ]; 105 ];
102 }).toList(), 106 }).toList(),
103 new HRElement(), 107 new HRElement(),
104 new FormElement() 108 new FormElement()
105 ..autocomplete = 'on' 109 ..autocomplete = 'on'
106 ..children = [ 110 ..children = [
107 _createAddressBox(), 111 _createAddressBox(),
108 new SpanElement()..text = ' ', 112 new SpanElement()..text = ' ',
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 var crashDump = JSON.decode(reader.result); 167 var crashDump = JSON.decode(reader.result);
164 _loadDump(crashDump); 168 _loadDump(crashDump);
165 }); 169 });
166 }); 170 });
167 return e; 171 return e;
168 } 172 }
169 void _create() { 173 void _create() {
170 if (_address == null || _address.isEmpty) return; 174 if (_address == null || _address.isEmpty) return;
171 _targets.add(_normalizeStandaloneAddress(_address)); 175 _targets.add(_normalizeStandaloneAddress(_address));
172 } 176 }
173 void _connect(TargetEvent e) => _targets.setCurrent(e.target); 177 void _connect(TargetEvent e) {
178 _targets.setCurrent(e.target);
179 }
174 void _delete(TargetEvent e) => _targets.delete(e.target); 180 void _delete(TargetEvent e) => _targets.delete(e.target);
175 181
176 static String _normalizeStandaloneAddress(String networkAddress) { 182 static String _normalizeStandaloneAddress(String networkAddress) {
177 if (networkAddress.startsWith('ws://')) { 183 if (!networkAddress.startsWith('http') && !networkAddress.startsWith('ws')) {
184 networkAddress = 'http://$networkAddress';
185 }
186 try {
187 Uri uri = Uri.parse(networkAddress);
188 print('returning ${uri.host} ${uri.port}');
189 return 'ws://${uri.host}:${uri.port}/ws';
190 } catch (e) {
191 print('caught exception with: $networkAddress -- $e');
178 return networkAddress; 192 return networkAddress;
179 } 193 }
180 return 'ws://${networkAddress}/ws';
181 } 194 }
182 } 195 }
OLDNEW
« 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