| 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 request response interceptor is called for each response. | 7 /// A request response interceptor is called for each response. |
| 8 typedef void RequestResponseInterceptor(); | 8 typedef void RequestResponseInterceptor(); |
| 9 | 9 |
| 10 /// The observatory application. Instances of this are created and owned | 10 /// The observatory application. Instances of this are created and owned |
| 11 /// by the observatory_application custom element. | 11 /// by the observatory_application custom element. |
| 12 class ObservatoryApplication extends Observable { | 12 class ObservatoryApplication extends Observable { |
| 13 @observable final LocationManager locationManager; | 13 @observable final LocationManager locationManager; |
| 14 @observable final VM vm; | 14 @observable final VM vm; |
| 15 @observable Isolate isolate; | 15 @observable Isolate isolate; |
| 16 | 16 |
| 17 /// The current [ServiceObject] being viewed by the application. | 17 /// The current [ServiceObject] being viewed by the application. |
| 18 @observable ServiceObject response; | 18 @observable ServiceObject response; |
| 19 | 19 |
| 20 /// Any client-level arguments for viewing the current response. | 20 /// Any client-level arguments for viewing the current response. |
| 21 @observable String args; | 21 @observable String args; |
| 22 // TODO(turnidge): Make args a Map. | 22 // TODO(turnidge): Make args a Map. |
| 23 | 23 |
| 24 void _initOnce() { | 24 void _initOnce() { |
| 25 // Only called once. | 25 // Only called once. |
| 26 assert(locationManager._app == null); | 26 assert(locationManager._app == null); |
| 27 locationManager._app = this; | 27 locationManager._app = this; |
| 28 locationManager.init(); | 28 locationManager.init(); |
| 29 vm.errors.stream.listen(_onError); |
| 30 vm.exceptions.stream.listen(_onException); |
| 31 } |
| 32 |
| 33 void _onError(ServiceError error) { |
| 34 response = error; |
| 35 // No id, clear the hash. |
| 36 locationManager.clearCurrentHash(); |
| 37 } |
| 38 |
| 39 void _onException(ServiceException exception) { |
| 40 response = exception; |
| 41 // No id, clear the hash. |
| 42 locationManager.clearCurrentHash(); |
| 29 } | 43 } |
| 30 | 44 |
| 31 ObservatoryApplication.devtools() : | 45 ObservatoryApplication.devtools() : |
| 32 locationManager = new LocationManager(), | 46 locationManager = new LocationManager(), |
| 33 vm = new DartiumVM() { | 47 vm = new DartiumVM() { |
| 34 _initOnce(); | 48 _initOnce(); |
| 35 } | 49 } |
| 36 | 50 |
| 37 ObservatoryApplication() : | 51 ObservatoryApplication() : |
| 38 locationManager = new LocationManager(), | 52 locationManager = new LocationManager(), |
| 39 vm = new HttpVM() { | 53 vm = new HttpVM() { |
| 40 _initOnce(); | 54 _initOnce(); |
| 41 } | 55 } |
| 42 } | 56 } |
| OLD | NEW |