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