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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 if (_gcSubscription == null) { | 66 if (_gcSubscription == null) { |
67 return; | 67 return; |
68 } | 68 } |
69 _gcSubscription.cancel(); | 69 _gcSubscription.cancel(); |
70 _gcSubscription = null; | 70 _gcSubscription = null; |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 @reflectable final ObservatoryApplicationElement rootElement; | 74 @reflectable final ObservatoryApplicationElement rootElement; |
75 | 75 |
76 TraceViewElement _traceView = null; | |
77 | |
78 @reflectable ServiceObject lastErrorOrException; | 76 @reflectable ServiceObject lastErrorOrException; |
79 | 77 |
80 void _initOnce() { | 78 void _initOnce() { |
81 assert(app == null); | 79 assert(app == null); |
82 app = this; | 80 app = this; |
83 _registerPages(); | 81 _registerPages(); |
84 Analytics.initialize(); | 82 Analytics.initialize(); |
85 // Visit the current page. | 83 // Visit the current page. |
86 locationManager._visit(); | 84 locationManager._visit(); |
87 } | 85 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 var traceArg = internalArguments['trace']; | 130 var traceArg = internalArguments['trace']; |
133 if (traceArg == 'on') { | 131 if (traceArg == 'on') { |
134 Tracer.start(); | 132 Tracer.start(); |
135 } else if (traceArg == 'off') { | 133 } else if (traceArg == 'off') { |
136 Tracer.stop(); | 134 Tracer.stop(); |
137 } | 135 } |
138 } | 136 } |
139 if (Tracer.current != null) { | 137 if (Tracer.current != null) { |
140 Tracer.current.reset(); | 138 Tracer.current.reset(); |
141 } | 139 } |
142 if (_traceView != null) { | |
143 _traceView.tracer = Tracer.current; | |
144 } | |
145 for (var i = 0; i < _pageRegistry.length; i++) { | 140 for (var i = 0; i < _pageRegistry.length; i++) { |
146 var page = _pageRegistry[i]; | 141 var page = _pageRegistry[i]; |
147 if (page.canVisit(uri)) { | 142 if (page.canVisit(uri)) { |
148 _installPage(page); | 143 _installPage(page); |
149 page.visit(uri, internalArguments); | 144 page.visit(uri, internalArguments); |
150 return; | 145 return; |
151 } | 146 } |
152 } | 147 } |
153 throw new FallThroughError(); | 148 throw new FallThroughError(); |
154 } | 149 } |
(...skipping 13 matching lines...) Expand all Loading... |
168 } | 163 } |
169 Logger.root.info('Installing page: $page'); | 164 Logger.root.info('Installing page: $page'); |
170 try { | 165 try { |
171 page.onInstall(); | 166 page.onInstall(); |
172 } catch (e) { | 167 } catch (e) { |
173 Logger.root.severe('Failed to install page: $e'); | 168 Logger.root.severe('Failed to install page: $e'); |
174 } | 169 } |
175 // Add new page. | 170 // Add new page. |
176 rootElement.children.add(page.element); | 171 rootElement.children.add(page.element); |
177 | 172 |
178 // Add tracing support. | |
179 _traceView = new Element.tag('trace-view'); | |
180 _traceView.tracer = Tracer.current; | |
181 rootElement.children.add(_traceView); | |
182 | |
183 // Remember page. | 173 // Remember page. |
184 currentPage = page; | 174 currentPage = page; |
185 } | 175 } |
186 | 176 |
187 ObservatoryApplication(this.rootElement) { | 177 ObservatoryApplication(this.rootElement) { |
188 _locationManager = new LocationManager(this); | 178 _locationManager = new LocationManager(this); |
189 targets.onChange.listen((e) { | 179 targets.onChange.listen((e) { |
190 if (targets.current == null) return _setVM(null); | 180 if (targets.current == null) return _setVM(null); |
191 if ((_vm as WebSocketVM)?.target != targets.current) { | 181 if ((_vm as WebSocketVM)?.target != targets.current) { |
192 _setVM(new WebSocketVM(targets.current)); | 182 _setVM(new WebSocketVM(targets.current)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 217 } |
228 | 218 |
229 // TODO(turnidge): Report this failure via analytics. | 219 // TODO(turnidge): Report this failure via analytics. |
230 Logger.root.warning('Caught exception: ${e}\n${st}'); | 220 Logger.root.warning('Caught exception: ${e}\n${st}'); |
231 notifications.add(new ExceptionNotification(e, stacktrace: st)); | 221 notifications.add(new ExceptionNotification(e, stacktrace: st)); |
232 } | 222 } |
233 | 223 |
234 // This map keeps track of which curly-blocks have been expanded by the user. | 224 // This map keeps track of which curly-blocks have been expanded by the user. |
235 Map<String,bool> expansions = {}; | 225 Map<String,bool> expansions = {}; |
236 } | 226 } |
OLD | NEW |