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 _pageRegistry = new List<Page>(); | 11 final _pageRegistry = new List<Page>(); |
| 12 LocationManager _locationManager; |
| 13 LocationManager get locationManager => _locationManager; |
12 @observable Page currentPage; | 14 @observable Page currentPage; |
13 @observable final LocationManager locationManager; | |
14 VM _vm; | 15 VM _vm; |
15 VM get vm => _vm; | 16 VM get vm => _vm; |
16 set vm(VM vm) { | 17 set vm(VM vm) { |
17 if (_vm == vm) { | 18 if (_vm == vm) { |
18 // Do nothing. | 19 // Do nothing. |
19 return; | 20 return; |
20 } | 21 } |
21 if (_vm != null) { | 22 if (_vm != null) { |
22 // Disconnect from current VM. | 23 // Disconnect from current VM. |
23 notifications.clear(); | 24 notifications.clear(); |
(...skipping 11 matching lines...) Expand all Loading... |
35 } | 36 } |
36 final TargetManager targets; | 37 final TargetManager targets; |
37 @reflectable final ObservatoryApplicationElement rootElement; | 38 @reflectable final ObservatoryApplicationElement rootElement; |
38 | 39 |
39 TraceViewElement _traceView = null; | 40 TraceViewElement _traceView = null; |
40 | 41 |
41 @reflectable ServiceObject lastErrorOrException; | 42 @reflectable ServiceObject lastErrorOrException; |
42 @observable ObservableList<ServiceEvent> notifications = | 43 @observable ObservableList<ServiceEvent> notifications = |
43 new ObservableList<ServiceEvent>(); | 44 new ObservableList<ServiceEvent>(); |
44 | 45 |
45 void _initOnce(bool chromium) { | 46 void _initOnce() { |
46 assert(app == null); | 47 assert(app == null); |
47 app = this; | 48 app = this; |
48 _registerPages(); | 49 _registerPages(); |
49 locationManager._init(this); | 50 // Visit the current page. |
| 51 locationManager._visit(); |
50 } | 52 } |
51 | 53 |
52 void removePauseEvents(Isolate isolate) { | 54 void removePauseEvents(Isolate isolate) { |
53 bool isPauseEvent(var event) { | 55 bool isPauseEvent(var event) { |
54 return (event.eventType == ServiceEvent.kPauseStart || | 56 return (event.eventType == ServiceEvent.kPauseStart || |
55 event.eventType == ServiceEvent.kPauseExit || | 57 event.eventType == ServiceEvent.kPauseExit || |
56 event.eventType == ServiceEvent.kPauseBreakpoint || | 58 event.eventType == ServiceEvent.kPauseBreakpoint || |
57 event.eventType == ServiceEvent.kPauseInterrupted || | 59 event.eventType == ServiceEvent.kPauseInterrupted || |
58 event.eventType == ServiceEvent.kPauseException); | 60 event.eventType == ServiceEvent.kPauseException); |
59 } | 61 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 } | 99 } |
98 } | 100 } |
99 | 101 |
100 void _registerPages() { | 102 void _registerPages() { |
101 _pageRegistry.add(new VMPage(this)); | 103 _pageRegistry.add(new VMPage(this)); |
102 _pageRegistry.add(new FlagsPage(this)); | 104 _pageRegistry.add(new FlagsPage(this)); |
103 _pageRegistry.add(new InspectPage(this)); | 105 _pageRegistry.add(new InspectPage(this)); |
104 _pageRegistry.add(new ClassTreePage(this)); | 106 _pageRegistry.add(new ClassTreePage(this)); |
105 _pageRegistry.add(new DebuggerPage(this)); | 107 _pageRegistry.add(new DebuggerPage(this)); |
106 _pageRegistry.add(new CpuProfilerPage(this)); | 108 _pageRegistry.add(new CpuProfilerPage(this)); |
| 109 _pageRegistry.add(new TableCpuProfilerPage(this)); |
107 _pageRegistry.add(new AllocationProfilerPage(this)); | 110 _pageRegistry.add(new AllocationProfilerPage(this)); |
108 _pageRegistry.add(new HeapMapPage(this)); | 111 _pageRegistry.add(new HeapMapPage(this)); |
109 _pageRegistry.add(new VMConnectPage(this)); | 112 _pageRegistry.add(new VMConnectPage(this)); |
110 _pageRegistry.add(new ErrorViewPage(this)); | 113 _pageRegistry.add(new ErrorViewPage(this)); |
111 _pageRegistry.add(new MetricsPage(this)); | 114 _pageRegistry.add(new MetricsPage(this)); |
112 // Note that ErrorPage must be the last entry in the list as it is | 115 // Note that ErrorPage must be the last entry in the list as it is |
113 // the catch all. | 116 // the catch all. |
114 _pageRegistry.add(new ErrorPage(this)); | 117 _pageRegistry.add(new ErrorPage(this)); |
115 } | 118 } |
116 | 119 |
117 void _onError(ServiceError error) { | 120 void _onError(ServiceError error) { |
118 lastErrorOrException = error; | 121 lastErrorOrException = error; |
119 _visit('error/', null); | 122 _visit(Uri.parse('error/'), null); |
120 } | 123 } |
121 | 124 |
122 void _onException(ServiceException exception) { | 125 void _onException(ServiceException exception) { |
123 lastErrorOrException = exception; | 126 lastErrorOrException = exception; |
124 if (exception.kind == 'NetworkException') { | 127 if (exception.kind == 'NetworkException') { |
125 // Got a network exception, visit the vm-connect page. | 128 // Got a network exception, visit the vm-connect page. |
126 this.vm = null; | 129 this.vm = null; |
127 locationManager.go(locationManager.makeLink('/vm-connect/')); | 130 locationManager.go(locationManager.makeLink('/vm-connect/')); |
128 } else { | 131 } else { |
129 _visit('error/', null); | 132 _visit(Uri.parse('error/'), null); |
130 } | 133 } |
131 } | 134 } |
132 | 135 |
133 void _visit(String url, String args) { | 136 void _visit(Uri uri, Map internalArguments) { |
134 var argsMap; | 137 if (internalArguments['trace'] != null) { |
135 if (args == null) { | 138 var traceArg = internalArguments['trace']; |
136 argsMap = {}; | |
137 } else { | |
138 argsMap = Uri.splitQueryString(args); | |
139 } | |
140 if (argsMap['trace'] != null) { | |
141 var traceArg = argsMap['trace']; | |
142 if (traceArg == 'on') { | 139 if (traceArg == 'on') { |
143 Tracer.start(); | 140 Tracer.start(); |
144 } else if (traceArg == 'off') { | 141 } else if (traceArg == 'off') { |
145 Tracer.stop(); | 142 Tracer.stop(); |
146 } | 143 } |
147 } | 144 } |
148 if (Tracer.current != null) { | 145 if (Tracer.current != null) { |
149 Tracer.current.reset(); | 146 Tracer.current.reset(); |
150 } | 147 } |
151 if (_traceView != null) { | 148 if (_traceView != null) { |
152 _traceView.tracer = Tracer.current; | 149 _traceView.tracer = Tracer.current; |
153 } | 150 } |
154 Uri uri = Uri.parse(url); | |
155 for (var i = 0; i < _pageRegistry.length; i++) { | 151 for (var i = 0; i < _pageRegistry.length; i++) { |
156 var page = _pageRegistry[i]; | 152 var page = _pageRegistry[i]; |
157 if (page.canVisit(uri)) { | 153 if (page.canVisit(uri)) { |
158 _installPage(page); | 154 _installPage(page); |
159 page.visit(uri, argsMap); | 155 page.visit(uri, internalArguments); |
160 return; | 156 return; |
161 } | 157 } |
162 } | 158 } |
163 throw new FallThroughError(); | 159 throw new FallThroughError(); |
164 } | 160 } |
165 | 161 |
166 /// Set the Observatory application page. | 162 /// Set the Observatory application page. |
167 void _installPage(Page page) { | 163 void _installPage(Page page) { |
168 assert(page != null); | 164 assert(page != null); |
169 if (currentPage == page) { | 165 if (currentPage == page) { |
(...skipping 18 matching lines...) Expand all Loading... |
188 // Add tracing support. | 184 // Add tracing support. |
189 _traceView = new Element.tag('trace-view'); | 185 _traceView = new Element.tag('trace-view'); |
190 _traceView.tracer = Tracer.current; | 186 _traceView.tracer = Tracer.current; |
191 rootElement.children.add(_traceView); | 187 rootElement.children.add(_traceView); |
192 | 188 |
193 // Remember page. | 189 // Remember page. |
194 currentPage = page; | 190 currentPage = page; |
195 } | 191 } |
196 | 192 |
197 ObservatoryApplication(this.rootElement) : | 193 ObservatoryApplication(this.rootElement) : |
198 locationManager = new HashLocationManager(), | |
199 targets = new TargetManager() { | 194 targets = new TargetManager() { |
| 195 _locationManager = new LocationManager(this); |
200 vm = new WebSocketVM(targets.defaultTarget); | 196 vm = new WebSocketVM(targets.defaultTarget); |
201 _initOnce(false); | 197 _initOnce(); |
202 } | 198 } |
203 | 199 |
204 void _removeDisconnectEvents() { | 200 void _removeDisconnectEvents() { |
205 notifications.removeWhere((oldEvent) { | 201 notifications.removeWhere((oldEvent) { |
206 return (oldEvent.eventType == ServiceEvent.kVMDisconnected); | 202 return (oldEvent.eventType == ServiceEvent.kVMDisconnected); |
207 }); | 203 }); |
208 } | 204 } |
209 | 205 |
210 _vmConnected(VM vm) { | 206 _vmConnected(VM vm) { |
211 if (vm is WebSocketVM) { | 207 if (vm is WebSocketVM) { |
212 targets.add(vm.target); | 208 targets.add(vm.target); |
213 } | 209 } |
214 _removeDisconnectEvents(); | 210 _removeDisconnectEvents(); |
215 } | 211 } |
216 | 212 |
217 _vmDisconnected(VM vm) { | 213 _vmDisconnected(VM vm) { |
218 if (this.vm != vm) { | 214 if (this.vm != vm) { |
219 // This disconnect event occured *after* a new VM was installed. | 215 // This disconnect event occured *after* a new VM was installed. |
220 return; | 216 return; |
221 } | 217 } |
222 this.vm = null; | 218 this.vm = null; |
223 notifications.add(new ServiceEvent.vmDisconencted()); | 219 notifications.add(new ServiceEvent.vmDisconencted()); |
224 } | 220 } |
225 } | 221 } |
OLD | NEW |