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

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

Issue 2294073003: Converted Observatory class-view element (Closed)
Patch Set: Addressed comments 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:html';
6 import 'dart:async';
7 import 'package:observatory/models.dart' as M;
8 import 'package:observatory/src/elements/curly_block.dart';
9 import 'package:observatory/src/elements/instance_ref.dart';
10 import 'package:observatory/src/elements/helpers/any_ref.dart';
11 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
12 import 'package:observatory/src/elements/helpers/tag.dart';
13 import 'package:observatory/utils.dart';
14
15 class TopRetainingInstancesElement extends HtmlElement implements Renderable {
16 static const tag = const Tag<TopRetainingInstancesElement>(
17 'top-retainig-instances',
18 dependencies: const [
19 CurlyBlockElement.tag,
20 InstanceRefElement.tag
21 ]);
22
23 RenderingScheduler<TopRetainingInstancesElement> _r;
24
25 Stream<RenderedEvent<TopRetainingInstancesElement>> get onRendered =>
26 _r.onRendered;
27
28 M.IsolateRef _isolate;
29 M.ClassRef _cls;
30 M.TopRetainingInstancesRepository _topRetainingInstances;
31 M.InstanceRepository _instances;
32 Iterable<M.RetainingObject> _topRetaining;
33 bool _expanded = false;
34
35 M.IsolateRef get isolate => _isolate;
36 M.ClassRef get cls => _cls;
37
38 factory TopRetainingInstancesElement(M.IsolateRef isolate, M.ClassRef cls,
39 M.TopRetainingInstancesRepository topRetainingInstances,
40 M.InstanceRepository instances,
41 {RenderingQueue queue}) {
42 assert(isolate != null);
43 assert(cls != null);
44 assert(topRetainingInstances != null);
45 assert(instances != null);
46 TopRetainingInstancesElement e = document.createElement(tag.name);
47 e._r = new RenderingScheduler(e, queue: queue);
48 e._isolate = isolate;
49 e._cls = cls;
50 e._topRetainingInstances = topRetainingInstances;
51 e._instances = instances;
52 return e;
53 }
54
55 TopRetainingInstancesElement.created() : super.created();
56
57 @override
58 void attached() {
59 super.attached();
60 _r.enable();
61 }
62
63 @override
64 void detached() {
65 super.detached();
66 children = [];
67 _r.disable(notify: true);
68 }
69
70 void render() {
71 children = [
72 new CurlyBlockElement(expanded: _expanded, queue: _r.queue)
73 ..children = [
74 new DivElement()..classes = ['memberList']
75 ..children = _createContent()
76 ]
77 ..onToggle.listen((e) async {
78 _expanded = e.control.expanded;
79 if (_expanded) {
80 e.control.disabled = true;
81 await _refresh();
82 e.control.disabled = false;
83 }
84 })
85 ];
86 }
87
88 Future _refresh() async {
89 _topRetaining = null;
90 _topRetaining = await _topRetainingInstances.get(_isolate, _cls);
91 _r.dirty();
92 }
93
94 List<Element> _createContent() {
95 if (_topRetaining == null) {
96 return [
97 new SpanElement()..text = 'Loading...'
98 ];
99 }
100 return _topRetaining.map((r) =>
101 new DivElement()..classes = ['memberItem']
102 ..children = [
103 new DivElement()..classes = ['memberName']
104 ..text = '${Utils.formatSize(r.retainedSize)} ',
105 new DivElement()..classes = ['memberValue']
106 ..children = [
107 anyRef(_isolate, r.object, _instances, queue: _r.queue)
108 ]
109 ]
110 ).toList();
111 }
112 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698