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

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: Created 4 years, 5 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) 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) {
Cutch 2016/07/25 13:57:15 why was this made private?
cbernaschina 2016/07/25 17:27:28 Changing the current VM without informing the rest
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 _removeDisconnectEvents();
35 targets.add(vm.target);
36 }
37 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; 53 //final TargetManager targets;
Cutch 2016/07/25 13:57:15 why is this commented out?
cbernaschina 2016/07/25 17:27:28 Dead code. I removed it in the last commit. done
56 @reflectable final ObservatoryApplicationElement rootElement; 54 @reflectable final ObservatoryApplicationElement rootElement;
57 55
58 TraceViewElement _traceView = null; 56 TraceViewElement _traceView = null;
59 57
60 @reflectable ServiceObject lastErrorOrException; 58 @reflectable ServiceObject lastErrorOrException;
61 59
62 void _initOnce() { 60 void _initOnce() {
63 assert(app == null); 61 assert(app == null);
64 app = this; 62 app = this;
65 _registerPages(); 63 _registerPages();
66 Analytics.initialize(); 64 Analytics.initialize();
67 // Visit the current page. 65 // Visit the current page.
68 locationManager._visit(); 66 locationManager._visit();
69 } 67 }
70 68
69 void removePauseEvents(Isolate isolate) {
70 var remove = notifications.list().where((notification) {
71 var event = notification.event;
72 return notification is M.EventNotification &&
73 notification.event is M.IsolateEvent &&
74 notification.event.isolate == isolate &&
75 M.Event.isPauseEvent(notification.event);
76 }).toList(growable: false);
77 remove.forEach((notification) {
78 notifications.delete(notification);
79 });
80 }
81
71 void _onEvent(ServiceEvent event) { 82 void _onEvent(ServiceEvent event) {
72 assert(event.kind != ServiceEvent.kNone); 83 assert(event.kind != ServiceEvent.kNone);
73 84
74 switch(event.kind) { 85 switch(event.kind) {
75 case ServiceEvent.kVMUpdate: 86 case ServiceEvent.kVMUpdate:
76 case ServiceEvent.kIsolateStart: 87 case ServiceEvent.kIsolateStart:
77 case ServiceEvent.kIsolateRunnable: 88 case ServiceEvent.kIsolateRunnable:
78 case ServiceEvent.kIsolateUpdate: 89 case ServiceEvent.kIsolateUpdate:
79 case ServiceEvent.kBreakpointAdded: 90 case ServiceEvent.kBreakpointAdded:
80 case ServiceEvent.kBreakpointResolved: 91 case ServiceEvent.kBreakpointResolved:
81 case ServiceEvent.kBreakpointRemoved: 92 case ServiceEvent.kBreakpointRemoved:
82 case ServiceEvent.kDebuggerSettingsUpdate: 93 case ServiceEvent.kDebuggerSettingsUpdate:
83 // Ignore for now. 94 // Ignore for now.
84 break; 95 break;
85 96
86 case ServiceEvent.kIsolateReload: 97 case ServiceEvent.kIsolateReload:
87 notifications.add(new EventNotification.fromServiceEvent(event)); 98 notifications.add(new EventNotification.fromServiceEvent(event));
88 break; 99 break;
89 100
90 case ServiceEvent.kIsolateExit: 101 case ServiceEvent.kIsolateExit:
91 case ServiceEvent.kResume: 102 case ServiceEvent.kResume:
92 notifications.deletePauseEvents(isolate: event.isolate); 103 removePauseEvents(event.isolate);
93 break; 104 break;
94 105
95 case ServiceEvent.kPauseStart: 106 case ServiceEvent.kPauseStart:
96 case ServiceEvent.kPauseExit: 107 case ServiceEvent.kPauseExit:
97 case ServiceEvent.kPauseBreakpoint: 108 case ServiceEvent.kPauseBreakpoint:
98 case ServiceEvent.kPauseInterrupted: 109 case ServiceEvent.kPauseInterrupted:
99 case ServiceEvent.kPauseException: 110 case ServiceEvent.kPauseException:
100 notifications.deletePauseEvents(isolate: event.isolate); 111 removePauseEvents(event.isolate);
101 notifications.add(new EventNotification.fromServiceEvent(event)); 112 notifications.add(new EventNotification.fromServiceEvent(event));
102 break; 113 break;
103 114
104 case ServiceEvent.kInspect: 115 case ServiceEvent.kInspect:
105 notifications.add(new EventNotification.fromServiceEvent(event)); 116 notifications.add(new EventNotification.fromServiceEvent(event));
106 break; 117 break;
107 118
108 default: 119 default:
109 // Ignore unrecognized events. 120 // Ignore unrecognized events.
110 Logger.root.severe('Unrecognized event: $event'); 121 Logger.root.severe('Unrecognized event: $event');
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 198
188 // Add tracing support. 199 // Add tracing support.
189 _traceView = new Element.tag('trace-view'); 200 _traceView = new Element.tag('trace-view');
190 _traceView.tracer = Tracer.current; 201 _traceView.tracer = Tracer.current;
191 rootElement.children.add(_traceView); 202 rootElement.children.add(_traceView);
192 203
193 // Remember page. 204 // Remember page.
194 currentPage = page; 205 currentPage = page;
195 } 206 }
196 207
197 ObservatoryApplication(this.rootElement) : 208 ObservatoryApplication(this.rootElement) {
198 targets = new TargetManager() {
199 _locationManager = new LocationManager(this); 209 _locationManager = new LocationManager(this);
200 vm = new WebSocketVM(targets.defaultTarget); 210 targets.onChange.listen((e) {
211 if (targets.current == null) return _setVM(null);
212 if ((_vm as WebSocketVM)?.target != targets.current) {
213 _setVM(new WebSocketVM(targets.current));
214 }
215 });
216 _setVM(new WebSocketVM(targets.current));
201 _initOnce(); 217 _initOnce();
202 } 218 }
203 219
220 void _removeDisconnectEvents() {
221 var remove = notifications.list().where((notification) {
222 return notification is EventNotification &&
223 notification.event is M.ConnectionClosedEvent;
224 }).toList(growable: false);
225 remove.forEach((notification){
226 notifications.delete(notification);
227 });
228 }
229
204 loadCrashDump(Map crashDump) { 230 loadCrashDump(Map crashDump) {
205 this.vm = new FakeVM(crashDump['result']); 231 _setVM(new FakeVM(crashDump['result']));
206 app.locationManager.go('#/vm'); 232 app.locationManager.go('#/vm');
207 } 233 }
208 234
209 void handleException(e, st) { 235 void handleException(e, st) {
210 if (e is ServerRpcException) { 236 if (e is ServerRpcException) {
211 if (e.code == ServerRpcException.kFeatureDisabled) return; 237 if (e.code == ServerRpcException.kFeatureDisabled) return;
212 if (e.code == ServerRpcException.kIsolateMustBePaused) return; 238 if (e.code == ServerRpcException.kIsolateMustBePaused) return;
213 if (e.code == ServerRpcException.kCannotAddBreakpoint) return; 239 if (e.code == ServerRpcException.kCannotAddBreakpoint) return;
214 Logger.root.fine('Dropping exception: ${e}\n${st}'); 240 Logger.root.fine('Dropping exception: ${e}\n${st}');
215 } 241 }
216 242
217 // TODO(turnidge): Report this failure via analytics. 243 // TODO(turnidge): Report this failure via analytics.
218 Logger.root.warning('Caught exception: ${e}\n${st}'); 244 Logger.root.warning('Caught exception: ${e}\n${st}');
219 notifications.add(new ExceptionNotification(e, stacktrace: st)); 245 notifications.add(new ExceptionNotification(e, stacktrace: st));
220 } 246 }
221 247
222 // This map keeps track of which curly-blocks have been expanded by the user. 248 // This map keeps track of which curly-blocks have been expanded by the user.
223 Map<String,bool> expansions = {}; 249 Map<String,bool> expansions = {};
224 } 250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698