OLD | NEW |
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; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 // TODO(cbernaschina) smart connection of streams in the events object. | 48 // TODO(cbernaschina) smart connection of streams in the events object. |
49 vm.listenEventStream(VM.kVMStream, _onEvent); | 49 vm.listenEventStream(VM.kVMStream, _onEvent); |
50 vm.listenEventStream(VM.kIsolateStream, _onEvent); | 50 vm.listenEventStream(VM.kIsolateStream, _onEvent); |
51 vm.listenEventStream(VM.kDebugStream, _onEvent); | 51 vm.listenEventStream(VM.kDebugStream, _onEvent); |
52 } | 52 } |
53 _vm = vm; | 53 _vm = vm; |
54 } | 54 } |
55 | 55 |
56 StreamSubscription _gcSubscription; | 56 StreamSubscription _gcSubscription; |
| 57 StreamSubscription _loggingSubscription; |
57 | 58 |
58 Future startGCEventListener() async { | 59 Future startGCEventListener() async { |
59 if (_gcSubscription != null || _vm == null) { | 60 if (_gcSubscription != null || _vm == null) { |
60 return; | 61 return; |
61 } | 62 } |
62 _gcSubscription = await _vm.listenEventStream(VM.kGCStream, _onEvent); | 63 _gcSubscription = await _vm.listenEventStream(VM.kGCStream, _onEvent); |
63 } | 64 } |
64 | 65 |
| 66 Future startLoggingEventListener() async { |
| 67 if (_loggingSubscription != null || _vm == null) { |
| 68 return; |
| 69 } |
| 70 _loggingSubscription = |
| 71 await _vm.listenEventStream(Isolate.kLoggingStream, _onEvent); |
| 72 } |
| 73 |
65 Future stopGCEventListener() async { | 74 Future stopGCEventListener() async { |
66 if (_gcSubscription == null) { | 75 if (_gcSubscription == null) { |
67 return; | 76 return; |
68 } | 77 } |
69 _gcSubscription.cancel(); | 78 _gcSubscription.cancel(); |
70 _gcSubscription = null; | 79 _gcSubscription = null; |
71 } | 80 } |
72 | 81 |
| 82 Future stopLoggingEventListener() async { |
| 83 if (_loggingSubscription == null) { |
| 84 return; |
| 85 } |
| 86 _loggingSubscription.cancel(); |
| 87 _loggingSubscription = null; |
| 88 } |
| 89 |
73 | 90 |
74 @reflectable final ObservatoryApplicationElement rootElement; | 91 @reflectable final ObservatoryApplicationElement rootElement; |
75 | 92 |
76 @reflectable ServiceObject lastErrorOrException; | 93 @reflectable ServiceObject lastErrorOrException; |
77 | 94 |
78 void _initOnce() { | 95 void _initOnce() { |
79 assert(app == null); | 96 assert(app == null); |
80 app = this; | 97 app = this; |
81 _registerPages(); | 98 _registerPages(); |
82 Analytics.initialize(); | 99 Analytics.initialize(); |
83 // Visit the current page. | 100 // Visit the current page. |
84 locationManager._visit(); | 101 locationManager._visit(); |
85 } | 102 } |
86 | 103 |
87 void _deletePauseEvents(e) { | 104 void _deletePauseEvents(e) { |
88 notifications.deletePauseEvents(isolate: e.isolate); | 105 notifications.deletePauseEvents(isolate: e.isolate); |
89 } | 106 } |
90 void _addNotification(M.Event e) { | 107 void _addNotification(M.Event e) { |
91 notifications.add(new EventNotification(e)); | 108 notifications.add(new EventNotification(e)); |
92 } | 109 } |
93 | 110 |
94 void _onEvent(ServiceEvent event) { | 111 void _onEvent(ServiceEvent event) { |
95 assert(event.kind != ServiceEvent.kNone); | 112 assert(event.kind != ServiceEvent.kNone); |
96 | |
97 M.Event e = createEventFromServiceEvent(event); | 113 M.Event e = createEventFromServiceEvent(event); |
98 if (e != null) { | 114 if (e != null) { |
99 events.add(e); | 115 events.add(e); |
100 } | 116 } |
101 } | 117 } |
102 | 118 |
103 void _registerPages() { | 119 void _registerPages() { |
104 _pageRegistry.add(new VMPage(this)); | 120 _pageRegistry.add(new VMPage(this)); |
105 _pageRegistry.add(new FlagsPage(this)); | 121 _pageRegistry.add(new FlagsPage(this)); |
106 _pageRegistry.add(new InspectPage(this)); | 122 _pageRegistry.add(new InspectPage(this)); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 } | 233 } |
218 | 234 |
219 // TODO(turnidge): Report this failure via analytics. | 235 // TODO(turnidge): Report this failure via analytics. |
220 Logger.root.warning('Caught exception: ${e}\n${st}'); | 236 Logger.root.warning('Caught exception: ${e}\n${st}'); |
221 notifications.add(new ExceptionNotification(e, stacktrace: st)); | 237 notifications.add(new ExceptionNotification(e, stacktrace: st)); |
222 } | 238 } |
223 | 239 |
224 // This map keeps track of which curly-blocks have been expanded by the user. | 240 // This map keeps track of which curly-blocks have been expanded by the user. |
225 Map<String,bool> expansions = {}; | 241 Map<String,bool> expansions = {}; |
226 } | 242 } |
OLD | NEW |