| 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 /// A [Pane] controls the user interface of Observatory. At any given time | 7 /// A [Pane] controls the user interface of Observatory. At any given time |
| 8 /// one pane will be the current pane. Panes are registered at startup. | 8 /// one pane will be the current pane. Panes are registered at startup. |
| 9 /// When the user navigates within the application, each pane is asked if it | 9 /// When the user navigates within the application, each pane is asked if it |
| 10 /// can handle the current location, the first pane to say yes, wins. | 10 /// can handle the current location, the first pane to say yes, wins. |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 assert(canVisit(url)); | 109 assert(canVisit(url)); |
| 110 (element as ServiceObjectViewElement).object = app.lastErrorOrException; | 110 (element as ServiceObjectViewElement).object = app.lastErrorOrException; |
| 111 } | 111 } |
| 112 | 112 |
| 113 bool canVisit(String url) => url.startsWith('error/'); | 113 bool canVisit(String url) => url.startsWith('error/'); |
| 114 } | 114 } |
| 115 | 115 |
| 116 /// The observatory application. Instances of this are created and owned | 116 /// The observatory application. Instances of this are created and owned |
| 117 /// by the observatory_application custom element. | 117 /// by the observatory_application custom element. |
| 118 class ObservatoryApplication extends Observable { | 118 class ObservatoryApplication extends Observable { |
| 119 static ObservatoryApplication app; |
| 119 final _paneRegistry = new List<Pane>(); | 120 final _paneRegistry = new List<Pane>(); |
| 120 ServiceObjectPane _serviceObjectPane; | 121 ServiceObjectPane _serviceObjectPane; |
| 121 Pane _currentPane; | 122 Pane _currentPane; |
| 122 @observable final LocationManager locationManager; | 123 @observable final LocationManager locationManager; |
| 123 @observable final VM vm; | 124 @observable final VM vm; |
| 124 @observable Isolate isolate; | 125 @observable Isolate isolate; |
| 125 @reflectable final ObservatoryApplicationElement rootElement; | 126 @reflectable final ObservatoryApplicationElement rootElement; |
| 126 | 127 |
| 127 @reflectable ServiceObject lastErrorOrException; | 128 @reflectable ServiceObject lastErrorOrException; |
| 128 | 129 |
| 130 @observable ObservableList<ServiceEvent> notifications = |
| 131 new ObservableList<ServiceEvent>(); |
| 132 |
| 129 void _initOnce() { | 133 void _initOnce() { |
| 134 app = this; |
| 135 vm.events.stream.listen(_handleEvent); |
| 130 _registerPanes(); | 136 _registerPanes(); |
| 131 vm.errors.stream.listen(_onError); | 137 vm.errors.stream.listen(_onError); |
| 132 vm.exceptions.stream.listen(_onException); | 138 vm.exceptions.stream.listen(_onException); |
| 133 location = locationManager; | 139 location = locationManager; |
| 134 locationManager._init(this); | 140 locationManager._init(this); |
| 135 } | 141 } |
| 136 | 142 |
| 143 void removePauseEvents(Isolate isolate) { |
| 144 bool isPauseEvent(var event) { |
| 145 return (event.eventType == 'IsolateInterrupted' || |
| 146 event.eventType == 'BreakpointReached' || |
| 147 event.eventType == 'ExceptionThrown'); |
| 148 } |
| 149 |
| 150 notifications.removeWhere((oldEvent) { |
| 151 return (oldEvent.isolate == isolate && |
| 152 isPauseEvent(oldEvent)); |
| 153 }); |
| 154 } |
| 155 |
| 156 void _handleEvent(ServiceEvent event) { |
| 157 switch(event.eventType) { |
| 158 case 'IsolateCreated': |
| 159 // vm.reload(); |
| 160 break; |
| 161 |
| 162 case 'IsolateShutdown': |
| 163 // TODO(turnidge): Should we show the user isolate shutdown events? |
| 164 // What if there are hundreds of them? Coalesce multiple |
| 165 // shutdown events into one notification? |
| 166 removePauseEvents(event.isolate); |
| 167 // vm.reload(); |
| 168 break; |
| 169 |
| 170 case 'BreakpointResolved': |
| 171 // Do nothing. |
| 172 break; |
| 173 |
| 174 case 'BreakpointReached': |
| 175 case 'IsolateInterrupted': |
| 176 case 'ExceptionThrown': |
| 177 removePauseEvents(event.isolate); |
| 178 notifications.add(event); |
| 179 break; |
| 180 |
| 181 default: |
| 182 // Ignore unrecognized events. |
| 183 Logger.root.severe('Unrecognized event type: ${event.eventType}'); |
| 184 break; |
| 185 } |
| 186 } |
| 187 |
| 137 void _registerPanes() { | 188 void _registerPanes() { |
| 138 if (_serviceObjectPane != null) { | 189 if (_serviceObjectPane != null) { |
| 139 // Already done. | 190 // Already done. |
| 140 return; | 191 return; |
| 141 } | 192 } |
| 142 // Register ClassTreePane. | 193 // Register ClassTreePane. |
| 143 _paneRegistry.add(new ClassTreePane(this)); | 194 _paneRegistry.add(new ClassTreePane(this)); |
| 144 _paneRegistry.add(new ErrorViewPane(this)); | 195 _paneRegistry.add(new ErrorViewPane(this)); |
| 145 // Note that ServiceObjectPane must be the last entry in the list as it is | 196 // Note that ServiceObjectPane must be the last entry in the list as it is |
| 146 // the catch all. | 197 // the catch all. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 } | 243 } |
| 193 | 244 |
| 194 ObservatoryApplication.devtools(this.rootElement) : | 245 ObservatoryApplication.devtools(this.rootElement) : |
| 195 locationManager = new HashLocationManager(), | 246 locationManager = new HashLocationManager(), |
| 196 vm = new DartiumVM() { | 247 vm = new DartiumVM() { |
| 197 _initOnce(); | 248 _initOnce(); |
| 198 } | 249 } |
| 199 | 250 |
| 200 ObservatoryApplication(this.rootElement) : | 251 ObservatoryApplication(this.rootElement) : |
| 201 locationManager = new HashLocationManager(), | 252 locationManager = new HashLocationManager(), |
| 202 vm = new HttpVM() { | 253 vm = new WebSocketVM() { |
| 203 _initOnce(); | 254 _initOnce(); |
| 204 } | 255 } |
| 205 } | 256 } |
| 206 | 257 |
| 207 LocationManager location; | 258 LocationManager location; |
| OLD | NEW |