| 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 part of dart.vmstats; |
| 6 |
| 7 class IsolateList { |
| 8 UListElement _listArea; |
| 9 |
| 10 static const String CSS_VISIBLE = 'isolate_details'; |
| 11 static const String CSS_HIDDEN = 'isolate_details_hidden'; |
| 12 |
| 13 IsolateList(this._listArea) {} |
| 14 |
| 15 void updateList(IsolateListModel model) { |
| 16 var detailsClass = CSS_HIDDEN; |
| 17 if (_listArea.children.length > 0) { |
| 18 // Preserve visibility state. |
| 19 var listItem = _listArea.children.first; |
| 20 var item = listItem.children.first; |
| 21 if (item.classes.length > 0 && item.classes.first == CSS_VISIBLE) { |
| 22 detailsClass = CSS_VISIBLE; |
| 23 } |
| 24 _listArea.children.clear(); |
| 25 } |
| 26 var iterator = model.iterator; |
| 27 while (iterator.moveNext()) { |
| 28 var isolate = iterator.current; |
| 29 var listItem = new LIElement(); |
| 30 listItem.classes.add('isolate_list'); |
| 31 listItem.text = isolate.name |
| 32 .replaceAll('\$', ': ') // Split script from isolate, and ... |
| 33 .replaceAll('-', ' '); // ... split name from port number. |
| 34 |
| 35 // Add isolate details as hidden children. |
| 36 var details = new DivElement(); |
| 37 isolateDetails(isolate, details); |
| 38 details.classes.add(detailsClass); |
| 39 listItem.children.add(details); |
| 40 listItem.onClick.listen((e) => toggle(details)); |
| 41 |
| 42 _listArea.children.add(listItem); |
| 43 } |
| 44 } |
| 45 |
| 46 void isolateDetails(Isolate isolate, DivElement parent) { |
| 47 var newSpace = new DivElement(); |
| 48 newSpace.text = 'New space: ${isolate.newSpace.used}K'; |
| 49 parent.children.add(newSpace); |
| 50 var oldSpace = new DivElement(); |
| 51 oldSpace.text = 'Old space: ${isolate.oldSpace.used}K'; |
| 52 parent.children.add(oldSpace); |
| 53 var stack = new DivElement(); |
| 54 stack.text = 'Stack limit: ${(isolate.stackLimit / 1000000).round()}M'; |
| 55 parent.children.add(stack); |
| 56 } |
| 57 |
| 58 void toggle(DivElement e) { |
| 59 e.classes.toggle(CSS_VISIBLE); |
| 60 e.classes.toggle(CSS_HIDDEN); |
| 61 } |
| 62 } |
| OLD | NEW |