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

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

Issue 2211603002: Centralized event streams (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged with master 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/service_common.dart ('k') | runtime/observatory/lib/src/app/event.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 TargetRepository targets = new TargetRepository();
13 final EventRepository events = new EventRepository();
13 final NotificationRepository notifications = new NotificationRepository(); 14 final NotificationRepository notifications = new NotificationRepository();
14 final _pageRegistry = new List<Page>(); 15 final _pageRegistry = new List<Page>();
15 LocationManager _locationManager; 16 LocationManager _locationManager;
16 LocationManager get locationManager => _locationManager; 17 LocationManager get locationManager => _locationManager;
17 @observable Page currentPage; 18 @observable Page currentPage;
18 VM _vm; 19 VM _vm;
19 VM get vm => _vm; 20 VM get vm => _vm;
20 21
21 _setVM(VM vm) { 22 _setVM(VM vm) {
22 if (_vm == vm) { 23 if (_vm == vm) {
(...skipping 10 matching lines...) Expand all
33 34
34 vm.onConnect.then((_) { 35 vm.onConnect.then((_) {
35 notifications.deleteDisconnectEvents(); 36 notifications.deleteDisconnectEvents();
36 }); 37 });
37 38
38 vm.onDisconnect.then((String reason) { 39 vm.onDisconnect.then((String reason) {
39 if (this.vm != vm) { 40 if (this.vm != vm) {
40 // This disconnect event occured *after* a new VM was installed. 41 // This disconnect event occured *after* a new VM was installed.
41 return; 42 return;
42 } 43 }
43 notifications.add( 44 events.add(new ConnectionClosedEvent(new DateTime.now(), reason));
44 new EventNotification.fromServiceEvent(
45 new ServiceEvent.connectionClosed(reason)));
46 }); 45 });
47 46
47 // TODO(cbernaschina) smart connection of streams in the events object.
48 vm.listenEventStream(VM.kVMStream, _onEvent);
48 vm.listenEventStream(VM.kIsolateStream, _onEvent); 49 vm.listenEventStream(VM.kIsolateStream, _onEvent);
49 vm.listenEventStream(VM.kDebugStream, _onEvent); 50 vm.listenEventStream(VM.kDebugStream, _onEvent);
50 } 51 }
51 _vm = vm; 52 _vm = vm;
52 } 53 }
53 @reflectable final ObservatoryApplicationElement rootElement; 54 @reflectable final ObservatoryApplicationElement rootElement;
54 55
55 TraceViewElement _traceView = null; 56 TraceViewElement _traceView = null;
56 57
57 @reflectable ServiceObject lastErrorOrException; 58 @reflectable ServiceObject lastErrorOrException;
58 59
59 void _initOnce() { 60 void _initOnce() {
60 assert(app == null); 61 assert(app == null);
61 app = this; 62 app = this;
62 _registerPages(); 63 _registerPages();
63 Analytics.initialize(); 64 Analytics.initialize();
64 // Visit the current page. 65 // Visit the current page.
65 locationManager._visit(); 66 locationManager._visit();
66 } 67 }
67 68
69 void _deletePauseEvents(e) {
70 notifications.deletePauseEvents(isolate: e.isolate);
71 }
72 void _addNotification(M.Event e) {
73 notifications.add(new EventNotification(e));
74 }
75
68 void _onEvent(ServiceEvent event) { 76 void _onEvent(ServiceEvent event) {
69 assert(event.kind != ServiceEvent.kNone); 77 assert(event.kind != ServiceEvent.kNone);
70 78
79 M.Event e;
80
71 switch(event.kind) { 81 switch(event.kind) {
72 case ServiceEvent.kVMUpdate: 82 case ServiceEvent.kVMUpdate:
83 e = new VMUpdateEvent(event.timestamp, event.vm);
84 break;
73 case ServiceEvent.kIsolateStart: 85 case ServiceEvent.kIsolateStart:
86 e = new IsolateStartEvent(event.timestamp, event.isolate);
87 break;
74 case ServiceEvent.kIsolateRunnable: 88 case ServiceEvent.kIsolateRunnable:
89 e = new IsolateRunnableEvent(event.timestamp, event.isolate);
90 break;
75 case ServiceEvent.kIsolateUpdate: 91 case ServiceEvent.kIsolateUpdate:
92 e = new IsolateUpdateEvent(event.timestamp, event.isolate);
93 break;
94 case ServiceEvent.kIsolateReload:
95 e = new IsolateReloadEvent(event.timestamp, event.isolate, event.error);
96 break;
97 case ServiceEvent.kIsolateExit:
98 e = new IsolateExitEvent(event.timestamp, event.isolate);
99 break;
76 case ServiceEvent.kBreakpointAdded: 100 case ServiceEvent.kBreakpointAdded:
101 e = new BreakpointAddedEvent(event.timestamp, event.isolate,
102 event.breakpoint);
103 break;
77 case ServiceEvent.kBreakpointResolved: 104 case ServiceEvent.kBreakpointResolved:
105 e = new BreakpointResolvedEvent(event.timestamp, event.isolate,
106 event.breakpoint);
107 break;
78 case ServiceEvent.kBreakpointRemoved: 108 case ServiceEvent.kBreakpointRemoved:
109 e = new BreakpointRemovedEvent(event.timestamp, event.isolate,
110 event.breakpoint);
111 break;
79 case ServiceEvent.kDebuggerSettingsUpdate: 112 case ServiceEvent.kDebuggerSettingsUpdate:
80 // Ignore for now. 113 e = new DebuggerSettingsUpdateEvent(event.timestamp, event.isolate);
81 break; 114 break;
82 115 case ServiceEvent.kResume:
83 case ServiceEvent.kIsolateReload: 116 e = new ResumeEvent(event.timestamp, event.isolate, event.topFrame);
84 notifications.add(new EventNotification.fromServiceEvent(event));
85 break; 117 break;
86 118 case ServiceEvent.kPauseStart:
87 case ServiceEvent.kIsolateExit: 119 e = new PauseStartEvent(event.timestamp, event.isolate);
88 case ServiceEvent.kResume:
89 notifications.deletePauseEvents(isolate: event.isolate);
90 break; 120 break;
91
92 case ServiceEvent.kPauseStart:
93 case ServiceEvent.kPauseExit: 121 case ServiceEvent.kPauseExit:
122 e = new PauseExitEvent(event.timestamp, event.isolate);
123 break;
94 case ServiceEvent.kPauseBreakpoint: 124 case ServiceEvent.kPauseBreakpoint:
125 e = new PauseBreakpointEvent(event.timestamp, event.isolate,
126 event.pauseBreakpoints, event.topFrame, event.atAsyncSuspension,
127 event.breakpoint);
128 break;
95 case ServiceEvent.kPauseInterrupted: 129 case ServiceEvent.kPauseInterrupted:
130 e = new PauseInterruptedEvent(event.timestamp, event.isolate,
131 event.topFrame, event.atAsyncSuspension);
132 break;
96 case ServiceEvent.kPauseException: 133 case ServiceEvent.kPauseException:
97 notifications.deletePauseEvents(isolate: event.isolate); 134 e = new PauseExceptionEvent(event.timestamp, event.isolate,
98 notifications.add(new EventNotification.fromServiceEvent(event)); 135 event.topFrame, event.exception);
99 break; 136 break;
100
101 case ServiceEvent.kInspect: 137 case ServiceEvent.kInspect:
102 notifications.add(new EventNotification.fromServiceEvent(event)); 138 e = new InspectEvent(event.timestamp, event.isolate,
139 event.inspectee);
103 break; 140 break;
104
105 default: 141 default:
106 // Ignore unrecognized events. 142 // Ignore unrecognized events.
107 Logger.root.severe('Unrecognized event: $event'); 143 Logger.root.severe('Unrecognized event: $event');
108 break; 144 return;
109 } 145 }
146 events.add(e);
110 } 147 }
111 148
112 void _registerPages() { 149 void _registerPages() {
113 _pageRegistry.add(new VMPage(this)); 150 _pageRegistry.add(new VMPage(this));
114 _pageRegistry.add(new FlagsPage(this)); 151 _pageRegistry.add(new FlagsPage(this));
115 _pageRegistry.add(new InspectPage(this)); 152 _pageRegistry.add(new InspectPage(this));
116 _pageRegistry.add(new ClassTreePage(this)); 153 _pageRegistry.add(new ClassTreePage(this));
117 _pageRegistry.add(new DebuggerPage(this)); 154 _pageRegistry.add(new DebuggerPage(this));
118 _pageRegistry.add(new ObjectStorePage(this)); 155 _pageRegistry.add(new ObjectStorePage(this));
119 _pageRegistry.add(new CpuProfilerPage(this)); 156 _pageRegistry.add(new CpuProfilerPage(this));
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 ObservatoryApplication(this.rootElement) { 231 ObservatoryApplication(this.rootElement) {
195 _locationManager = new LocationManager(this); 232 _locationManager = new LocationManager(this);
196 targets.onChange.listen((e) { 233 targets.onChange.listen((e) {
197 if (targets.current == null) return _setVM(null); 234 if (targets.current == null) return _setVM(null);
198 if ((_vm as WebSocketVM)?.target != targets.current) { 235 if ((_vm as WebSocketVM)?.target != targets.current) {
199 _setVM(new WebSocketVM(targets.current)); 236 _setVM(new WebSocketVM(targets.current));
200 } 237 }
201 }); 238 });
202 _setVM(new WebSocketVM(targets.current)); 239 _setVM(new WebSocketVM(targets.current));
203 _initOnce(); 240 _initOnce();
241
242 // delete pause events.
243 events.onIsolateExit.listen(_deletePauseEvents);
244 events.onResume.listen(_deletePauseEvents);
245 events.onPauseStart.listen(_deletePauseEvents);
246 events.onPauseExit.listen(_deletePauseEvents);
247 events.onPauseBreakpoint.listen(_deletePauseEvents);
248 events.onPauseInterrupted.listen(_deletePauseEvents);
249 events.onPauseException.listen(_deletePauseEvents);
250
251 // show notification for an event.
252 events.onIsolateReload.listen(_addNotification);
253 events.onPauseExit.listen(_addNotification);
254 events.onPauseBreakpoint.listen(_addNotification);
255 events.onPauseInterrupted.listen(_addNotification);
256 events.onPauseException.listen(_addNotification);
257 events.onInspect.listen(_addNotification);
204 } 258 }
205 259
206 loadCrashDump(Map crashDump) { 260 loadCrashDump(Map crashDump) {
207 _setVM(new FakeVM(crashDump['result'])); 261 _setVM(new FakeVM(crashDump['result']));
208 app.locationManager.go('#/vm'); 262 app.locationManager.go('#/vm');
209 } 263 }
210 264
211 void handleException(e, st) { 265 void handleException(e, st) {
212 if (e is ServerRpcException) { 266 if (e is ServerRpcException) {
213 if (e.code == ServerRpcException.kFeatureDisabled) return; 267 if (e.code == ServerRpcException.kFeatureDisabled) return;
214 if (e.code == ServerRpcException.kIsolateMustBePaused) return; 268 if (e.code == ServerRpcException.kIsolateMustBePaused) return;
215 if (e.code == ServerRpcException.kCannotAddBreakpoint) return; 269 if (e.code == ServerRpcException.kCannotAddBreakpoint) return;
216 Logger.root.fine('Dropping exception: ${e}\n${st}'); 270 Logger.root.fine('Dropping exception: ${e}\n${st}');
217 } 271 }
218 272
219 // TODO(turnidge): Report this failure via analytics. 273 // TODO(turnidge): Report this failure via analytics.
220 Logger.root.warning('Caught exception: ${e}\n${st}'); 274 Logger.root.warning('Caught exception: ${e}\n${st}');
221 notifications.add(new ExceptionNotification(e, stacktrace: st)); 275 notifications.add(new ExceptionNotification(e, stacktrace: st));
222 } 276 }
223 277
224 // This map keeps track of which curly-blocks have been expanded by the user. 278 // This map keeps track of which curly-blocks have been expanded by the user.
225 Map<String,bool> expansions = {}; 279 Map<String,bool> expansions = {};
226 } 280 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/service_common.dart ('k') | runtime/observatory/lib/src/app/event.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698