OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /// This page is not directly reachable from the main Observatory ui. | 5 /// This page is not directly reachable from the main Observatory ui. |
6 /// It is mainly mented to be used from editors as an integrated tool. | 6 /// It is mainly mented to be used from editors as an integrated tool. |
7 /// | 7 /// |
8 /// This page mainly targeting developers and not VM experts, so concepts like | 8 /// This page mainly targeting developers and not VM experts, so concepts like |
9 /// old and new heap are abstracted away. | 9 /// old and new heap are abstracted away. |
10 /// | 10 /// |
(...skipping 15 matching lines...) Expand all Loading... |
26 import 'package:observatory/src/elements/helpers/tag.dart'; | 26 import 'package:observatory/src/elements/helpers/tag.dart'; |
27 import 'package:observatory/src/elements/nav/notify.dart'; | 27 import 'package:observatory/src/elements/nav/notify.dart'; |
28 import 'package:observatory/src/elements/memory/graph.dart'; | 28 import 'package:observatory/src/elements/memory/graph.dart'; |
29 import 'package:observatory/src/elements/memory/profile.dart'; | 29 import 'package:observatory/src/elements/memory/profile.dart'; |
30 | 30 |
31 class MemoryDashboardElement extends HtmlElement implements Renderable { | 31 class MemoryDashboardElement extends HtmlElement implements Renderable { |
32 static const tag = const Tag<MemoryDashboardElement>('memory-dashboard', | 32 static const tag = const Tag<MemoryDashboardElement>('memory-dashboard', |
33 dependencies: const [ | 33 dependencies: const [ |
34 NavNotifyElement.tag, | 34 NavNotifyElement.tag, |
35 MemoryGraphElement.tag, | 35 MemoryGraphElement.tag, |
36 MemoryProfileElement.tag | 36 MemoryProfileElement.tag, |
37 ]); | 37 ]); |
38 | 38 |
39 RenderingScheduler<MemoryDashboardElement> _r; | 39 RenderingScheduler<MemoryDashboardElement> _r; |
40 | 40 |
41 Stream<RenderedEvent<MemoryDashboardElement>> get onRendered => _r.onRendered; | 41 Stream<RenderedEvent<MemoryDashboardElement>> get onRendered => _r.onRendered; |
42 | 42 |
43 M.VMRef _vm; | 43 M.VMRef _vm; |
44 M.VMRepository _vms; | 44 M.VMRepository _vms; |
45 M.IsolateRepository _isolates; | 45 M.IsolateRepository _isolates; |
46 M.EditorRepository _editor; | 46 M.EditorRepository _editor; |
47 M.AllocationProfileRepository _allocations; | 47 M.AllocationProfileRepository _allocations; |
| 48 M.HeapSnapshotRepository _snapshots; |
| 49 M.ObjectRepository _objects; |
48 M.EventRepository _events; | 50 M.EventRepository _events; |
49 M.NotificationRepository _notifications; | 51 M.NotificationRepository _notifications; |
50 | 52 |
51 M.VMRef get vm => _vm; | 53 M.VMRef get vm => _vm; |
52 M.NotificationRepository get notifications => _notifications; | 54 M.NotificationRepository get notifications => _notifications; |
53 | 55 |
54 factory MemoryDashboardElement( | 56 factory MemoryDashboardElement( |
55 M.VMRef vm, | 57 M.VMRef vm, |
56 M.VMRepository vms, | 58 M.VMRepository vms, |
57 M.IsolateRepository isolates, | 59 M.IsolateRepository isolates, |
58 M.EditorRepository editor, | 60 M.EditorRepository editor, |
59 M.AllocationProfileRepository allocations, | 61 M.AllocationProfileRepository allocations, |
| 62 M.HeapSnapshotRepository snapshots, |
| 63 M.ObjectRepository objects, |
60 M.EventRepository events, | 64 M.EventRepository events, |
61 M.NotificationRepository notifications, | 65 M.NotificationRepository notifications, |
62 {RenderingQueue queue}) { | 66 {RenderingQueue queue}) { |
63 assert(vm != null); | 67 assert(vm != null); |
64 assert(vms != null); | 68 assert(vms != null); |
65 assert(isolates != null); | 69 assert(isolates != null); |
66 assert(editor != null); | 70 assert(editor != null); |
67 assert(allocations != null); | 71 assert(allocations != null); |
68 assert(events != null); | 72 assert(events != null); |
69 assert(notifications != null); | 73 assert(notifications != null); |
70 MemoryDashboardElement e = document.createElement(tag.name); | 74 MemoryDashboardElement e = document.createElement(tag.name); |
71 e._r = new RenderingScheduler(e, queue: queue); | 75 e._r = new RenderingScheduler(e, queue: queue); |
72 e._vm = vm; | 76 e._vm = vm; |
73 e._vms = vms; | 77 e._vms = vms; |
74 e._isolates = isolates; | 78 e._isolates = isolates; |
75 e._editor = editor; | 79 e._editor = editor; |
76 e._allocations = allocations; | 80 e._allocations = allocations; |
| 81 e._snapshots = snapshots; |
| 82 e._objects = objects; |
77 e._events = events; | 83 e._events = events; |
78 e._notifications = notifications; | 84 e._notifications = notifications; |
79 return e; | 85 return e; |
80 } | 86 } |
81 | 87 |
82 MemoryDashboardElement.created() : super.created(); | 88 MemoryDashboardElement.created() : super.created(); |
83 | 89 |
84 @override | 90 @override |
85 attached() { | 91 attached() { |
86 super.attached(); | 92 super.attached(); |
(...skipping 26 matching lines...) Expand all Loading... |
113 new HRElement(), | 119 new HRElement(), |
114 _graph, | 120 _graph, |
115 new HRElement(), | 121 new HRElement(), |
116 ], | 122 ], |
117 ]; | 123 ]; |
118 if (_isolate == null) { | 124 if (_isolate == null) { |
119 children.add(new DivElement() | 125 children.add(new DivElement() |
120 ..classes = ['content-centered-big'] | 126 ..classes = ['content-centered-big'] |
121 ..children = [new HeadingElement.h1()..text = "No isolate selected"]); | 127 ..children = [new HeadingElement.h1()..text = "No isolate selected"]); |
122 } else { | 128 } else { |
123 final MemoryProfileElement profile = | 129 children.add(new MemoryProfileElement( |
124 new MemoryProfileElement(_isolate, _editor, _events, _allocations); | 130 _isolate, _editor, _events, _allocations, _snapshots, _objects)); |
125 final ButtonElement reload = new ButtonElement(); | |
126 final ButtonElement gc = new ButtonElement(); | |
127 children.addAll([ | |
128 new DivElement() | |
129 ..classes = ['content-centered-big'] | |
130 ..children = [ | |
131 new HeadingElement.h1() | |
132 ..children = [ | |
133 new Text("Isolate ${_isolate.name}"), | |
134 reload | |
135 ..classes = ['link', 'big'] | |
136 ..text = ' ↺ ' | |
137 ..title = 'Refresh' | |
138 ..onClick.listen((e) async { | |
139 gc.disabled = true; | |
140 reload.disabled = true; | |
141 await profile.reload(); | |
142 gc.disabled = false; | |
143 reload.disabled = false; | |
144 }), | |
145 gc | |
146 ..classes = ['link', 'big'] | |
147 ..text = ' ♺ ' | |
148 ..title = 'Collect Garbage' | |
149 ..onClick.listen((e) async { | |
150 gc.disabled = true; | |
151 reload.disabled = true; | |
152 await profile.reload(gc: true); | |
153 gc.disabled = false; | |
154 reload.disabled = false; | |
155 }), | |
156 ] | |
157 ], | |
158 profile | |
159 ]); | |
160 } | 131 } |
161 } | 132 } |
162 | 133 |
163 void _onIsolateSelected(IsolateSelectedEvent e) { | 134 void _onIsolateSelected(IsolateSelectedEvent e) { |
164 _r.checkAndReact(_isolate, e.isolate); | 135 _isolate = _r.checkAndReact(_isolate, e.isolate); |
165 _isolate = e.isolate; | |
166 } | 136 } |
167 } | 137 } |
OLD | NEW |