OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, 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 objectpool_view; |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'observatory_element.dart'; |
| 9 import 'package:observatory/service.dart'; |
| 10 import 'package:polymer/polymer.dart'; |
| 11 |
| 12 @CustomTag('objectpool-view') |
| 13 class ObjectPoolViewElement extends ObservatoryElement { |
| 14 @published ObjectPool pool; |
| 15 @published List annotatedEntries; |
| 16 |
| 17 ObjectPoolViewElement.created() : super.created(); |
| 18 |
| 19 bool isServiceObject(o) => o is ServiceObject; |
| 20 |
| 21 void poolChanged(oldValue) { |
| 22 annotateRawEntries(); |
| 23 } |
| 24 |
| 25 Future annotateRawEntries() { |
| 26 var tasks = pool.entries.map((entry) { |
| 27 if (entry is int) { |
| 28 var addr = entry.toRadixString(16); |
| 29 return pool.isolate.getObjectByAddress(addr).then((result) { |
| 30 return result is ServiceObject ? result : null; |
| 31 }); |
| 32 } else { |
| 33 return new Future.value(null); |
| 34 } |
| 35 }); |
| 36 |
| 37 return Future.wait(tasks).then((results) => annotatedEntries = results); |
| 38 } |
| 39 |
| 40 Future refresh() { |
| 41 return pool.reload().then((_) => annotateRawEntries()); |
| 42 } |
| 43 } |
OLD | NEW |