| 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'; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 sampleBufferControlElement = | 55 sampleBufferControlElement = |
| 56 shadowRoot.querySelector('#sampleBufferControl'); | 56 shadowRoot.querySelector('#sampleBufferControl'); |
| 57 assert(sampleBufferControlElement != null); | 57 assert(sampleBufferControlElement != null); |
| 58 sampleBufferControlElement.onSampleBufferUpdate = onSampleBufferChange; | 58 sampleBufferControlElement.onSampleBufferUpdate = onSampleBufferChange; |
| 59 sampleBufferControlElement.state = | 59 sampleBufferControlElement.state = |
| 60 SampleBufferControlElement.kNotLoadedState; | 60 SampleBufferControlElement.kNotLoadedState; |
| 61 stackTraceTreeConfigElement = | 61 stackTraceTreeConfigElement = |
| 62 shadowRoot.querySelector('#stackTraceTreeConfig'); | 62 shadowRoot.querySelector('#stackTraceTreeConfig'); |
| 63 assert(stackTraceTreeConfigElement != null); | 63 assert(stackTraceTreeConfigElement != null); |
| 64 stackTraceTreeConfigElement.onTreeConfigChange = onTreeConfigChange; | 64 stackTraceTreeConfigElement.onTreeConfigChange = onTreeConfigChange; |
| 65 stackTraceTreeConfigElement.show = false; |
| 65 cpuProfileTreeElement = shadowRoot.querySelector('#cpuProfileTree'); | 66 cpuProfileTreeElement = shadowRoot.querySelector('#cpuProfileTree'); |
| 66 assert(cpuProfileTreeElement != null); | 67 assert(cpuProfileTreeElement != null); |
| 67 cpuProfileTreeElement.profile = sampleBufferControlElement.profile; | 68 cpuProfileTreeElement.profile = sampleBufferControlElement.profile; |
| 69 cpuProfileTreeElement.show = false; |
| 68 cls.fields.forEach((field) => field.reload()); | 70 cls.fields.forEach((field) => field.reload()); |
| 69 sampleBufferControlElement.allocationProfileClass = cls; | 71 sampleBufferControlElement.allocationProfileClass = cls; |
| 70 } | 72 } |
| 71 | 73 |
| 72 Future refresh() { | 74 Future refresh() { |
| 73 instances = null; | 75 instances = null; |
| 74 retainedBytes = null; | 76 retainedBytes = null; |
| 75 mostRetained = null; | 77 mostRetained = null; |
| 76 var loads = []; | 78 var loads = []; |
| 77 loads.add(cls.reload()); | 79 loads.add(cls.reload()); |
| 78 cls.fields.forEach((field) => loads.add(field.reload())); | 80 cls.fields.forEach((field) => loads.add(field.reload())); |
| 79 return Future.wait(loads); | 81 return Future.wait(loads); |
| 80 } | 82 } |
| 81 | 83 |
| 82 Future refreshCoverage() { | 84 Future refreshCoverage() { |
| 83 return cls.refreshCoverage(); | 85 return cls.refreshCoverage(); |
| 84 } | 86 } |
| 85 | 87 |
| 86 onSampleBufferChange(CpuProfile sampleBuffer) { | 88 onSampleBufferChange(CpuProfile sampleBuffer) { |
| 89 stackTraceTreeConfigElement.show = sampleBuffer.sampleCount > 0; |
| 90 cpuProfileTreeElement.show = sampleBuffer.sampleCount > 0; |
| 87 cpuProfileTreeElement.render(); | 91 cpuProfileTreeElement.render(); |
| 88 } | 92 } |
| 89 | 93 |
| 90 onTreeConfigChange(String modeSelector, String directionSelector) { | 94 onTreeConfigChange(String modeSelector, String directionSelector) { |
| 91 ProfileTreeDirection direction = ProfileTreeDirection.Exclusive; | 95 ProfileTreeDirection direction = ProfileTreeDirection.Exclusive; |
| 92 if (directionSelector != 'Up') { | 96 if (directionSelector != 'Up') { |
| 93 direction = ProfileTreeDirection.Inclusive; | 97 direction = ProfileTreeDirection.Inclusive; |
| 94 } | 98 } |
| 95 ProfileTreeMode mode = ProfileTreeMode.Function; | 99 ProfileTreeMode mode = ProfileTreeMode.Function; |
| 96 if (modeSelector == 'Code') { | 100 if (modeSelector == 'Code') { |
| 97 mode = ProfileTreeMode.Code; | 101 mode = ProfileTreeMode.Code; |
| 98 } | 102 } |
| 99 cpuProfileTreeElement.direction = direction; | 103 cpuProfileTreeElement.direction = direction; |
| 100 cpuProfileTreeElement.mode = mode; | 104 cpuProfileTreeElement.mode = mode; |
| 101 cpuProfileTreeElement.render(); | 105 cpuProfileTreeElement.render(); |
| 102 } | 106 } |
| 103 | 107 |
| 104 Future refreshAllocationProfile() async { | 108 Future refreshAllocationProfile() async { |
| 105 return sampleBufferControlElement.reload(cls.isolate); | 109 return sampleBufferControlElement.reload(cls.isolate); |
| 106 } | 110 } |
| 107 | 111 |
| 108 Future toggleAllocationTrace() { | 112 Future toggleAllocationTrace() { |
| 109 if (cls == null) { | 113 if (cls == null) { |
| 110 return new Future(refresh); | 114 return new Future(refresh); |
| 111 } | 115 } |
| 112 return cls.setTraceAllocations(!cls.traceAllocations).whenComplete(refresh); | 116 return cls.setTraceAllocations(!cls.traceAllocations).whenComplete(refresh); |
| 113 } | 117 } |
| 114 } | 118 } |
| OLD | NEW |