| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library inbound_reference_element; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 import 'package:polymer/polymer.dart'; | |
| 9 import 'package:observatory/service.dart'; | |
| 10 import 'observatory_element.dart'; | |
| 11 | |
| 12 @CustomTag('inbound-reference') | |
| 13 class InboundReferenceElement extends ObservatoryElement { | |
| 14 @published ObservableMap ref; | |
| 15 InboundReferenceElement.created() : super.created(); | |
| 16 | |
| 17 dynamic get slot => ref['slot']; | |
| 18 bool get slotIsArrayIndex => slot is num; | |
| 19 bool get slotIsField => slot is ServiceMap && slot['type'] == '@Field'; | |
| 20 | |
| 21 ServiceObject get source => ref['source']; | |
| 22 | |
| 23 // I.e., inbound references to 'source' for recursive pointer chasing. | |
| 24 @observable ObservableList inboundReferences; | |
| 25 Future<ServiceObject> fetchInboundReferences(arg) { | |
| 26 return source.isolate.get(source.id + "/inbound_references?limit=$arg") | |
| 27 .then((ServiceMap response) { | |
| 28 inboundReferences = new ObservableList.from(response['references']); | |
| 29 }); | |
| 30 } | |
| 31 | |
| 32 // TODO(turnidge): This is here to workaround vm/dart2js differences. | |
| 33 dynamic expander() { | |
| 34 return expandEvent; | |
| 35 } | |
| 36 | |
| 37 void expandEvent(bool expand, Function onDone) { | |
| 38 if (expand) { | |
| 39 fetchInboundReferences(100).then((result) { | |
| 40 notifyPropertyChange(#ref, 0, 1); | |
| 41 }).whenComplete(onDone); | |
| 42 } else { | |
| 43 inboundReferences = null; | |
| 44 onDone(); | |
| 45 } | |
| 46 } | |
| 47 } | |
| OLD | NEW |