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

Side by Side Diff: runtime/observatory/lib/src/elements/object_common.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 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/class_ref.dart'; 8 import 'package:observatory/src/elements/class_ref.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/inbound_references.dart'; 11 import 'package:observatory/src/elements/inbound_references.dart';
12 import 'package:observatory/src/elements/retaining_path.dart'; 12 import 'package:observatory/src/elements/retaining_path.dart';
13 import 'package:observatory/src/elements/sentinel_value.dart'; 13 import 'package:observatory/src/elements/sentinel_value.dart';
14 import 'package:observatory/utils.dart'; 14 import 'package:observatory/utils.dart';
15 15
16 class ObjectCommonElement extends HtmlElement implements Renderable { 16 class ObjectCommonElement extends HtmlElement implements Renderable {
17 static const tag = const Tag<ObjectCommonElement>('object-common', 17 static const tag =
18 dependencies: const [ 18 const Tag<ObjectCommonElement>('object-common', dependencies: const [
19 ClassRefElement.tag, 19 ClassRefElement.tag,
20 InboundReferencesElement.tag, 20 InboundReferencesElement.tag,
21 RetainingPathElement.tag, 21 RetainingPathElement.tag,
22 SentinelValueElement.tag 22 SentinelValueElement.tag
23 ]); 23 ]);
24 24
25 RenderingScheduler<ObjectCommonElement> _r; 25 RenderingScheduler<ObjectCommonElement> _r;
26 26
27 Stream<RenderedEvent<ObjectCommonElement>> get onRendered => _r.onRendered; 27 Stream<RenderedEvent<ObjectCommonElement>> get onRendered => _r.onRendered;
28 28
29 M.IsolateRef _isolate; 29 M.IsolateRef _isolate;
30 M.Object _object; 30 M.Object _object;
31 M.RetainedSizeRepository _retainedSizes; 31 M.RetainedSizeRepository _retainedSizes;
32 M.ReachableSizeRepository _reachableSizes; 32 M.ReachableSizeRepository _reachableSizes;
33 M.InboundReferencesRepository _references; 33 M.InboundReferencesRepository _references;
34 M.RetainingPathRepository _retainingPaths; 34 M.RetainingPathRepository _retainingPaths;
35 M.InstanceRepository _instances; 35 M.InstanceRepository _instances;
36 M.Guarded<M.Instance> _retainedSize = null; 36 M.Guarded<M.Instance> _retainedSize = null;
37 bool _loadingRetainedBytes = false; 37 bool _loadingRetainedBytes = false;
38 M.Guarded<M.Instance> _reachableSize = null; 38 M.Guarded<M.Instance> _reachableSize = null;
39 bool _loadingReachableBytes = false; 39 bool _loadingReachableBytes = false;
40 40
41 M.IsolateRef get isolate => _isolate; 41 M.IsolateRef get isolate => _isolate;
42 M.Object get object => _object; 42 M.Object get object => _object;
43 43
44 factory ObjectCommonElement(M.IsolateRef isolate, M.Object object, 44 factory ObjectCommonElement(
45 M.RetainedSizeRepository retainedSizes, 45 M.IsolateRef isolate,
46 M.ReachableSizeRepository reachableSizes, 46 M.Object object,
47 M.InboundReferencesRepository references, 47 M.RetainedSizeRepository retainedSizes,
48 M.RetainingPathRepository retainingPaths, 48 M.ReachableSizeRepository reachableSizes,
49 M.InstanceRepository instances, 49 M.InboundReferencesRepository references,
50 {RenderingQueue queue}) { 50 M.RetainingPathRepository retainingPaths,
51 M.InstanceRepository instances,
52 {RenderingQueue queue}) {
51 assert(isolate != null); 53 assert(isolate != null);
52 assert(object != null); 54 assert(object != null);
53 assert(retainedSizes != null); 55 assert(retainedSizes != null);
54 assert(reachableSizes != null); 56 assert(reachableSizes != null);
55 assert(references != null); 57 assert(references != null);
56 assert(retainingPaths != null); 58 assert(retainingPaths != null);
57 assert(instances != null); 59 assert(instances != null);
58 ObjectCommonElement e = document.createElement(tag.name); 60 ObjectCommonElement e = document.createElement(tag.name);
59 e._r = new RenderingScheduler(e, queue: queue); 61 e._r = new RenderingScheduler(e, queue: queue);
60 e._isolate = isolate; 62 e._isolate = isolate;
(...skipping 18 matching lines...) Expand all
79 void detached() { 81 void detached() {
80 super.detached(); 82 super.detached();
81 _r.disable(notify: true); 83 _r.disable(notify: true);
82 children = []; 84 children = [];
83 } 85 }
84 86
85 RetainingPathElement _path; 87 RetainingPathElement _path;
86 InboundReferencesElement _inbounds; 88 InboundReferencesElement _inbounds;
87 89
88 void render() { 90 void render() {
89 _path = _path ?? new RetainingPathElement(_isolate, _object, 91 _path = _path ??
90 _retainingPaths, _instances, 92 new RetainingPathElement(_isolate, _object, _retainingPaths, _instances,
91 queue: _r.queue); 93 queue: _r.queue);
92 _inbounds = _inbounds ?? new InboundReferencesElement(_isolate, _object, 94 _inbounds = _inbounds ??
93 _references, 95 new InboundReferencesElement(_isolate, _object, _references, _instances,
94 _instances, 96 queue: _r.queue);
95 queue: _r.queue);
96 children = [ 97 children = [
97 new DivElement()..classes = ['memberList'] 98 new DivElement()
99 ..classes = ['memberList']
98 ..children = [ 100 ..children = [
99 new DivElement()..classes = ['memberItem'] 101 new DivElement()
102 ..classes = ['memberItem']
100 ..children = [ 103 ..children = [
101 new DivElement()..classes = ['memberName'] 104 new DivElement()
105 ..classes = ['memberName']
102 ..text = 'Class ', 106 ..text = 'Class ',
103 new DivElement()..classes = ['memberValue'] 107 new DivElement()
108 ..classes = ['memberValue']
104 ..children = [ 109 ..children = [
105 _object.clazz == null 110 _object.clazz == null
106 ? (new SpanElement()..text = '...') 111 ? (new SpanElement()..text = '...')
107 : new ClassRefElement(_isolate, _object.clazz, 112 : new ClassRefElement(_isolate, _object.clazz,
108 queue: _r.queue) 113 queue: _r.queue)
109 ] 114 ]
110 ], 115 ],
111 new DivElement()..classes = ['memberItem'] 116 new DivElement()
117 ..classes = ['memberItem']
112 ..title = 'Space for this object in memory' 118 ..title = 'Space for this object in memory'
113 ..children = [ 119 ..children = [
114 new DivElement()..classes = ['memberName'] 120 new DivElement()
121 ..classes = ['memberName']
115 ..text = 'Shallow size ', 122 ..text = 'Shallow size ',
116 new DivElement()..classes = ['memberValue'] 123 new DivElement()
124 ..classes = ['memberValue']
117 ..text = Utils.formatSize(_object.size ?? 0) 125 ..text = Utils.formatSize(_object.size ?? 0)
118 ], 126 ],
119 new DivElement()..classes = ['memberItem'] 127 new DivElement()
128 ..classes = ['memberItem']
120 ..title = 'Space reachable from this object, ' 129 ..title = 'Space reachable from this object, '
121 'excluding class references' 130 'excluding class references'
122 ..children = [ 131 ..children = [
123 new DivElement()..classes = ['memberName'] 132 new DivElement()
133 ..classes = ['memberName']
124 ..text = 'Reachable size ', 134 ..text = 'Reachable size ',
125 new DivElement()..classes = ['memberValue'] 135 new DivElement()
136 ..classes = ['memberValue']
126 ..children = _createReachableSizeValue() 137 ..children = _createReachableSizeValue()
127 ], 138 ],
128 new DivElement()..classes = ['memberItem'] 139 new DivElement()
140 ..classes = ['memberItem']
129 ..title = 'Space that would be reclaimed if references to this ' 141 ..title = 'Space that would be reclaimed if references to this '
130 'object were replaced with null' 142 'object were replaced with null'
131 ..children = [ 143 ..children = [
132 new DivElement()..classes = ['memberName'] 144 new DivElement()
145 ..classes = ['memberName']
133 ..text = 'Retained size ', 146 ..text = 'Retained size ',
134 new DivElement()..classes = ['memberValue'] 147 new DivElement()
148 ..classes = ['memberValue']
135 ..children = _createRetainedSizeValue() 149 ..children = _createRetainedSizeValue()
136 ], 150 ],
137 new DivElement()..classes = ['memberItem'] 151 new DivElement()
152 ..classes = ['memberItem']
138 ..children = [ 153 ..children = [
139 new DivElement()..classes = ['memberName'] 154 new DivElement()
155 ..classes = ['memberName']
140 ..text = 'Retaining path ', 156 ..text = 'Retaining path ',
141 new DivElement()..classes = ['memberValue'] 157 new DivElement()
158 ..classes = ['memberValue']
142 ..children = [_path] 159 ..children = [_path]
143 ], 160 ],
144 new DivElement()..classes = ['memberItem'] 161 new DivElement()
162 ..classes = ['memberItem']
145 ..title = 'Objects which directly reference this object' 163 ..title = 'Objects which directly reference this object'
146 ..children = [ 164 ..children = [
147 new DivElement()..classes = ['memberName'] 165 new DivElement()
166 ..classes = ['memberName']
148 ..text = 'Inbound references ', 167 ..text = 'Inbound references ',
149 new DivElement()..classes = ['memberValue'] 168 new DivElement()
169 ..classes = ['memberValue']
150 ..children = [_inbounds] 170 ..children = [_inbounds]
151 ] 171 ]
152 ] 172 ]
153 ]; 173 ];
154 } 174 }
155 175
156 List<Element> _createReachableSizeValue() { 176 List<Element> _createReachableSizeValue() {
157 final content = <Element>[]; 177 final content = <Element>[];
158 if (_reachableSize != null) { 178 if (_reachableSize != null) {
159 if (_reachableSize.isSentinel) { 179 if (_reachableSize.isSentinel) {
160 content.add( 180 content.add(new SentinelValueElement(_reachableSize.asSentinel,
161 new SentinelValueElement(_reachableSize.asSentinel, queue: _r.queue) 181 queue: _r.queue));
162 );
163 } else { 182 } else {
164 content.add( 183 content.add(new SpanElement()
165 new SpanElement()..text = Utils.formatSize(int.parse( 184 ..text = Utils
166 _reachableSize.asValue.valueAsString)) 185 .formatSize(int.parse(_reachableSize.asValue.valueAsString)));
167 );
168 } 186 }
169 } else { 187 } else {
170 content.add( 188 content.add(new SpanElement()..text = '...');
171 new SpanElement()..text = '...'
172 );
173 } 189 }
174 final button = new ButtonElement()..classes = ['reachable_size'] 190 final button = new ButtonElement()
191 ..classes = ['reachable_size']
175 ..disabled = _loadingReachableBytes 192 ..disabled = _loadingReachableBytes
176 ..text = '↺'; 193 ..text = '↺';
177 button.onClick.listen((_) async { 194 button.onClick.listen((_) async {
178 button.disabled = true; 195 button.disabled = true;
179 _loadingReachableBytes = true; 196 _loadingReachableBytes = true;
180 _reachableSize = await _reachableSizes.get(_isolate, _object.id); 197 _reachableSize = await _reachableSizes.get(_isolate, _object.id);
181 _r.dirty(); 198 _r.dirty();
182 }); 199 });
183 content.add(button); 200 content.add(button);
184 return content; 201 return content;
185 } 202 }
186 203
187 List<Element> _createRetainedSizeValue() { 204 List<Element> _createRetainedSizeValue() {
188 final content = <Element>[]; 205 final content = <Element>[];
189 if (_retainedSize != null) { 206 if (_retainedSize != null) {
190 if (_retainedSize.isSentinel) { 207 if (_retainedSize.isSentinel) {
191 content.add( 208 content.add(new SentinelValueElement(_retainedSize.asSentinel,
192 new SentinelValueElement(_retainedSize.asSentinel, queue: _r.queue) 209 queue: _r.queue));
193 );
194 } else { 210 } else {
195 content.add( 211 content.add(new SpanElement()
196 new SpanElement()..text = Utils.formatSize(int.parse( 212 ..text =
197 _retainedSize.asValue.valueAsString)) 213 Utils.formatSize(int.parse(_retainedSize.asValue.valueAsString)));
198 );
199 } 214 }
200 } else { 215 } else {
201 content.add( 216 content.add(new SpanElement()..text = '...');
202 new SpanElement()..text = '...'
203 );
204 } 217 }
205 final button = new ButtonElement()..classes = ['retained_size'] 218 final button = new ButtonElement()
219 ..classes = ['retained_size']
206 ..disabled = _loadingRetainedBytes 220 ..disabled = _loadingRetainedBytes
207 ..text = '↺'; 221 ..text = '↺';
208 button.onClick.listen((_) async { 222 button.onClick.listen((_) async {
209 button.disabled = true; 223 button.disabled = true;
210 _loadingRetainedBytes = true; 224 _loadingRetainedBytes = true;
211 _retainedSize = await _retainedSizes.get(_isolate, _object.id); 225 _retainedSize = await _retainedSizes.get(_isolate, _object.id);
212 _r.dirty(); 226 _r.dirty();
213 }); 227 });
214 content.add(button); 228 content.add(button);
215 return content; 229 return content;
216 } 230 }
217 } 231 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/nav/vm_menu.dart ('k') | runtime/observatory/lib/src/elements/object_view.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698