| 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 ServiceObject get source => ref['source']; | |
| 18 | |
| 19 // I.e., inbound references to 'source' for recursive pointer chasing. | 17 // I.e., inbound references to 'source' for recursive pointer chasing. |
| 20 @observable ObservableList inboundReferences; | 18 @observable ObservableList inboundReferences; |
| 21 Future<ServiceObject> fetchInboundReferences(arg) { | 19 Future<ServiceObject> fetchInboundReferences(arg) { |
| 20 var source = ref['source']; |
| 22 return source.isolate.getInboundReferences(source, arg) | 21 return source.isolate.getInboundReferences(source, arg) |
| 23 .then((ServiceMap response) { | 22 .then((ServiceMap response) { |
| 24 inboundReferences = new ObservableList.from(response['references']); | 23 inboundReferences = new ObservableList.from(response['references']); |
| 25 }); | 24 }); |
| 26 } | 25 } |
| 27 | 26 |
| 28 // TODO(turnidge): This is here to workaround vm/dart2js differences. | 27 // TODO(turnidge): This is here to workaround vm/dart2js differences. |
| 29 dynamic expander() { | 28 dynamic expander() { |
| 30 return expandEvent; | 29 return expandEvent; |
| 31 } | 30 } |
| 32 | 31 |
| 33 void expandEvent(bool expand, Function onDone) { | 32 void expandEvent(bool expand, Function onDone) { |
| 34 if (expand) { | 33 if (expand) { |
| 35 fetchInboundReferences(100).then((result) { | 34 fetchInboundReferences(100).then((result) { |
| 36 notifyPropertyChange(#ref, 0, 1); | 35 notifyPropertyChange(#ref, 0, 1); |
| 37 }).whenComplete(onDone); | 36 }).whenComplete(onDone); |
| 38 } else { | 37 } else { |
| 39 inboundReferences = null; | 38 inboundReferences = null; |
| 40 onDone(); | 39 onDone(); |
| 41 } | 40 } |
| 42 } | 41 } |
| 43 } | 42 } |
| OLD | NEW |