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

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

Issue 2119733003: Wrapping leaf nodes in non polymer elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Converted vm-connect 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 class Notification {
8 Notification.fromEvent(this.event);
9 Notification.fromException(this.exception, this.stacktrace);
10
11 ServiceEvent event;
12 var exception;
13 var stacktrace;
14 }
15
16 /// The observatory application. Instances of this are created and owned 7 /// The observatory application. Instances of this are created and owned
17 /// by the observatory_application custom element. 8 /// by the observatory_application custom element.
18 class ObservatoryApplication extends Observable { 9 class ObservatoryApplication extends Observable {
19 static ObservatoryApplication app; 10 static ObservatoryApplication app;
11 final RenderingQueue queue = new RenderingQueue();
12 final TargetRepository targets = new TargetRepository();
13 final NotificationRepository notifications = new NotificationRepository();
20 final _pageRegistry = new List<Page>(); 14 final _pageRegistry = new List<Page>();
21 LocationManager _locationManager; 15 LocationManager _locationManager;
22 LocationManager get locationManager => _locationManager; 16 LocationManager get locationManager => _locationManager;
23 @observable Page currentPage; 17 @observable Page currentPage;
24 VM _vm; 18 VM _vm;
25 VM get vm => _vm; 19 VM get vm => _vm;
26 20
27 set vm(VM vm) { 21 _setVM(VM vm) {
28 if (_vm == vm) { 22 if (_vm == vm) {
29 // Do nothing. 23 // Do nothing.
30 return; 24 return;
31 } 25 }
32 if (_vm != null) { 26 if (_vm != null) {
33 // Disconnect from current VM. 27 // Disconnect from current VM.
34 notifications.clear(); 28 notifications.deleteAll();
35 _vm.disconnect(); 29 _vm.disconnect();
36 } 30 }
37 if (vm != null) { 31 if (vm != null) {
38 Logger.root.info('Registering new VM callbacks'); 32 Logger.root.info('Registering new VM callbacks');
39 33
40 vm.onConnect.then((_) { 34 vm.onConnect.then((_) {
41 if (vm is WebSocketVM) {
42 targets.add(vm.target);
43 }
44 _removeDisconnectEvents(); 35 _removeDisconnectEvents();
45 }); 36 });
46 37
47 vm.onDisconnect.then((String reason) { 38 vm.onDisconnect.then((String reason) {
48 if (this.vm != vm) { 39 if (this.vm != vm) {
49 // This disconnect event occured *after* a new VM was installed. 40 // This disconnect event occured *after* a new VM was installed.
50 return; 41 return;
51 } 42 }
52 notifications.add( 43 notifications.add(
53 new Notification.fromEvent( 44 new EventNotification.fromServiceEvent(
54 new ServiceEvent.connectionClosed(reason))); 45 new ServiceEvent.connectionClosed(reason)));
55 }); 46 });
56 47
57 vm.listenEventStream(VM.kIsolateStream, _onEvent); 48 vm.listenEventStream(VM.kIsolateStream, _onEvent);
58 vm.listenEventStream(VM.kDebugStream, _onEvent); 49 vm.listenEventStream(VM.kDebugStream, _onEvent);
59 } 50 }
60 _vm = vm; 51 _vm = vm;
61 } 52 }
62 final TargetManager targets; 53 //final TargetManager targets;
63 @reflectable final ObservatoryApplicationElement rootElement; 54 @reflectable final ObservatoryApplicationElement rootElement;
64 55
65 TraceViewElement _traceView = null; 56 TraceViewElement _traceView = null;
66 57
67 @reflectable ServiceObject lastErrorOrException; 58 @reflectable ServiceObject lastErrorOrException;
68 @observable ObservableList<Notification> notifications =
69 new ObservableList<Notification>();
70 59
71 void _initOnce() { 60 void _initOnce() {
72 assert(app == null); 61 assert(app == null);
73 app = this; 62 app = this;
74 _registerPages(); 63 _registerPages();
75 Analytics.initialize(); 64 Analytics.initialize();
76 // Visit the current page. 65 // Visit the current page.
77 locationManager._visit(); 66 locationManager._visit();
78 } 67 }
79 68
80 void removePauseEvents(Isolate isolate) { 69 void removePauseEvents(Isolate isolate) {
81 notifications.removeWhere((notification) { 70 var remove = notifications.list().where((notification) {
82 var event = notification.event; 71 var event = notification.event;
83 return (event != null && 72 return notification is M.EventNotification &&
84 event.isolate == isolate && 73 notification.event is M.IsolateEvent &&
85 event.isPauseEvent); 74 notification.event.isolate == isolate &&
86 }); 75 M.Event.isPauseEvent(notification.event);
76 }).toList(growable: false);
77 remove.forEach((notification) {
78 notifications.delete(notification);
79 });
87 } 80 }
88 81
89 void _onEvent(ServiceEvent event) { 82 void _onEvent(ServiceEvent event) {
90 assert(event.kind != ServiceEvent.kNone); 83 assert(event.kind != ServiceEvent.kNone);
91 84
92 switch(event.kind) { 85 switch(event.kind) {
93 case ServiceEvent.kVMUpdate: 86 case ServiceEvent.kVMUpdate:
94 case ServiceEvent.kIsolateStart: 87 case ServiceEvent.kIsolateStart:
95 case ServiceEvent.kIsolateRunnable: 88 case ServiceEvent.kIsolateRunnable:
96 case ServiceEvent.kIsolateUpdate: 89 case ServiceEvent.kIsolateUpdate:
97 case ServiceEvent.kBreakpointAdded: 90 case ServiceEvent.kBreakpointAdded:
98 case ServiceEvent.kBreakpointResolved: 91 case ServiceEvent.kBreakpointResolved:
99 case ServiceEvent.kBreakpointRemoved: 92 case ServiceEvent.kBreakpointRemoved:
100 case ServiceEvent.kDebuggerSettingsUpdate: 93 case ServiceEvent.kDebuggerSettingsUpdate:
101 // Ignore for now. 94 // Ignore for now.
102 break; 95 break;
103 96
104 case ServiceEvent.kIsolateReload: 97 case ServiceEvent.kIsolateReload:
105 notifications.add(new Notification.fromEvent(event)); 98 notifications.add(new EventNotification.fromServiceEvent(event));
106 break; 99 break;
107 100
108 case ServiceEvent.kIsolateExit: 101 case ServiceEvent.kIsolateExit:
109 case ServiceEvent.kResume: 102 case ServiceEvent.kResume:
110 removePauseEvents(event.isolate); 103 removePauseEvents(event.isolate);
111 break; 104 break;
112 105
113 case ServiceEvent.kPauseStart: 106 case ServiceEvent.kPauseStart:
114 case ServiceEvent.kPauseExit: 107 case ServiceEvent.kPauseExit:
115 case ServiceEvent.kPauseBreakpoint: 108 case ServiceEvent.kPauseBreakpoint:
116 case ServiceEvent.kPauseInterrupted: 109 case ServiceEvent.kPauseInterrupted:
117 case ServiceEvent.kPauseException: 110 case ServiceEvent.kPauseException:
118 removePauseEvents(event.isolate); 111 removePauseEvents(event.isolate);
119 notifications.add(new Notification.fromEvent(event)); 112 notifications.add(new EventNotification.fromServiceEvent(event));
120 break; 113 break;
121 114
122 case ServiceEvent.kInspect: 115 case ServiceEvent.kInspect:
123 notifications.add(new Notification.fromEvent(event)); 116 notifications.add(new EventNotification.fromServiceEvent(event));
124 break; 117 break;
125 118
126 default: 119 default:
127 // Ignore unrecognized events. 120 // Ignore unrecognized events.
128 Logger.root.severe('Unrecognized event: $event'); 121 Logger.root.severe('Unrecognized event: $event');
129 break; 122 break;
130 } 123 }
131 } 124 }
132 125
133 void _registerPages() { 126 void _registerPages() {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 198
206 // Add tracing support. 199 // Add tracing support.
207 _traceView = new Element.tag('trace-view'); 200 _traceView = new Element.tag('trace-view');
208 _traceView.tracer = Tracer.current; 201 _traceView.tracer = Tracer.current;
209 rootElement.children.add(_traceView); 202 rootElement.children.add(_traceView);
210 203
211 // Remember page. 204 // Remember page.
212 currentPage = page; 205 currentPage = page;
213 } 206 }
214 207
215 ObservatoryApplication(this.rootElement) : 208 ObservatoryApplication(this.rootElement) {
216 targets = new TargetManager() {
217 _locationManager = new LocationManager(this); 209 _locationManager = new LocationManager(this);
218 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));
219 _initOnce(); 217 _initOnce();
220 } 218 }
221 219
222 void _removeDisconnectEvents() { 220 void _removeDisconnectEvents() {
223 notifications.removeWhere((notification) { 221 var remove = notifications.list().where((notification) {
224 var event = notification.event; 222 return notification is EventNotification &&
225 return (event != null && 223 notification.event is M.ConnectionClosedEvent;
226 event.kind == ServiceEvent.kConnectionClosed); 224 }).toList(growable: false);
227 }); 225 remove.forEach((notification){
226 notifications.delete(notification);
227 });
228 } 228 }
229 229
230 loadCrashDump(Map crashDump) { 230 loadCrashDump(Map crashDump) {
231 this.vm = new FakeVM(crashDump['result']); 231 _setVM(new FakeVM(crashDump['result']));
232 app.locationManager.go('#/vm'); 232 app.locationManager.go('#/vm');
233 } 233 }
234 234
235 void handleException(e, st) { 235 void handleException(e, st) {
236 if (e is ServerRpcException) { 236 if (e is ServerRpcException) {
237 if (e.code == ServerRpcException.kFeatureDisabled) return; 237 if (e.code == ServerRpcException.kFeatureDisabled) return;
238 if (e.code == ServerRpcException.kIsolateMustBePaused) return; 238 if (e.code == ServerRpcException.kIsolateMustBePaused) return;
239 if (e.code == ServerRpcException.kCannotAddBreakpoint) return; 239 if (e.code == ServerRpcException.kCannotAddBreakpoint) return;
240 Logger.root.fine('Dropping exception: ${e}\n${st}'); 240 Logger.root.fine('Dropping exception: ${e}\n${st}');
241 } 241 }
242 242
243 // TODO(turnidge): Report this failure via analytics. 243 // TODO(turnidge): Report this failure via analytics.
244 Logger.root.warning('Caught exception: ${e}\n${st}'); 244 Logger.root.warning('Caught exception: ${e}\n${st}');
245 notifications.add(new Notification.fromException(e, st)); 245 notifications.add(new ExceptionNotification(e, stacktrace: st));
246 } 246 }
247 247
248 // 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.
249 Map<String,bool> expansions = {}; 249 Map<String,bool> expansions = {};
250 } 250 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/service_common.dart ('k') | runtime/observatory/lib/src/app/location_manager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698