| Index: runtime/observatory/lib/src/elements/class_view.dart
|
| diff --git a/runtime/observatory/lib/src/elements/class_view.dart b/runtime/observatory/lib/src/elements/class_view.dart
|
| index b1ac3fca46e6aca9e31a5172075afc2872eeef2a..9f860a9f25f56fccafc9b21c7190c4a5f386d4fe 100644
|
| --- a/runtime/observatory/lib/src/elements/class_view.dart
|
| +++ b/runtime/observatory/lib/src/elements/class_view.dart
|
| @@ -6,9 +6,13 @@ library class_view_element;
|
|
|
| import 'dart:async';
|
| import 'observatory_element.dart';
|
| -import 'package:observatory/cpu_profile.dart';
|
| +import 'sample_buffer_control.dart';
|
| +import 'stack_trace_tree_config.dart';
|
| +import 'cpu_profile/virtual_tree.dart';
|
| import 'package:observatory/elements.dart';
|
| +import 'package:observatory/models.dart' as M;
|
| import 'package:observatory/service.dart';
|
| +import 'package:observatory/repositories.dart';
|
| import 'package:polymer/polymer.dart';
|
|
|
| @CustomTag('class-view')
|
| @@ -21,6 +25,8 @@ class ClassViewElement extends ObservatoryElement {
|
| SampleBufferControlElement sampleBufferControlElement;
|
| StackTraceTreeConfigElement stackTraceTreeConfigElement;
|
| CpuProfileVirtualTreeElement cpuProfileTreeElement;
|
| + ClassSampleProfileRepository repository = new ClassSampleProfileRepository();
|
| +
|
|
|
| ClassViewElement.created() : super.created();
|
|
|
| @@ -59,66 +65,62 @@ class ClassViewElement extends ObservatoryElement {
|
|
|
| void attached() {
|
| super.attached();
|
| - sampleBufferControlElement =
|
| - shadowRoot.querySelector('#sampleBufferControl');
|
| - assert(sampleBufferControlElement != null);
|
| - sampleBufferControlElement.onSampleBufferUpdate = onSampleBufferChange;
|
| - sampleBufferControlElement.state =
|
| - SampleBufferControlElement.kNotLoadedState;
|
| - stackTraceTreeConfigElement =
|
| - shadowRoot.querySelector('#stackTraceTreeConfig');
|
| - assert(stackTraceTreeConfigElement != null);
|
| - stackTraceTreeConfigElement.onTreeConfigChange = onTreeConfigChange;
|
| - stackTraceTreeConfigElement.show = false;
|
| - stackTraceTreeConfigElement.showFilter = false;
|
| - cpuProfileTreeElement = shadowRoot.querySelector('#cpuProfileTree');
|
| - assert(cpuProfileTreeElement != null);
|
| - cpuProfileTreeElement.profile = sampleBufferControlElement.profile;
|
| - cpuProfileTreeElement.show = false;
|
| cls.fields.forEach((field) => field.reload());
|
| - sampleBufferControlElement.allocationProfileClass = cls;
|
| }
|
|
|
| - Future refresh() {
|
| + Future refresh() async {
|
| instances = null;
|
| retainedBytes = null;
|
| mostRetained = null;
|
| - var loads = [];
|
| - loads.add(cls.reload());
|
| - cls.fields.forEach((field) => loads.add(field.reload()));
|
| - return Future.wait(loads);
|
| + await cls.reload();
|
| + await Future.wait(cls.fields.map((field) => field.reload()));
|
| }
|
|
|
| - onSampleBufferChange(CpuProfile sampleBuffer) {
|
| - stackTraceTreeConfigElement.show = sampleBuffer.sampleCount > 0;
|
| - cpuProfileTreeElement.show = sampleBuffer.sampleCount > 0;
|
| - cpuProfileTreeElement.render();
|
| - }
|
| + M.SampleProfileTag _tag = M.SampleProfileTag.none;
|
|
|
| - onTreeConfigChange(String modeSelector,
|
| - String directionSelector,
|
| - String filter) {
|
| - ProfileTreeDirection direction = ProfileTreeDirection.Exclusive;
|
| - if (directionSelector != 'Up') {
|
| - direction = ProfileTreeDirection.Inclusive;
|
| + Future refreshAllocationProfile() async {
|
| + shadowRoot.querySelector('#sampleBufferControl').children = const [];
|
| + shadowRoot.querySelector('#stackTraceTreeConfig').children = const [];
|
| + shadowRoot.querySelector('#cpuProfileTree').children = const [];
|
| + final stream = repository.get(cls, _tag);
|
| + var progress = (await stream.first).progress;
|
| + shadowRoot.querySelector('#sampleBufferControl')..children = [
|
| + new SampleBufferControlElement(progress, stream, queue: app.queue,
|
| + selectedTag: _tag)
|
| + ..onTagChange.listen((e) {
|
| + _tag = e.element.selectedTag;
|
| + refreshAllocationProfile();
|
| + })
|
| + ];
|
| + if (M.isSampleProcessRunning(progress.status)) {
|
| + progress = await stream.last;
|
| }
|
| - ProfileTreeMode mode = ProfileTreeMode.Function;
|
| - if (modeSelector == 'Code') {
|
| - mode = ProfileTreeMode.Code;
|
| + if (progress.status == M.SampleProfileLoadingStatus.loaded) {
|
| + shadowRoot.querySelector('#stackTraceTreeConfig')..children = [
|
| + new StackTraceTreeConfigElement(
|
| + queue: app.queue)
|
| + ..showFilter = false
|
| + ..onModeChange.listen((e) {
|
| + cpuProfileTreeElement.mode = e.element.mode;
|
| + })
|
| + ..onDirectionChange.listen((e) {
|
| + cpuProfileTreeElement.direction = e.element.direction;
|
| + })
|
| + ];
|
| + shadowRoot.querySelector('#cpuProfileTree')..children = [
|
| + cpuProfileTreeElement = new CpuProfileVirtualTreeElement(cls.isolate,
|
| + progress.profile, queue: app.queue)
|
| + ];
|
| }
|
| - cpuProfileTreeElement.direction = direction;
|
| - cpuProfileTreeElement.mode = mode;
|
| - cpuProfileTreeElement.render();
|
| - }
|
| -
|
| - Future refreshAllocationProfile() async {
|
| - return sampleBufferControlElement.reload(cls.isolate);
|
| }
|
|
|
| Future toggleAllocationTrace() {
|
| if (cls == null) {
|
| return new Future(refresh);
|
| }
|
| + if (cls.traceAllocations) {
|
| + refreshAllocationProfile();
|
| + }
|
| return cls.setTraceAllocations(!cls.traceAllocations).whenComplete(refresh);
|
| }
|
| }
|
|
|