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

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