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

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: Polish 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
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
27 Future<StreamSubscription> isolateStreamSubscription;
28 Future<StreamSubscription> debugStreamSubscription;
29
26 set vm(VM vm) { 30 set vm(VM vm) {
27 if (_vm == vm) { 31 if (_vm == vm) {
28 // Do nothing. 32 // Do nothing.
29 return; 33 return;
30 } 34 }
31 if (_vm != null) { 35 if (_vm != null) {
32 // Disconnect from current VM. 36 // Disconnect from current VM.
33 notifications.clear(); 37 notifications.clear();
34 _vm.disconnect(); 38 _vm.disconnect();
35 } 39 }
(...skipping 10 matching lines...) Expand all
46 vm.onDisconnect.then((String reason) { 50 vm.onDisconnect.then((String reason) {
47 if (this.vm != vm) { 51 if (this.vm != vm) {
48 // This disconnect event occured *after* a new VM was installed. 52 // This disconnect event occured *after* a new VM was installed.
49 return; 53 return;
50 } 54 }
51 notifications.add( 55 notifications.add(
52 new Notification.fromEvent( 56 new Notification.fromEvent(
53 new ServiceEvent.connectionClosed(reason))); 57 new ServiceEvent.connectionClosed(reason)));
54 }); 58 });
55 59
56 vm.events.stream.listen(_onEvent); 60 vm.getIsolateEventStream().then((stream) {
61 stream.listen(_onEvent);
62 });
63 vm.getDebugEventStream().then((stream) {
64 stream.listen(_onEvent);
65 });
57 } 66 }
58 _vm = vm; 67 _vm = vm;
59 } 68 }
60 final TargetManager targets; 69 final TargetManager targets;
61 @reflectable final ObservatoryApplicationElement rootElement; 70 @reflectable final ObservatoryApplicationElement rootElement;
62 71
63 TraceViewElement _traceView = null; 72 TraceViewElement _traceView = null;
64 73
65 @reflectable ServiceObject lastErrorOrException; 74 @reflectable ServiceObject lastErrorOrException;
66 @observable ObservableList<Notification> notifications = 75 @observable ObservableList<Notification> notifications =
(...skipping 14 matching lines...) Expand all
81 return (event != null && 90 return (event != null &&
82 event.isolate == isolate && 91 event.isolate == isolate &&
83 event.isPauseEvent); 92 event.isPauseEvent);
84 }); 93 });
85 } 94 }
86 95
87 void _onEvent(ServiceEvent event) { 96 void _onEvent(ServiceEvent event) {
88 switch(event.kind) { 97 switch(event.kind) {
89 case ServiceEvent.kIsolateStart: 98 case ServiceEvent.kIsolateStart:
90 case ServiceEvent.kIsolateUpdate: 99 case ServiceEvent.kIsolateUpdate:
91 case ServiceEvent.kGraph:
92 case ServiceEvent.kBreakpointAdded: 100 case ServiceEvent.kBreakpointAdded:
93 case ServiceEvent.kBreakpointResolved: 101 case ServiceEvent.kBreakpointResolved:
94 case ServiceEvent.kBreakpointRemoved: 102 case ServiceEvent.kBreakpointRemoved:
95 case ServiceEvent.kGC:
96 case ServiceEvent.kDebuggerSettingsUpdate: 103 case ServiceEvent.kDebuggerSettingsUpdate:
97 // Ignore for now. 104 // Ignore for now.
98 break; 105 break;
99 106
100 case ServiceEvent.kIsolateExit: 107 case ServiceEvent.kIsolateExit:
101 case ServiceEvent.kResume: 108 case ServiceEvent.kResume:
102 removePauseEvents(event.isolate); 109 removePauseEvents(event.isolate);
103 break; 110 break;
104 111
105 case ServiceEvent.kPauseStart: 112 case ServiceEvent.kPauseStart:
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 this.vm = new FakeVM(crashDump['result']); 226 this.vm = new FakeVM(crashDump['result']);
220 app.locationManager.go('#/vm'); 227 app.locationManager.go('#/vm');
221 } 228 }
222 229
223 void handleException(e, st) { 230 void handleException(e, st) {
224 // TODO(turnidge): Report this failure via analytics. 231 // TODO(turnidge): Report this failure via analytics.
225 Logger.root.warning('Caught exception: ${e}\n${st}'); 232 Logger.root.warning('Caught exception: ${e}\n${st}');
226 notifications.add(new Notification.fromException(e, st)); 233 notifications.add(new Notification.fromException(e, st));
227 } 234 }
228 } 235 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698