Chromium Code Reviews| 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 'IsolateResumed': | |
| 175 _removePauseEvents(event.isolate); | |
| 176 break; | |
| 177 | |
| 178 case 'BreakpointReached': | |
| 179 case 'IsolateInterrupted': | |
| 180 case 'ExceptionThrown': | |
| 181 _removePauseEvents(event.isolate); | |
| 182 notifications.add(event); | |
| 183 break; | |
| 184 | |
| 185 default: | |
| 186 // Ignore unrecognized events. | |
| 187 Logger.root.severe('Unrecognized event type: ${event.eventType}'); | |
| 188 break; | |
| 189 } | |
| 190 } | |
| 191 | |
| 137 void _registerPanes() { | 192 void _registerPanes() { |
| 138 if (_serviceObjectPane != null) { | 193 if (_serviceObjectPane != null) { |
| 139 // Already done. | 194 // Already done. |
| 140 return; | 195 return; |
| 141 } | 196 } |
| 142 // Register ClassTreePane. | 197 // Register ClassTreePane. |
| 143 _paneRegistry.add(new ClassTreePane(this)); | 198 _paneRegistry.add(new ClassTreePane(this)); |
| 144 _paneRegistry.add(new ErrorViewPane(this)); | 199 _paneRegistry.add(new ErrorViewPane(this)); |
| 145 // Note that ServiceObjectPane must be the last entry in the list as it is | 200 // Note that ServiceObjectPane must be the last entry in the list as it is |
| 146 // the catch all. | 201 // the catch all. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 } | 247 } |
| 193 | 248 |
| 194 ObservatoryApplication.devtools(this.rootElement) : | 249 ObservatoryApplication.devtools(this.rootElement) : |
| 195 locationManager = new HashLocationManager(), | 250 locationManager = new HashLocationManager(), |
| 196 vm = new DartiumVM() { | 251 vm = new DartiumVM() { |
| 197 _initOnce(); | 252 _initOnce(); |
| 198 } | 253 } |
| 199 | 254 |
| 200 ObservatoryApplication(this.rootElement) : | 255 ObservatoryApplication(this.rootElement) : |
| 201 locationManager = new HashLocationManager(), | 256 locationManager = new HashLocationManager(), |
| 202 vm = new HttpVM() { | 257 vm = new WebSocketVM() { |
|
turnidge
2014/06/26 21:27:46
I recall that this broke something last time I cha
Cutch
2014/06/27 16:03:49
This breaks clicking the Observatory link to recon
turnidge
2014/06/27 18:15:06
Ok, good.
| |
| 203 _initOnce(); | 258 _initOnce(); |
| 204 } | 259 } |
| 205 } | 260 } |
| 206 | 261 |
| 207 LocationManager location; | 262 LocationManager location; |
| OLD | NEW |