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

Side by Side Diff: runtime/observatory/lib/src/elements/top_retaining_instances.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) 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/curly_block.dart'; 8 import 'package:observatory/src/elements/curly_block.dart';
9 import 'package:observatory/src/elements/instance_ref.dart'; 9 import 'package:observatory/src/elements/instance_ref.dart';
10 import 'package:observatory/src/elements/helpers/any_ref.dart'; 10 import 'package:observatory/src/elements/helpers/any_ref.dart';
11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
12 import 'package:observatory/src/elements/helpers/tag.dart'; 12 import 'package:observatory/src/elements/helpers/tag.dart';
13 import 'package:observatory/utils.dart'; 13 import 'package:observatory/utils.dart';
14 14
15 class TopRetainingInstancesElement extends HtmlElement implements Renderable { 15 class TopRetainingInstancesElement extends HtmlElement implements Renderable {
16 static const tag = const Tag<TopRetainingInstancesElement>( 16 static const tag = const Tag<TopRetainingInstancesElement>(
17 'top-retainig-instances', 17 'top-retainig-instances',
18 dependencies: const [ 18 dependencies: const [CurlyBlockElement.tag, InstanceRefElement.tag]);
19 CurlyBlockElement.tag,
20 InstanceRefElement.tag
21 ]);
22 19
23 RenderingScheduler<TopRetainingInstancesElement> _r; 20 RenderingScheduler<TopRetainingInstancesElement> _r;
24 21
25 Stream<RenderedEvent<TopRetainingInstancesElement>> get onRendered => 22 Stream<RenderedEvent<TopRetainingInstancesElement>> get onRendered =>
26 _r.onRendered; 23 _r.onRendered;
27 24
28 M.IsolateRef _isolate; 25 M.IsolateRef _isolate;
29 M.ClassRef _cls; 26 M.ClassRef _cls;
30 M.TopRetainingInstancesRepository _topRetainingInstances; 27 M.TopRetainingInstancesRepository _topRetainingInstances;
31 M.InstanceRepository _instances; 28 M.InstanceRepository _instances;
32 Iterable<M.RetainingObject> _topRetaining; 29 Iterable<M.RetainingObject> _topRetaining;
33 bool _expanded = false; 30 bool _expanded = false;
34 31
35 M.IsolateRef get isolate => _isolate; 32 M.IsolateRef get isolate => _isolate;
36 M.ClassRef get cls => _cls; 33 M.ClassRef get cls => _cls;
37 34
38 factory TopRetainingInstancesElement(M.IsolateRef isolate, M.ClassRef cls, 35 factory TopRetainingInstancesElement(
36 M.IsolateRef isolate,
37 M.ClassRef cls,
39 M.TopRetainingInstancesRepository topRetainingInstances, 38 M.TopRetainingInstancesRepository topRetainingInstances,
40 M.InstanceRepository instances, 39 M.InstanceRepository instances,
41 {RenderingQueue queue}) { 40 {RenderingQueue queue}) {
42 assert(isolate != null); 41 assert(isolate != null);
43 assert(cls != null); 42 assert(cls != null);
44 assert(topRetainingInstances != null); 43 assert(topRetainingInstances != null);
45 assert(instances != null); 44 assert(instances != null);
46 TopRetainingInstancesElement e = document.createElement(tag.name); 45 TopRetainingInstancesElement e = document.createElement(tag.name);
47 e._r = new RenderingScheduler(e, queue: queue); 46 e._r = new RenderingScheduler(e, queue: queue);
48 e._isolate = isolate; 47 e._isolate = isolate;
(...skipping 15 matching lines...) Expand all
64 void detached() { 63 void detached() {
65 super.detached(); 64 super.detached();
66 children = []; 65 children = [];
67 _r.disable(notify: true); 66 _r.disable(notify: true);
68 } 67 }
69 68
70 void render() { 69 void render() {
71 children = [ 70 children = [
72 new CurlyBlockElement(expanded: _expanded, queue: _r.queue) 71 new CurlyBlockElement(expanded: _expanded, queue: _r.queue)
73 ..content = [ 72 ..content = [
74 new DivElement()..classes = ['memberList'] 73 new DivElement()
74 ..classes = ['memberList']
75 ..children = _createContent() 75 ..children = _createContent()
76 ] 76 ]
77 ..onToggle.listen((e) async { 77 ..onToggle.listen((e) async {
78 _expanded = e.control.expanded; 78 _expanded = e.control.expanded;
79 if (_expanded) { 79 if (_expanded) {
80 e.control.disabled = true; 80 e.control.disabled = true;
81 await _refresh(); 81 await _refresh();
82 e.control.disabled = false; 82 e.control.disabled = false;
83 } 83 }
84 }) 84 })
85 ]; 85 ];
86 } 86 }
87 87
88 Future _refresh() async { 88 Future _refresh() async {
89 _topRetaining = null; 89 _topRetaining = null;
90 _topRetaining = await _topRetainingInstances.get(_isolate, _cls); 90 _topRetaining = await _topRetainingInstances.get(_isolate, _cls);
91 _r.dirty(); 91 _r.dirty();
92 } 92 }
93 93
94 List<Element> _createContent() { 94 List<Element> _createContent() {
95 if (_topRetaining == null) { 95 if (_topRetaining == null) {
96 return [ 96 return [new SpanElement()..text = 'Loading...'];
97 new SpanElement()..text = 'Loading...'
98 ];
99 } 97 }
100 return _topRetaining.map((r) => 98 return _topRetaining
101 new DivElement()..classes = ['memberItem'] 99 .map((r) => new DivElement()
102 ..children = [ 100 ..classes = ['memberItem']
103 new DivElement()..classes = ['memberName'] 101 ..children = [
104 ..text = '${Utils.formatSize(r.retainedSize)} ', 102 new DivElement()
105 new DivElement()..classes = ['memberValue'] 103 ..classes = ['memberName']
106 ..children = [ 104 ..text = '${Utils.formatSize(r.retainedSize)} ',
107 anyRef(_isolate, r.object, _instances, queue: _r.queue) 105 new DivElement()
108 ] 106 ..classes = ['memberValue']
109 ] 107 ..children = [
110 ).toList(); 108 anyRef(_isolate, r.object, _instances, queue: _r.queue)
109 ]
110 ])
111 .toList();
111 } 112 }
112 } 113 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698