| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:html'; | 5 import 'dart:html'; |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'package:observatory/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
| 8 import 'package:observatory/src/elements/cpu_profile/virtual_tree.dart'; | 8 import 'package:observatory/src/elements/cpu_profile/virtual_tree.dart'; |
| 9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
| 10 import 'package:observatory/src/elements/helpers/tag.dart'; | 10 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 11 import 'package:observatory/src/elements/sample_buffer_control.dart'; | 11 import 'package:observatory/src/elements/sample_buffer_control.dart'; |
| 12 import 'package:observatory/src/elements/stack_trace_tree_config.dart'; | 12 import 'package:observatory/src/elements/stack_trace_tree_config.dart'; |
| 13 | 13 |
| 14 class ClassAllocationProfileElement extends HtmlElement implements Renderable { | 14 class ClassAllocationProfileElement extends HtmlElement implements Renderable { |
| 15 static const tag = const Tag<ClassAllocationProfileElement>( | 15 static const tag = const Tag<ClassAllocationProfileElement>( |
| 16 'class-allocation-profile', | 16 'class-allocation-profile', |
| 17 dependencies: const [ | 17 dependencies: const [ |
| 18 SampleBufferControlElement.tag, | 18 SampleBufferControlElement.tag, |
| 19 StackTraceTreeConfigElement.tag, | 19 StackTraceTreeConfigElement.tag, |
| 20 CpuProfileVirtualTreeElement.tag, | 20 CpuProfileVirtualTreeElement.tag, |
| 21 ]); | 21 ]); |
| 22 | 22 |
| 23 RenderingScheduler<ClassAllocationProfileElement> _r; | 23 RenderingScheduler<ClassAllocationProfileElement> _r; |
| 24 | 24 |
| 25 Stream<RenderedEvent<ClassAllocationProfileElement>> get onRendered => | 25 Stream<RenderedEvent<ClassAllocationProfileElement>> get onRendered => |
| 26 _r.onRendered; | 26 _r.onRendered; |
| 27 | 27 |
| 28 M.IsolateRef _isolate; | 28 M.IsolateRef _isolate; |
| 29 M.Class _cls; | 29 M.Class _cls; |
| 30 M.ClassSampleProfileRepository _profiles; | 30 M.ClassSampleProfileRepository _profiles; |
| 31 Stream<M.SampleProfileLoadingProgressEvent> _progressStream; | 31 Stream<M.SampleProfileLoadingProgressEvent> _progressStream; |
| 32 M.SampleProfileLoadingProgress _progress; | 32 M.SampleProfileLoadingProgress _progress; |
| 33 M.SampleProfileTag _tag = M.SampleProfileTag.none; | 33 M.SampleProfileTag _tag = M.SampleProfileTag.none; |
| 34 ProfileTreeMode _mode = ProfileTreeMode.function; | 34 ProfileTreeMode _mode = ProfileTreeMode.function; |
| 35 M.ProfileTreeDirection _direction = M.ProfileTreeDirection.exclusive; | 35 M.ProfileTreeDirection _direction = M.ProfileTreeDirection.exclusive; |
| 36 | 36 |
| 37 | |
| 38 | |
| 39 M.IsolateRef get isolate => _isolate; | 37 M.IsolateRef get isolate => _isolate; |
| 40 M.Class get cls => _cls; | 38 M.Class get cls => _cls; |
| 41 | 39 |
| 42 factory ClassAllocationProfileElement(M.IsolateRef isolate, M.Class cls, | 40 factory ClassAllocationProfileElement(M.IsolateRef isolate, M.Class cls, |
| 43 M.ClassSampleProfileRepository profiles, {RenderingQueue queue}) { | 41 M.ClassSampleProfileRepository profiles, |
| 42 {RenderingQueue queue}) { |
| 44 assert(isolate != null); | 43 assert(isolate != null); |
| 45 assert(cls != null); | 44 assert(cls != null); |
| 46 assert(profiles != null); | 45 assert(profiles != null); |
| 47 ClassAllocationProfileElement e = document.createElement(tag.name); | 46 ClassAllocationProfileElement e = document.createElement(tag.name); |
| 48 e._r = new RenderingScheduler(e, queue: queue); | 47 e._r = new RenderingScheduler(e, queue: queue); |
| 49 e._isolate = isolate; | 48 e._isolate = isolate; |
| 50 e._cls = cls; | 49 e._cls = cls; |
| 51 e._profiles = profiles; | 50 e._profiles = profiles; |
| 52 return e; | 51 return e; |
| 53 } | 52 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 78 selectedTag: _tag, queue: _r.queue) | 77 selectedTag: _tag, queue: _r.queue) |
| 79 ..onTagChange.listen((e) { | 78 ..onTagChange.listen((e) { |
| 80 _tag = e.element.selectedTag; | 79 _tag = e.element.selectedTag; |
| 81 _request(); | 80 _request(); |
| 82 }) | 81 }) |
| 83 ]; | 82 ]; |
| 84 if (_progress.status == M.SampleProfileLoadingStatus.loaded) { | 83 if (_progress.status == M.SampleProfileLoadingStatus.loaded) { |
| 85 CpuProfileVirtualTreeElement tree; | 84 CpuProfileVirtualTreeElement tree; |
| 86 content.addAll([ | 85 content.addAll([ |
| 87 new BRElement(), | 86 new BRElement(), |
| 88 new StackTraceTreeConfigElement(mode: _mode, direction: _direction, | 87 new StackTraceTreeConfigElement( |
| 89 showFilter: false, queue: _r.queue) | 88 mode: _mode, |
| 90 ..onModeChange.listen((e) { | 89 direction: _direction, |
| 91 _mode = tree.mode = e.element.mode; | 90 showFilter: false, |
| 92 }) | 91 queue: _r.queue) |
| 93 ..onDirectionChange.listen((e) { | 92 ..onModeChange.listen((e) { |
| 94 _direction = tree.direction = e.element.direction; | 93 _mode = tree.mode = e.element.mode; |
| 95 }), | 94 }) |
| 95 ..onDirectionChange.listen((e) { |
| 96 _direction = tree.direction = e.element.direction; |
| 97 }), |
| 96 new BRElement(), | 98 new BRElement(), |
| 97 tree = new CpuProfileVirtualTreeElement(_isolate, _progress.profile, | 99 tree = new CpuProfileVirtualTreeElement(_isolate, _progress.profile, |
| 98 queue: _r.queue) | 100 queue: _r.queue) |
| 99 ]); | 101 ]); |
| 100 } | 102 } |
| 101 children = content; | 103 children = content; |
| 102 } | 104 } |
| 103 | 105 |
| 104 Future _request() async { | 106 Future _request() async { |
| 105 _progress = null; | 107 _progress = null; |
| 106 _progressStream = _profiles.get(_isolate, _cls, _tag); | 108 _progressStream = _profiles.get(_isolate, _cls, _tag); |
| 107 _r.dirty(); | 109 _r.dirty(); |
| 108 _progress = (await _progressStream.first).progress; | 110 _progress = (await _progressStream.first).progress; |
| 109 _r.dirty(); | 111 _r.dirty(); |
| 110 if (M.isSampleProcessRunning(_progress.status)) { | 112 if (M.isSampleProcessRunning(_progress.status)) { |
| 111 _progress = (await _progressStream.last).progress; | 113 _progress = (await _progressStream.last).progress; |
| 112 _r.dirty(); | 114 _r.dirty(); |
| 113 } | 115 } |
| 114 } | 116 } |
| 115 } | 117 } |
| OLD | NEW |