Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: runtime/observatory/lib/src/elements/cpu_profile.dart

Issue 2345023003: Use dartfmt on Observatory code (Closed)
Patch Set: merge Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 cpu_profile_element; 5 library cpu_profile_element;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'package:observatory/models.dart' as M; 9 import 'package:observatory/models.dart' as M;
10 import 'package:observatory/src/elements/cpu_profile/virtual_tree.dart'; 10 import 'package:observatory/src/elements/cpu_profile/virtual_tree.dart';
11 import 'package:observatory/src/elements/helpers/nav_bar.dart'; 11 import 'package:observatory/src/elements/helpers/nav_bar.dart';
12 import 'package:observatory/src/elements/helpers/nav_menu.dart'; 12 import 'package:observatory/src/elements/helpers/nav_menu.dart';
13 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 13 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
14 import 'package:observatory/src/elements/helpers/tag.dart'; 14 import 'package:observatory/src/elements/helpers/tag.dart';
15 import 'package:observatory/src/elements/helpers/uris.dart'; 15 import 'package:observatory/src/elements/helpers/uris.dart';
16 import 'package:observatory/src/elements/nav/isolate_menu.dart'; 16 import 'package:observatory/src/elements/nav/isolate_menu.dart';
17 import 'package:observatory/src/elements/nav/notify.dart'; 17 import 'package:observatory/src/elements/nav/notify.dart';
18 import 'package:observatory/src/elements/nav/refresh.dart'; 18 import 'package:observatory/src/elements/nav/refresh.dart';
19 import 'package:observatory/src/elements/nav/top_menu.dart'; 19 import 'package:observatory/src/elements/nav/top_menu.dart';
20 import 'package:observatory/src/elements/nav/vm_menu.dart'; 20 import 'package:observatory/src/elements/nav/vm_menu.dart';
21 import 'package:observatory/src/elements/sample_buffer_control.dart'; 21 import 'package:observatory/src/elements/sample_buffer_control.dart';
22 import 'package:observatory/src/elements/stack_trace_tree_config.dart'; 22 import 'package:observatory/src/elements/stack_trace_tree_config.dart';
23 23
24 class CpuProfileElement extends HtmlElement implements Renderable { 24 class CpuProfileElement extends HtmlElement implements Renderable {
25 static const tag = const Tag<CpuProfileElement>('cpu-profile', 25 static const tag =
26 dependencies: const [ 26 const Tag<CpuProfileElement>('cpu-profile', dependencies: const [
27 NavTopMenuElement.tag, 27 NavTopMenuElement.tag,
28 NavVMMenuElement.tag, 28 NavVMMenuElement.tag,
29 NavIsolateMenuElement.tag, 29 NavIsolateMenuElement.tag,
30 NavRefreshElement.tag, 30 NavRefreshElement.tag,
31 NavNotifyElement.tag, 31 NavNotifyElement.tag,
32 SampleBufferControlElement.tag, 32 SampleBufferControlElement.tag,
33 StackTraceTreeConfigElement.tag, 33 StackTraceTreeConfigElement.tag,
34 CpuProfileVirtualTreeElement.tag, 34 CpuProfileVirtualTreeElement.tag,
35 ]); 35 ]);
36 36
37 RenderingScheduler<CpuProfileElement> _r; 37 RenderingScheduler<CpuProfileElement> _r;
38 38
39 Stream<RenderedEvent<CpuProfileElement>> get onRendered => _r.onRendered; 39 Stream<RenderedEvent<CpuProfileElement>> get onRendered => _r.onRendered;
40 40
41 M.VM _vm; 41 M.VM _vm;
42 M.IsolateRef _isolate; 42 M.IsolateRef _isolate;
43 M.EventRepository _events; 43 M.EventRepository _events;
44 M.NotificationRepository _notifications; 44 M.NotificationRepository _notifications;
45 M.IsolateSampleProfileRepository _profiles; 45 M.IsolateSampleProfileRepository _profiles;
46 Stream<M.SampleProfileLoadingProgressEvent> _progressStream; 46 Stream<M.SampleProfileLoadingProgressEvent> _progressStream;
47 M.SampleProfileLoadingProgress _progress; 47 M.SampleProfileLoadingProgress _progress;
48 M.SampleProfileTag _tag = M.SampleProfileTag.none; 48 M.SampleProfileTag _tag = M.SampleProfileTag.none;
49 ProfileTreeMode _mode = ProfileTreeMode.function; 49 ProfileTreeMode _mode = ProfileTreeMode.function;
50 M.ProfileTreeDirection _direction = M.ProfileTreeDirection.exclusive; 50 M.ProfileTreeDirection _direction = M.ProfileTreeDirection.exclusive;
51 String _filter = ''; 51 String _filter = '';
52 52
53
54 M.IsolateRef get isolate => _isolate; 53 M.IsolateRef get isolate => _isolate;
55 M.NotificationRepository get notifications => _notifications; 54 M.NotificationRepository get notifications => _notifications;
56 M.IsolateSampleProfileRepository get profiles => _profiles; 55 M.IsolateSampleProfileRepository get profiles => _profiles;
57 M.VMRef get vm => _vm; 56 M.VMRef get vm => _vm;
58 57
59 factory CpuProfileElement(M.VM vm, M.IsolateRef isolate, 58 factory CpuProfileElement(
60 M.EventRepository events, 59 M.VM vm,
61 M.NotificationRepository notifications, 60 M.IsolateRef isolate,
62 M.IsolateSampleProfileRepository profiles, 61 M.EventRepository events,
63 {RenderingQueue queue}) { 62 M.NotificationRepository notifications,
63 M.IsolateSampleProfileRepository profiles,
64 {RenderingQueue queue}) {
64 assert(vm != null); 65 assert(vm != null);
65 assert(isolate != null); 66 assert(isolate != null);
66 assert(events != null); 67 assert(events != null);
67 assert(notifications != null); 68 assert(notifications != null);
68 assert(profiles != null); 69 assert(profiles != null);
69 CpuProfileElement e = document.createElement(tag.name); 70 CpuProfileElement e = document.createElement(tag.name);
70 e._r = new RenderingScheduler(e, queue: queue); 71 e._r = new RenderingScheduler(e, queue: queue);
71 e._vm = vm; 72 e._vm = vm;
72 e._isolate = isolate; 73 e._isolate = isolate;
73 e._events = events; 74 e._events = events;
(...skipping 18 matching lines...) Expand all
92 children = []; 93 children = [];
93 } 94 }
94 95
95 void render() { 96 void render() {
96 var content = [ 97 var content = [
97 navBar([ 98 navBar([
98 new NavTopMenuElement(queue: _r.queue), 99 new NavTopMenuElement(queue: _r.queue),
99 new NavVMMenuElement(_vm, _events, queue: _r.queue), 100 new NavVMMenuElement(_vm, _events, queue: _r.queue),
100 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), 101 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue),
101 navMenu('cpu profile', link: Uris.cpuProfiler(_isolate)), 102 navMenu('cpu profile', link: Uris.cpuProfiler(_isolate)),
102 new NavRefreshElement(queue: _r.queue) 103 new NavRefreshElement(queue: _r.queue)..onRefresh.listen(_refresh),
103 ..onRefresh.listen(_refresh),
104 new NavRefreshElement(label: 'Clear', queue: _r.queue) 104 new NavRefreshElement(label: 'Clear', queue: _r.queue)
105 ..onRefresh.listen(_clearCpuProfile), 105 ..onRefresh.listen(_clearCpuProfile),
106 new NavNotifyElement(_notifications, queue: _r.queue) 106 new NavNotifyElement(_notifications, queue: _r.queue)
107 ]), 107 ]),
108 ]; 108 ];
109 if (_progress == null) { 109 if (_progress == null) {
110 children = content; 110 children = content;
111 return; 111 return;
112 } 112 }
113 content.add(new SampleBufferControlElement(_progress, _progressStream, 113 content.add(new SampleBufferControlElement(_progress, _progressStream,
114 selectedTag: _tag, queue: _r.queue) 114 selectedTag: _tag, queue: _r.queue)
115 ..onTagChange.listen((e) { 115 ..onTagChange.listen((e) {
116 _tag = e.element.selectedTag; 116 _tag = e.element.selectedTag;
117 _request(); 117 _request();
118 })); 118 }));
119 if (_progress.status == M.SampleProfileLoadingStatus.loaded) { 119 if (_progress.status == M.SampleProfileLoadingStatus.loaded) {
120 CpuProfileVirtualTreeElement tree; 120 CpuProfileVirtualTreeElement tree;
121 content.addAll([ 121 content.addAll([
122 new BRElement(), 122 new BRElement(),
123 new StackTraceTreeConfigElement(mode: _mode, direction: _direction, 123 new StackTraceTreeConfigElement(
124 filter: _filter, queue: _r.queue) 124 mode: _mode,
125 ..onModeChange.listen((e) { 125 direction: _direction,
126 _mode = tree.mode = e.element.mode; 126 filter: _filter,
127 }) 127 queue: _r.queue)
128 ..onFilterChange.listen((e) { 128 ..onModeChange.listen((e) {
129 _filter = e.element.filter.trim(); 129 _mode = tree.mode = e.element.mode;
130 tree.filters = _filter.isNotEmpty 130 })
131 ? [(node) { return node.name.contains(_filter); }] 131 ..onFilterChange.listen((e) {
132 _filter = e.element.filter.trim();
133 tree.filters = _filter.isNotEmpty
134 ? [
135 (node) {
136 return node.name.contains(_filter);
137 }
138 ]
132 : const []; 139 : const [];
133 }) 140 })
134 ..onDirectionChange.listen((e) { 141 ..onDirectionChange.listen((e) {
135 _direction = tree.direction = e.element.direction; 142 _direction = tree.direction = e.element.direction;
136 }), 143 }),
137 new BRElement(), 144 new BRElement(),
138 tree = new CpuProfileVirtualTreeElement(_isolate, _progress.profile, 145 tree = new CpuProfileVirtualTreeElement(_isolate, _progress.profile,
139 queue: _r.queue) 146 queue: _r.queue)
140 ]); 147 ]);
141 } 148 }
142 children = content; 149 children = content;
143 } 150 }
144 151
145 Future _request({bool clear: false, bool forceFetch: false}) async { 152 Future _request({bool clear: false, bool forceFetch: false}) async {
146 _progress = null; 153 _progress = null;
147 _progressStream = _profiles.get(isolate, _tag, clear: clear, 154 _progressStream =
148 forceFetch: forceFetch); 155 _profiles.get(isolate, _tag, clear: clear, forceFetch: forceFetch);
149 _r.dirty(); 156 _r.dirty();
150 _progress = (await _progressStream.first).progress; 157 _progress = (await _progressStream.first).progress;
151 _r.dirty(); 158 _r.dirty();
152 if (M.isSampleProcessRunning(_progress.status)) { 159 if (M.isSampleProcessRunning(_progress.status)) {
153 _progress = (await _progressStream.last).progress; 160 _progress = (await _progressStream.last).progress;
154 _r.dirty(); 161 _r.dirty();
155 } 162 }
156 } 163 }
157 164
158 Future _clearCpuProfile(RefreshEvent e) async { 165 Future _clearCpuProfile(RefreshEvent e) async {
159 e.element.disabled = true; 166 e.element.disabled = true;
160 await _request(clear: true); 167 await _request(clear: true);
161 e.element.disabled = false; 168 e.element.disabled = false;
162 } 169 }
163 170
164 Future _refresh(e) async { 171 Future _refresh(e) async {
165 e.element.disabled = true; 172 e.element.disabled = true;
166 await _request(forceFetch: true); 173 await _request(forceFetch: true);
167 e.element.disabled = false; 174 e.element.disabled = false;
168 } 175 }
169 } 176 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698