| 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; |
| 11 final _paneRegistry = new List<Pane>(); | 11 final _pageRegistry = new List<Page>(); |
| 12 Pane _currentPane; | 12 @observable Page currentPage; |
| 13 @observable final LocationManager locationManager; | 13 @observable final LocationManager locationManager; |
| 14 VM _vm; | 14 VM _vm; |
| 15 VM get vm => _vm; | 15 VM get vm => _vm; |
| 16 set vm(VM vm) { | 16 set vm(VM vm) { |
| 17 if (_vm == vm) { | 17 if (_vm == vm) { |
| 18 // Do nothing. | 18 // Do nothing. |
| 19 return; | 19 return; |
| 20 } | 20 } |
| 21 if (_vm != null) { | 21 if (_vm != null) { |
| 22 // Disconnect from current VM. | 22 // Disconnect from current VM. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 35 @observable Isolate isolate; | 35 @observable Isolate isolate; |
| 36 @reflectable final ObservatoryApplicationElement rootElement; | 36 @reflectable final ObservatoryApplicationElement rootElement; |
| 37 | 37 |
| 38 @reflectable ServiceObject lastErrorOrException; | 38 @reflectable ServiceObject lastErrorOrException; |
| 39 @observable ObservableList<ServiceEvent> notifications = | 39 @observable ObservableList<ServiceEvent> notifications = |
| 40 new ObservableList<ServiceEvent>(); | 40 new ObservableList<ServiceEvent>(); |
| 41 | 41 |
| 42 void _initOnce(bool chromium) { | 42 void _initOnce(bool chromium) { |
| 43 assert(app == null); | 43 assert(app == null); |
| 44 app = this; | 44 app = this; |
| 45 _registerPanes(); | 45 _registerPages(); |
| 46 locationManager._init(this); | 46 locationManager._init(this); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void removePauseEvents(Isolate isolate) { | 49 void removePauseEvents(Isolate isolate) { |
| 50 bool isPauseEvent(var event) { | 50 bool isPauseEvent(var event) { |
| 51 return (event.eventType == 'IsolateInterrupted' || | 51 return (event.eventType == 'IsolateInterrupted' || |
| 52 event.eventType == 'BreakpointReached' || | 52 event.eventType == 'BreakpointReached' || |
| 53 event.eventType == 'ExceptionThrown'); | 53 event.eventType == 'ExceptionThrown'); |
| 54 } | 54 } |
| 55 | 55 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 84 notifications.add(event); | 84 notifications.add(event); |
| 85 break; | 85 break; |
| 86 | 86 |
| 87 default: | 87 default: |
| 88 // Ignore unrecognized events. | 88 // Ignore unrecognized events. |
| 89 Logger.root.severe('Unrecognized event type: ${event.eventType}'); | 89 Logger.root.severe('Unrecognized event type: ${event.eventType}'); |
| 90 break; | 90 break; |
| 91 } | 91 } |
| 92 } | 92 } |
| 93 | 93 |
| 94 void _registerPanes() { | 94 void _registerPages() { |
| 95 // Register ClassTreePane. | 95 // Register ClassTreePage. |
| 96 _paneRegistry.add(new ClassTreePane(this)); | 96 _pageRegistry.add(new ClassTreePage(this)); |
| 97 _paneRegistry.add(new VMConnectPane(this)); | 97 _pageRegistry.add(new VMConnectPage(this)); |
| 98 _paneRegistry.add(new ErrorViewPane(this)); | 98 _pageRegistry.add(new ErrorViewPage(this)); |
| 99 // Note that ServiceObjectPane must be the last entry in the list as it is | 99 // Note that ServiceObjectPage must be the last entry in the list as it is |
| 100 // the catch all. | 100 // the catch all. |
| 101 _paneRegistry.add(new ServiceObjectPane(this)); | 101 _pageRegistry.add(new ServiceObjectPage(this)); |
| 102 } | 102 } |
| 103 | 103 |
| 104 void _onError(ServiceError error) { | 104 void _onError(ServiceError error) { |
| 105 lastErrorOrException = error; | 105 lastErrorOrException = error; |
| 106 _visit('error/', null); | 106 _visit('error/', null); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void _onException(ServiceException exception) { | 109 void _onException(ServiceException exception) { |
| 110 lastErrorOrException = exception; | 110 lastErrorOrException = exception; |
| 111 if (exception.kind == 'NetworkException') { | 111 if (exception.kind == 'NetworkException') { |
| 112 // Got a network exception, visit the vm-connect pane. | 112 // Got a network exception, visit the vm-connect page. |
| 113 locationManager.go(locationManager.makeLink('/vm-connect/')); | 113 locationManager.go(locationManager.makeLink('/vm-connect/')); |
| 114 } else { | 114 } else { |
| 115 _visit('error/', null); | 115 _visit('error/', null); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 void _visit(String url, String args) { | 119 void _visit(String url, String args) { |
| 120 // TODO(johnmccutchan): Pass [args] to pane. | 120 var argsMap; |
| 121 for (var i = 0; i < _paneRegistry.length; i++) { | 121 if (args == null) { |
| 122 var pane = _paneRegistry[i]; | 122 argsMap = {}; |
| 123 if (pane.canVisit(url)) { | 123 } else { |
| 124 _installPane(pane); | 124 argsMap = Uri.splitQueryString(args); |
| 125 pane.visit(url); | 125 } |
| 126 for (var i = 0; i < _pageRegistry.length; i++) { |
| 127 var page = _pageRegistry[i]; |
| 128 if (page.canVisit(url)) { |
| 129 _installPage(page); |
| 130 page.visit(url, argsMap); |
| 126 return; | 131 return; |
| 127 } | 132 } |
| 128 } | 133 } |
| 129 throw new FallThroughError(); | 134 throw new FallThroughError(); |
| 130 } | 135 } |
| 131 | 136 |
| 132 /// Set the Observatory application pane. | 137 /// Set the Observatory application page. |
| 133 void _installPane(Pane pane) { | 138 void _installPage(Page page) { |
| 134 assert(pane != null); | 139 assert(page != null); |
| 135 if (_currentPane == pane) { | 140 if (currentPage == page) { |
| 136 // Already isntalled. | 141 // Already isntalled. |
| 137 return; | 142 return; |
| 138 } | 143 } |
| 139 if (_currentPane != null) { | 144 if (currentPage != null) { |
| 140 Logger.root.info('Uninstalling pane: $_currentPane'); | 145 Logger.root.info('Uninstalling page: $currentPage'); |
| 141 _currentPane.onUninstall(); | 146 currentPage.onUninstall(); |
| 142 // Clear children. | 147 // Clear children. |
| 143 rootElement.children.clear(); | 148 rootElement.children.clear(); |
| 144 } | 149 } |
| 145 Logger.root.info('Installing pane: $pane'); | 150 Logger.root.info('Installing page: $page'); |
| 146 try { | 151 try { |
| 147 pane.onInstall(); | 152 page.onInstall(); |
| 148 } catch (e) { | 153 } catch (e) { |
| 149 Logger.root.severe('Failed to install pane: $e'); | 154 Logger.root.severe('Failed to install page: $e'); |
| 150 } | 155 } |
| 151 // Add new pane. | 156 // Add new page. |
| 152 rootElement.children.add(pane.element); | 157 rootElement.children.add(page.element); |
| 153 // Remember pane. | 158 // Remember page. |
| 154 _currentPane = pane; | 159 currentPage = page; |
| 155 } | 160 } |
| 156 | 161 |
| 157 ObservatoryApplication.devtools(this.rootElement) : | 162 ObservatoryApplication.devtools(this.rootElement) : |
| 158 locationManager = new HashLocationManager(), | 163 locationManager = new HashLocationManager(), |
| 159 targets = null { | 164 targets = null { |
| 160 vm = new PostMessageVM(); | 165 vm = new PostMessageVM(); |
| 161 _initOnce(true); | 166 _initOnce(true); |
| 162 } | 167 } |
| 163 | 168 |
| 164 ObservatoryApplication(this.rootElement) : | 169 ObservatoryApplication(this.rootElement) : |
| (...skipping 11 matching lines...) Expand all Loading... |
| 176 | 181 |
| 177 _vmDisconnected(VM vm) { | 182 _vmDisconnected(VM vm) { |
| 178 if (this.vm != vm) { | 183 if (this.vm != vm) { |
| 179 // This disconnect event occured *after* a new VM was installed. | 184 // This disconnect event occured *after* a new VM was installed. |
| 180 return; | 185 return; |
| 181 } | 186 } |
| 182 this.vm = null; | 187 this.vm = null; |
| 183 locationManager.go(locationManager.makeLink('/vm-connect/')); | 188 locationManager.go(locationManager.makeLink('/vm-connect/')); |
| 184 } | 189 } |
| 185 } | 190 } |
| OLD | NEW |