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

Side by Side Diff: runtime/observatory/lib/src/elements/strongly_reachable_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 13
14 class StronglyReachableInstancesElement extends HtmlElement 14 class StronglyReachableInstancesElement extends HtmlElement
15 implements Renderable { 15 implements Renderable {
16 static const tag = const Tag<StronglyReachableInstancesElement>( 16 static const tag = const Tag<StronglyReachableInstancesElement>(
17 'strongly-reachable-instances', 17 'strongly-reachable-instances',
18 dependencies: const [ 18 dependencies: const [CurlyBlockElement.tag, InstanceRefElement.tag]);
19 CurlyBlockElement.tag,
20 InstanceRefElement.tag
21 ]);
22 19
23 RenderingScheduler<StronglyReachableInstancesElement> _r; 20 RenderingScheduler<StronglyReachableInstancesElement> _r;
24 21
25 Stream<RenderedEvent<StronglyReachableInstancesElement>> get onRendered => 22 Stream<RenderedEvent<StronglyReachableInstancesElement>> 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.StronglyReachableInstancesRepository _stronglyReachableInstances; 27 M.StronglyReachableInstancesRepository _stronglyReachableInstances;
31 M.InstanceRepository _instances; 28 M.InstanceRepository _instances;
32 M.InstanceSet _result; 29 M.InstanceSet _result;
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 StronglyReachableInstancesElement(M.IsolateRef isolate, 35 factory StronglyReachableInstancesElement(
36 M.IsolateRef isolate,
39 M.ClassRef cls, 37 M.ClassRef cls,
40 M.StronglyReachableInstancesRepository stronglyReachable, 38 M.StronglyReachableInstancesRepository stronglyReachable,
41 M.InstanceRepository instances, 39 M.InstanceRepository instances,
42 {RenderingQueue queue}) { 40 {RenderingQueue queue}) {
43 assert(isolate != null); 41 assert(isolate != null);
44 assert(cls != null); 42 assert(cls != null);
45 assert(stronglyReachable != null); 43 assert(stronglyReachable != null);
46 assert(instances != null); 44 assert(instances != null);
47 StronglyReachableInstancesElement e = document.createElement(tag.name); 45 StronglyReachableInstancesElement e = document.createElement(tag.name);
48 e._r = new RenderingScheduler(e, queue: queue); 46 e._r = new RenderingScheduler(e, queue: queue);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 80 }
83 81
84 Future _refresh() async { 82 Future _refresh() async {
85 _result = null; 83 _result = null;
86 _result = await _stronglyReachableInstances.get(_isolate, _cls); 84 _result = await _stronglyReachableInstances.get(_isolate, _cls);
87 _r.dirty(); 85 _r.dirty();
88 } 86 }
89 87
90 List<Element> _createContent() { 88 List<Element> _createContent() {
91 if (_result == null) { 89 if (_result == null) {
92 return [ 90 return [new SpanElement()..text = 'Loading...'];
93 new SpanElement()..text = 'Loading...'
94 ];
95 } 91 }
96 final content = _result.samples.map((sample) => 92 final content = _result.samples
97 new DivElement() 93 .map((sample) => new DivElement()
98 ..children = [ 94 ..children = [anyRef(_isolate, sample, _instances, queue: _r.queue)])
99 anyRef(_isolate, sample, _instances, queue: _r.queue) 95 .toList();
100 ]
101 ).toList();
102 content.add(new DivElement() 96 content.add(new DivElement()
103 ..children = ([] 97 ..children = ([]
104 ..addAll(_createShowMoreButton()) 98 ..addAll(_createShowMoreButton())
105 ..add(new SpanElement()..text = ' of total ${_result.count}')) 99 ..add(new SpanElement()..text = ' of total ${_result.count}')));
106 );
107 return content; 100 return content;
108 } 101 }
109 102
110 List<Element> _createShowMoreButton() { 103 List<Element> _createShowMoreButton() {
111 final samples = _result.samples.toList(); 104 final samples = _result.samples.toList();
112 if (samples.length == _result.count) { 105 if (samples.length == _result.count) {
113 return []; 106 return [];
114 } 107 }
115 final count = samples.length; 108 final count = samples.length;
116 final button = new ButtonElement() 109 final button = new ButtonElement()..text = 'show next ${count}';
117 ..text = 'show next ${count}';
118 button.onClick.listen((_) async { 110 button.onClick.listen((_) async {
119 button.disabled = true; 111 button.disabled = true;
120 _result = await _stronglyReachableInstances.get(_isolate, _cls, 112 _result = await _stronglyReachableInstances.get(_isolate, _cls,
121 limit: count * 2); 113 limit: count * 2);
122 _r.dirty(); 114 _r.dirty();
123 }); 115 });
124 return [button]; 116 return [button];
125 } 117 }
126 } 118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698