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

Side by Side Diff: runtime/observatory/lib/src/app/application.dart

Issue 2180803002: Converted Observatory vm-connect element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Renamed DumpRepository to CrashDumpRepository Created 4 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 unified diff | Download patch
« no previous file with comments | « runtime/observatory/lib/repositories.dart ('k') | runtime/observatory/lib/src/app/page.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of app; 5 part of app;
6 6
7 /// The observatory application. Instances of this are created and owned 7 /// The observatory application. Instances of this are created and owned
8 /// by the observatory_application custom element. 8 /// by the observatory_application custom element.
9 class ObservatoryApplication extends Observable { 9 class ObservatoryApplication extends Observable {
10 static ObservatoryApplication app; 10 static ObservatoryApplication app;
11 final RenderingQueue queue = new RenderingQueue(); 11 final RenderingQueue queue = new RenderingQueue();
12 final TargetRepository targets = new TargetRepository();
12 final NotificationRepository notifications = new NotificationRepository(); 13 final NotificationRepository notifications = new NotificationRepository();
13 final _pageRegistry = new List<Page>(); 14 final _pageRegistry = new List<Page>();
14 LocationManager _locationManager; 15 LocationManager _locationManager;
15 LocationManager get locationManager => _locationManager; 16 LocationManager get locationManager => _locationManager;
16 @observable Page currentPage; 17 @observable Page currentPage;
17 VM _vm; 18 VM _vm;
18 VM get vm => _vm; 19 VM get vm => _vm;
19 20
20 set vm(VM vm) { 21 _setVM(VM vm) {
21 if (_vm == vm) { 22 if (_vm == vm) {
22 // Do nothing. 23 // Do nothing.
23 return; 24 return;
24 } 25 }
25 if (_vm != null) { 26 if (_vm != null) {
26 // Disconnect from current VM. 27 // Disconnect from current VM.
27 notifications.deleteAll(); 28 notifications.deleteAll();
28 _vm.disconnect(); 29 _vm.disconnect();
29 } 30 }
30 if (vm != null) { 31 if (vm != null) {
31 Logger.root.info('Registering new VM callbacks'); 32 Logger.root.info('Registering new VM callbacks');
32 33
33 vm.onConnect.then((_) { 34 vm.onConnect.then((_) {
34 if (vm is WebSocketVM) {
35 targets.add(vm.target);
36 }
37 notifications.deleteDisconnectEvents(); 35 notifications.deleteDisconnectEvents();
38 }); 36 });
39 37
40 vm.onDisconnect.then((String reason) { 38 vm.onDisconnect.then((String reason) {
41 if (this.vm != vm) { 39 if (this.vm != vm) {
42 // This disconnect event occured *after* a new VM was installed. 40 // This disconnect event occured *after* a new VM was installed.
43 return; 41 return;
44 } 42 }
45 notifications.add( 43 notifications.add(
46 new EventNotification.fromServiceEvent( 44 new EventNotification.fromServiceEvent(
47 new ServiceEvent.connectionClosed(reason))); 45 new ServiceEvent.connectionClosed(reason)));
48 }); 46 });
49 47
50 vm.listenEventStream(VM.kIsolateStream, _onEvent); 48 vm.listenEventStream(VM.kIsolateStream, _onEvent);
51 vm.listenEventStream(VM.kDebugStream, _onEvent); 49 vm.listenEventStream(VM.kDebugStream, _onEvent);
52 } 50 }
53 _vm = vm; 51 _vm = vm;
54 } 52 }
55 final TargetManager targets;
56 @reflectable final ObservatoryApplicationElement rootElement; 53 @reflectable final ObservatoryApplicationElement rootElement;
57 54
58 TraceViewElement _traceView = null; 55 TraceViewElement _traceView = null;
59 56
60 @reflectable ServiceObject lastErrorOrException; 57 @reflectable ServiceObject lastErrorOrException;
61 58
62 void _initOnce() { 59 void _initOnce() {
63 assert(app == null); 60 assert(app == null);
64 app = this; 61 app = this;
65 _registerPages(); 62 _registerPages();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 184
188 // Add tracing support. 185 // Add tracing support.
189 _traceView = new Element.tag('trace-view'); 186 _traceView = new Element.tag('trace-view');
190 _traceView.tracer = Tracer.current; 187 _traceView.tracer = Tracer.current;
191 rootElement.children.add(_traceView); 188 rootElement.children.add(_traceView);
192 189
193 // Remember page. 190 // Remember page.
194 currentPage = page; 191 currentPage = page;
195 } 192 }
196 193
197 ObservatoryApplication(this.rootElement) : 194 ObservatoryApplication(this.rootElement) {
198 targets = new TargetManager() {
199 _locationManager = new LocationManager(this); 195 _locationManager = new LocationManager(this);
200 vm = new WebSocketVM(targets.defaultTarget); 196 targets.onChange.listen((e) {
197 if (targets.current == null) return _setVM(null);
198 if ((_vm as WebSocketVM)?.target != targets.current) {
199 _setVM(new WebSocketVM(targets.current));
200 }
201 });
202 _setVM(new WebSocketVM(targets.current));
201 _initOnce(); 203 _initOnce();
202 } 204 }
203 205
204 loadCrashDump(Map crashDump) { 206 loadCrashDump(Map crashDump) {
205 this.vm = new FakeVM(crashDump['result']); 207 _setVM(new FakeVM(crashDump['result']));
206 app.locationManager.go('#/vm'); 208 app.locationManager.go('#/vm');
207 } 209 }
208 210
209 void handleException(e, st) { 211 void handleException(e, st) {
210 if (e is ServerRpcException) { 212 if (e is ServerRpcException) {
211 if (e.code == ServerRpcException.kFeatureDisabled) return; 213 if (e.code == ServerRpcException.kFeatureDisabled) return;
212 if (e.code == ServerRpcException.kIsolateMustBePaused) return; 214 if (e.code == ServerRpcException.kIsolateMustBePaused) return;
213 if (e.code == ServerRpcException.kCannotAddBreakpoint) return; 215 if (e.code == ServerRpcException.kCannotAddBreakpoint) return;
214 Logger.root.fine('Dropping exception: ${e}\n${st}'); 216 Logger.root.fine('Dropping exception: ${e}\n${st}');
215 } 217 }
216 218
217 // TODO(turnidge): Report this failure via analytics. 219 // TODO(turnidge): Report this failure via analytics.
218 Logger.root.warning('Caught exception: ${e}\n${st}'); 220 Logger.root.warning('Caught exception: ${e}\n${st}');
219 notifications.add(new ExceptionNotification(e, stacktrace: st)); 221 notifications.add(new ExceptionNotification(e, stacktrace: st));
220 } 222 }
221 223
222 // This map keeps track of which curly-blocks have been expanded by the user. 224 // This map keeps track of which curly-blocks have been expanded by the user.
223 Map<String,bool> expansions = {}; 225 Map<String,bool> expansions = {};
224 } 226 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/repositories.dart ('k') | runtime/observatory/lib/src/app/page.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698