| 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 class_view_element; | 5 library class_view_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'observatory_element.dart'; | 8 import 'observatory_element.dart'; |
| 9 import 'package:observatory/cpu_profile.dart'; | 9 import 'package:observatory/cpu_profile.dart'; |
| 10 import 'package:observatory/elements.dart'; | 10 import 'package:observatory/elements.dart'; |
| 11 import 'package:observatory/service.dart'; | 11 import 'package:observatory/service.dart'; |
| 12 import 'package:polymer/polymer.dart'; | 12 import 'package:polymer/polymer.dart'; |
| 13 | 13 |
| 14 @CustomTag('class-view') | 14 @CustomTag('class-view') |
| 15 class ClassViewElement extends ObservatoryElement { | 15 class ClassViewElement extends ObservatoryElement { |
| 16 @published Class cls; | 16 @published Class cls; |
| 17 @observable ServiceMap instances; | 17 @observable ServiceMap instances; |
| 18 @observable int reachableBytes; |
| 18 @observable int retainedBytes; | 19 @observable int retainedBytes; |
| 19 @observable ObservableList mostRetained; | 20 @observable ObservableList mostRetained; |
| 20 SampleBufferControlElement sampleBufferControlElement; | 21 SampleBufferControlElement sampleBufferControlElement; |
| 21 StackTraceTreeConfigElement stackTraceTreeConfigElement; | 22 StackTraceTreeConfigElement stackTraceTreeConfigElement; |
| 22 CpuProfileTreeElement cpuProfileTreeElement; | 23 CpuProfileTreeElement cpuProfileTreeElement; |
| 23 | 24 |
| 24 ClassViewElement.created() : super.created(); | 25 ClassViewElement.created() : super.created(); |
| 25 | 26 |
| 26 Future<ServiceObject> evaluate(String expression) { | 27 Future<ServiceObject> evaluate(String expression) { |
| 27 return cls.evaluate(expression); | 28 return cls.evaluate(expression); |
| 28 } | 29 } |
| 29 | 30 |
| 30 Future<ServiceObject> reachable(var limit) { | 31 Future<ServiceObject> reachable(var limit) { |
| 31 return cls.isolate.getInstances(cls, limit).then((ServiceMap obj) { | 32 return cls.isolate.getInstances(cls, limit).then((ServiceMap obj) { |
| 32 instances = obj; | 33 instances = obj; |
| 33 }); | 34 }); |
| 34 } | 35 } |
| 35 | 36 |
| 36 Future<ServiceObject> retainedToplist(var limit) { | 37 Future<ServiceObject> retainedToplist(var limit) { |
| 37 return cls.isolate.fetchHeapSnapshot().last | 38 return cls.isolate.fetchHeapSnapshot().last |
| 38 .then((HeapSnapshot snapshot) => | 39 .then((HeapSnapshot snapshot) => |
| 39 Future.wait(snapshot.getMostRetained(classId: cls.vmCid, | 40 Future.wait(snapshot.getMostRetained(classId: cls.vmCid, |
| 40 limit: 10))) | 41 limit: 10))) |
| 41 .then((List<ServiceObject> most) { | 42 .then((List<ServiceObject> most) { |
| 42 mostRetained = new ObservableList.from(most); | 43 mostRetained = new ObservableList.from(most); |
| 43 }); | 44 }); |
| 44 } | 45 } |
| 45 | 46 |
| 46 // TODO(koda): Add no-arg "calculate-link" instead of reusing "eval-link". | 47 // TODO(koda): Add no-arg "calculate-link" instead of reusing "eval-link". |
| 48 Future<ServiceObject> reachableSize(var dummy) { |
| 49 return cls.isolate.getReachableSize(cls).then((Instance obj) { |
| 50 reachableBytes = int.parse(obj.valueAsString); |
| 51 }); |
| 52 } |
| 53 |
| 47 Future<ServiceObject> retainedSize(var dummy) { | 54 Future<ServiceObject> retainedSize(var dummy) { |
| 48 return cls.isolate.getRetainedSize(cls).then((Instance obj) { | 55 return cls.isolate.getRetainedSize(cls).then((Instance obj) { |
| 49 retainedBytes = int.parse(obj.valueAsString); | 56 retainedBytes = int.parse(obj.valueAsString); |
| 50 }); | 57 }); |
| 51 } | 58 } |
| 52 | 59 |
| 53 void attached() { | 60 void attached() { |
| 54 super.attached(); | 61 super.attached(); |
| 55 sampleBufferControlElement = | 62 sampleBufferControlElement = |
| 56 shadowRoot.querySelector('#sampleBufferControl'); | 63 shadowRoot.querySelector('#sampleBufferControl'); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 return sampleBufferControlElement.reload(cls.isolate); | 116 return sampleBufferControlElement.reload(cls.isolate); |
| 110 } | 117 } |
| 111 | 118 |
| 112 Future toggleAllocationTrace() { | 119 Future toggleAllocationTrace() { |
| 113 if (cls == null) { | 120 if (cls == null) { |
| 114 return new Future(refresh); | 121 return new Future(refresh); |
| 115 } | 122 } |
| 116 return cls.setTraceAllocations(!cls.traceAllocations).whenComplete(refresh); | 123 return cls.setTraceAllocations(!cls.traceAllocations).whenComplete(refresh); |
| 117 } | 124 } |
| 118 } | 125 } |
| OLD | NEW |