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

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

Issue 1217823009: Make VM event streams look like real dart streams. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge with master Created 5 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
« no previous file with comments | « runtime/observatory/lib/service_common.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 class Notification { 7 class Notification {
8 Notification.fromEvent(this.event); 8 Notification.fromEvent(this.event);
9 Notification.fromException(this.exception, this.stacktrace); 9 Notification.fromException(this.exception, this.stacktrace);
10 10
11 ServiceEvent event; 11 ServiceEvent event;
12 var exception; 12 var exception;
13 var stacktrace; 13 var stacktrace;
14 } 14 }
15 15
16 /// The observatory application. Instances of this are created and owned 16 /// The observatory application. Instances of this are created and owned
17 /// by the observatory_application custom element. 17 /// by the observatory_application custom element.
18 class ObservatoryApplication extends Observable { 18 class ObservatoryApplication extends Observable {
19 static ObservatoryApplication app; 19 static ObservatoryApplication app;
20 final _pageRegistry = new List<Page>(); 20 final _pageRegistry = new List<Page>();
21 LocationManager _locationManager; 21 LocationManager _locationManager;
22 LocationManager get locationManager => _locationManager; 22 LocationManager get locationManager => _locationManager;
23 @observable Page currentPage; 23 @observable Page currentPage;
24 VM _vm; 24 VM _vm;
25 VM get vm => _vm; 25 VM get vm => _vm;
26
26 set vm(VM vm) { 27 set vm(VM vm) {
27 if (_vm == vm) { 28 if (_vm == vm) {
28 // Do nothing. 29 // Do nothing.
29 return; 30 return;
30 } 31 }
31 if (_vm != null) { 32 if (_vm != null) {
32 // Disconnect from current VM. 33 // Disconnect from current VM.
33 notifications.clear(); 34 notifications.clear();
34 _vm.disconnect(); 35 _vm.disconnect();
35 } 36 }
(...skipping 10 matching lines...) Expand all
46 vm.onDisconnect.then((String reason) { 47 vm.onDisconnect.then((String reason) {
47 if (this.vm != vm) { 48 if (this.vm != vm) {
48 // This disconnect event occured *after* a new VM was installed. 49 // This disconnect event occured *after* a new VM was installed.
49 return; 50 return;
50 } 51 }
51 notifications.add( 52 notifications.add(
52 new Notification.fromEvent( 53 new Notification.fromEvent(
53 new ServiceEvent.connectionClosed(reason))); 54 new ServiceEvent.connectionClosed(reason)));
54 }); 55 });
55 56
56 vm.events.stream.listen(_onEvent); 57 vm.listenEventStream(VM.kIsolateStream, _onEvent);
58 vm.listenEventStream(VM.kDebugStream, _onEvent);
57 } 59 }
58 _vm = vm; 60 _vm = vm;
59 } 61 }
60 final TargetManager targets; 62 final TargetManager targets;
61 @reflectable final ObservatoryApplicationElement rootElement; 63 @reflectable final ObservatoryApplicationElement rootElement;
62 64
63 TraceViewElement _traceView = null; 65 TraceViewElement _traceView = null;
64 66
65 @reflectable ServiceObject lastErrorOrException; 67 @reflectable ServiceObject lastErrorOrException;
66 @observable ObservableList<Notification> notifications = 68 @observable ObservableList<Notification> notifications =
(...skipping 14 matching lines...) Expand all
81 return (event != null && 83 return (event != null &&
82 event.isolate == isolate && 84 event.isolate == isolate &&
83 event.isPauseEvent); 85 event.isPauseEvent);
84 }); 86 });
85 } 87 }
86 88
87 void _onEvent(ServiceEvent event) { 89 void _onEvent(ServiceEvent event) {
88 switch(event.kind) { 90 switch(event.kind) {
89 case ServiceEvent.kIsolateStart: 91 case ServiceEvent.kIsolateStart:
90 case ServiceEvent.kIsolateUpdate: 92 case ServiceEvent.kIsolateUpdate:
91 case ServiceEvent.kGraph:
92 case ServiceEvent.kBreakpointAdded: 93 case ServiceEvent.kBreakpointAdded:
93 case ServiceEvent.kBreakpointResolved: 94 case ServiceEvent.kBreakpointResolved:
94 case ServiceEvent.kBreakpointRemoved: 95 case ServiceEvent.kBreakpointRemoved:
95 case ServiceEvent.kGC:
96 case ServiceEvent.kDebuggerSettingsUpdate: 96 case ServiceEvent.kDebuggerSettingsUpdate:
97 // Ignore for now. 97 // Ignore for now.
98 break; 98 break;
99 99
100 case ServiceEvent.kIsolateExit: 100 case ServiceEvent.kIsolateExit:
101 case ServiceEvent.kResume: 101 case ServiceEvent.kResume:
102 removePauseEvents(event.isolate); 102 removePauseEvents(event.isolate);
103 break; 103 break;
104 104
105 case ServiceEvent.kPauseStart: 105 case ServiceEvent.kPauseStart:
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 this.vm = new FakeVM(crashDump['result']); 219 this.vm = new FakeVM(crashDump['result']);
220 app.locationManager.go('#/vm'); 220 app.locationManager.go('#/vm');
221 } 221 }
222 222
223 void handleException(e, st) { 223 void handleException(e, st) {
224 // TODO(turnidge): Report this failure via analytics. 224 // TODO(turnidge): Report this failure via analytics.
225 Logger.root.warning('Caught exception: ${e}\n${st}'); 225 Logger.root.warning('Caught exception: ${e}\n${st}');
226 notifications.add(new Notification.fromException(e, st)); 226 notifications.add(new Notification.fromException(e, st));
227 } 227 }
228 } 228 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/service_common.dart ('k') | runtime/observatory/lib/src/app/page.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698