OLD | NEW |
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 library vm_view_element; | 5 library vm_view_element; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:html'; | 8 import 'dart:html'; |
9 import 'package:observatory/models.dart' as M; | 9 import 'package:observatory/models.dart' as M; |
10 import 'package:observatory/src/elements/helpers/nav_bar.dart'; | 10 import 'package:observatory/src/elements/helpers/nav_bar.dart'; |
(...skipping 16 matching lines...) Expand all Loading... |
27 NavRefreshElement.tag, | 27 NavRefreshElement.tag, |
28 NavNotifyElement.tag, | 28 NavNotifyElement.tag, |
29 ViewFooterElement.tag | 29 ViewFooterElement.tag |
30 ]); | 30 ]); |
31 | 31 |
32 RenderingScheduler<VMViewElement> _r; | 32 RenderingScheduler<VMViewElement> _r; |
33 | 33 |
34 Stream<RenderedEvent<VMViewElement>> get onRendered => _r.onRendered; | 34 Stream<RenderedEvent<VMViewElement>> get onRendered => _r.onRendered; |
35 | 35 |
36 M.VM _vm; | 36 M.VM _vm; |
| 37 M.VMRepository _vms; |
37 M.EventRepository _events; | 38 M.EventRepository _events; |
38 M.NotificationRepository _notifications; | 39 M.NotificationRepository _notifications; |
39 M.IsolateRepository _isolates; | 40 M.IsolateRepository _isolates; |
40 M.ScriptRepository _scripts; | 41 M.ScriptRepository _scripts; |
41 StreamSubscription _vmSubscription; | 42 StreamSubscription _vmSubscription; |
42 StreamSubscription _startSubscription; | 43 StreamSubscription _startSubscription; |
43 StreamSubscription _exitSubscription; | 44 StreamSubscription _exitSubscription; |
44 | 45 |
45 M.VMRef get vm => _vm; | 46 M.VMRef get vm => _vm; |
46 M.NotificationRepository get notifications => _notifications; | 47 M.NotificationRepository get notifications => _notifications; |
47 | 48 |
48 factory VMViewElement( | 49 factory VMViewElement( |
49 M.VM vm, | 50 M.VM vm, |
| 51 M.VMRepository vms, |
50 M.EventRepository events, | 52 M.EventRepository events, |
51 M.NotificationRepository notifications, | 53 M.NotificationRepository notifications, |
52 M.IsolateRepository isolates, | 54 M.IsolateRepository isolates, |
53 M.ScriptRepository scripts, | 55 M.ScriptRepository scripts, |
54 {RenderingQueue queue}) { | 56 {RenderingQueue queue}) { |
55 assert(vm != null); | 57 assert(vm != null); |
| 58 assert(vms != null); |
56 assert(events != null); | 59 assert(events != null); |
57 assert(notifications != null); | 60 assert(notifications != null); |
| 61 assert(isolates != null); |
| 62 assert(scripts != null); |
58 VMViewElement e = document.createElement(tag.name); | 63 VMViewElement e = document.createElement(tag.name); |
59 e._r = new RenderingScheduler(e, queue: queue); | 64 e._r = new RenderingScheduler(e, queue: queue); |
60 e._vm = vm; | 65 e._vm = vm; |
| 66 e._vms = vms; |
61 e._events = events; | 67 e._events = events; |
62 e._notifications = notifications; | 68 e._notifications = notifications; |
63 e._isolates = isolates; | 69 e._isolates = isolates; |
64 e._scripts = scripts; | 70 e._scripts = scripts; |
65 return e; | 71 return e; |
66 } | 72 } |
67 | 73 |
68 VMViewElement.created() : super.created(); | 74 VMViewElement.created() : super.created(); |
69 | 75 |
70 @override | 76 @override |
(...skipping 21 matching lines...) Expand all Loading... |
92 void render() { | 98 void render() { |
93 final uptime = new DateTime.now().difference(_vm.startTime); | 99 final uptime = new DateTime.now().difference(_vm.startTime); |
94 final isolates = _vm.isolates.toList(); | 100 final isolates = _vm.isolates.toList(); |
95 children = [ | 101 children = [ |
96 navBar([ | 102 navBar([ |
97 new NavTopMenuElement(queue: _r.queue), | 103 new NavTopMenuElement(queue: _r.queue), |
98 new NavVMMenuElement(_vm, _events, queue: _r.queue), | 104 new NavVMMenuElement(_vm, _events, queue: _r.queue), |
99 new NavRefreshElement(queue: _r.queue) | 105 new NavRefreshElement(queue: _r.queue) |
100 ..onRefresh.listen((e) async { | 106 ..onRefresh.listen((e) async { |
101 e.element.disabled = true; | 107 e.element.disabled = true; |
| 108 _vm = await _vms.get(_vm); |
102 _r.dirty(); | 109 _r.dirty(); |
103 }), | 110 }), |
104 new NavNotifyElement(_notifications, queue: _r.queue) | 111 new NavNotifyElement(_notifications, queue: _r.queue) |
105 ]), | 112 ]), |
106 new DivElement() | 113 new DivElement() |
107 ..classes = ['content-centered-big'] | 114 ..classes = ['content-centered-big'] |
108 ..children = [ | 115 ..children = <HtmlElement>[ |
109 new HeadingElement.h1()..text = 'VM', | 116 new HeadingElement.h1()..text = 'VM', |
110 new HRElement(), | 117 new HRElement(), |
111 new DivElement() | 118 new DivElement() |
112 ..classes = ['memberList'] | 119 ..classes = ['memberList'] |
113 ..children = [ | 120 ..children = [ |
114 new DivElement() | 121 new DivElement() |
115 ..classes = ['memberItem'] | 122 ..classes = ['memberItem'] |
116 ..children = [ | 123 ..children = [ |
117 new DivElement() | 124 new DivElement() |
118 ..classes = ['memberName'] | 125 ..classes = ['memberName'] |
119 ..text = 'name', | 126 ..text = 'name', |
120 new DivElement() | 127 new DivElement() |
121 ..classes = ['memberValue'] | 128 ..classes = ['memberValue'] |
122 ..text = _vm.displayName | 129 ..text = _vm.displayName |
123 ], | 130 ], |
124 new DivElement() | 131 new DivElement() |
125 ..classes = ['memberItem'] | 132 ..classes = ['memberItem'] |
126 ..children = [ | 133 ..children = [ |
127 new DivElement() | 134 new DivElement() |
128 ..classes = ['memberName'] | 135 ..classes = ['memberName'] |
129 ..text = 'version', | 136 ..text = 'version', |
130 new DivElement() | 137 new DivElement() |
131 ..classes = ['memberValue'] | 138 ..classes = ['memberValue'] |
132 ..text = _vm.version | 139 ..text = _vm.version |
133 ], | 140 ], |
134 new DivElement() | 141 new DivElement() |
135 ..classes = ['memberItem'] | 142 ..classes = ['memberItem'] |
136 ..children = [ | 143 ..children = [ |
| 144 new DivElement() |
| 145 ..classes = ['memberName'] |
| 146 ..text = 'embedder', |
| 147 new DivElement() |
| 148 ..classes = ['memberValue'] |
| 149 ..text = _vm.embedder ?? "UNKNOWN" |
| 150 ], |
| 151 new DivElement() |
| 152 ..classes = ['memberItem'] |
| 153 ..children = [ |
137 new DivElement() | 154 new DivElement() |
138 ..classes = ['memberName'] | 155 ..classes = ['memberName'] |
139 ..text = 'started at', | 156 ..text = 'started at', |
140 new DivElement() | 157 new DivElement() |
141 ..classes = ['memberValue'] | 158 ..classes = ['memberValue'] |
142 ..text = '${_vm.startTime}' | 159 ..text = '${_vm.startTime}' |
143 ], | 160 ], |
144 new DivElement() | 161 new DivElement() |
145 ..classes = ['memberItem'] | 162 ..classes = ['memberItem'] |
146 ..children = [ | 163 ..children = [ |
(...skipping 25 matching lines...) Expand all Loading... |
172 ..text = '${_vm.pid}' | 189 ..text = '${_vm.pid}' |
173 ], | 190 ], |
174 new DivElement() | 191 new DivElement() |
175 ..classes = ['memberItem'] | 192 ..classes = ['memberItem'] |
176 ..children = [ | 193 ..children = [ |
177 new DivElement() | 194 new DivElement() |
178 ..classes = ['memberName'] | 195 ..classes = ['memberName'] |
179 ..text = 'peak memory', | 196 ..text = 'peak memory', |
180 new DivElement() | 197 new DivElement() |
181 ..classes = ['memberValue'] | 198 ..classes = ['memberValue'] |
182 ..text = Utils.formatSize(_vm.maxRSS) | 199 ..text = _vm.maxRSS != null |
| 200 ? Utils.formatSize(_vm.maxRSS) |
| 201 : "unavailable" |
183 ], | 202 ], |
184 new DivElement() | 203 new DivElement() |
185 ..classes = ['memberItem'] | 204 ..classes = ['memberItem'] |
| 205 ..children = [ |
| 206 new DivElement() |
| 207 ..classes = ['memberName'] |
| 208 ..text = 'current memory', |
| 209 new DivElement() |
| 210 ..classes = ['memberValue'] |
| 211 ..text = _vm.currentRSS != null |
| 212 ? Utils.formatSize(_vm.currentRSS) |
| 213 : "unavailable" |
| 214 ], |
| 215 new DivElement() |
| 216 ..classes = ['memberItem'] |
186 ..children = [ | 217 ..children = [ |
187 new DivElement() | 218 new DivElement() |
188 ..classes = ['memberName'] | 219 ..classes = ['memberName'] |
189 ..text = 'native zone memory', | 220 ..text = 'native zone memory', |
190 new DivElement() | 221 new DivElement() |
191 ..classes = ['memberValue'] | 222 ..classes = ['memberValue'] |
192 ..text = Utils.formatSize(_vm.nativeZoneMemoryUsage) | 223 ..text = Utils.formatSize(_vm.nativeZoneMemoryUsage) |
193 ..title = '${_vm.nativeZoneMemoryUsage} bytes' | 224 ..title = '${_vm.nativeZoneMemoryUsage} bytes' |
194 ], | 225 ], |
195 new DivElement() | 226 new DivElement() |
196 ..classes = ['memberItem'] | 227 ..classes = ['memberItem'] |
197 ..children = [ | 228 ..children = [ |
198 new DivElement() | 229 new DivElement() |
199 ..classes = ['memberName'] | 230 ..classes = ['memberName'] |
200 ..text = 'native heap memory', | 231 ..text = 'native heap memory', |
201 new DivElement() | 232 new DivElement() |
202 ..classes = ['memberValue'] | 233 ..classes = ['memberValue'] |
203 ..text = Utils.formatSize(_vm.heapAllocatedMemoryUsage) | 234 ..text = _vm.heapAllocatedMemoryUsage != null |
204 ..title = '${_vm.heapAllocatedMemoryUsage} bytes' | 235 ? Utils.formatSize(_vm.heapAllocatedMemoryUsage) |
| 236 : 'unavailable' |
| 237 ..title = _vm.heapAllocatedMemoryUsage != null |
| 238 ? '${_vm.heapAllocatedMemoryUsage} bytes' |
| 239 : null |
205 ], | 240 ], |
206 new DivElement() | 241 new DivElement() |
207 ..classes = ['memberItem'] | 242 ..classes = ['memberItem'] |
208 ..children = [ | 243 ..children = [ |
209 new DivElement() | 244 new DivElement() |
210 ..classes = ['memberName'] | 245 ..classes = ['memberName'] |
211 ..text = 'native heap allocation count', | 246 ..text = 'native heap allocation count', |
212 new DivElement() | 247 new DivElement() |
213 ..classes = ['memberValue'] | 248 ..classes = ['memberValue'] |
214 ..text = '${_vm.heapAllocationCount}' | 249 ..text = _vm.heapAllocationCount != null |
| 250 ? '${_vm.heapAllocationCount}' |
| 251 : 'unavailable' |
215 ], | 252 ], |
216 new BRElement(), | 253 new BRElement(), |
217 new DivElement() | 254 new DivElement() |
218 ..classes = ['memberItem'] | 255 ..classes = ['memberItem'] |
219 ..children = [ | 256 ..children = [ |
220 new DivElement() | 257 new DivElement() |
221 ..classes = ['memberName'] | 258 ..classes = ['memberName'] |
222 ..children = [ | 259 ..children = [ |
223 new SpanElement()..text = 'see ', | 260 new SpanElement()..text = 'see ', |
224 new AnchorElement(href: Uris.flags())..text = 'flags' | 261 new AnchorElement(href: Uris.flags())..text = 'flags' |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 queue: _r.queue) | 295 queue: _r.queue) |
259 ], | 296 ], |
260 new HRElement() | 297 new HRElement() |
261 ]) | 298 ]) |
262 .toList(), | 299 .toList(), |
263 new ViewFooterElement(queue: _r.queue) | 300 new ViewFooterElement(queue: _r.queue) |
264 ] | 301 ] |
265 ]; | 302 ]; |
266 } | 303 } |
267 } | 304 } |
OLD | NEW |