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 'service_ref.dart'; |
| 11 |
| 12 @CustomTag('inbound-reference') |
| 13 class InboundReferenceElement extends ServiceRefElement { |
| 14 InboundReferenceElement.created() : super.created(); |
| 15 |
| 16 dynamic get slot => ref['slot']; |
| 17 bool get slotIsArrayIndex => slot is num; |
| 18 bool get slotIsField => slot is ServiceMap && slot['type'] == '@Field'; |
| 19 |
| 20 ServiceObject get source => ref['source']; |
| 21 |
| 22 // I.e., inbound references to 'source' for recursive pointer chasing. |
| 23 @observable ObservableList inboundReferences; |
| 24 Future<ServiceObject> fetchInboundReferences(arg) { |
| 25 return source.isolate.get(source.id + "/inbound_references?limit=$arg") |
| 26 .then((ServiceMap response) { |
| 27 inboundReferences = new ObservableList.from(response['references']); |
| 28 }); |
| 29 } |
| 30 |
| 31 // TODO(turnidge): This is here to workaround vm/dart2js differences. |
| 32 dynamic expander() { |
| 33 return expandEvent; |
| 34 } |
| 35 |
| 36 void expandEvent(bool expand, var done) { |
| 37 assert(ref is ServiceMap); |
| 38 if (expand) { |
| 39 fetchInboundReferences(100).then((result) { |
| 40 notifyPropertyChange(#ref, 0, 1); |
| 41 }).whenComplete(done); |
| 42 } else { |
| 43 ServiceMap refMap = ref; |
| 44 refMap['fields'] = null; |
| 45 refMap['elements'] = null; |
| 46 done(); |
| 47 } |
| 48 } |
| 49 } |
OLD | NEW |