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 isolate_view_element; | 5 library isolate_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/curly_block.dart'; | 10 import 'package:observatory/src/elements/curly_block.dart'; |
(...skipping 11 matching lines...) Expand all Loading... |
22 import 'package:observatory/src/elements/nav/isolate_menu.dart'; | 22 import 'package:observatory/src/elements/nav/isolate_menu.dart'; |
23 import 'package:observatory/src/elements/nav/notify.dart'; | 23 import 'package:observatory/src/elements/nav/notify.dart'; |
24 import 'package:observatory/src/elements/nav/refresh.dart'; | 24 import 'package:observatory/src/elements/nav/refresh.dart'; |
25 import 'package:observatory/src/elements/nav/top_menu.dart'; | 25 import 'package:observatory/src/elements/nav/top_menu.dart'; |
26 import 'package:observatory/src/elements/nav/vm_menu.dart'; | 26 import 'package:observatory/src/elements/nav/vm_menu.dart'; |
27 import 'package:observatory/src/elements/script_inset.dart'; | 27 import 'package:observatory/src/elements/script_inset.dart'; |
28 import 'package:observatory/src/elements/source_inset.dart'; | 28 import 'package:observatory/src/elements/source_inset.dart'; |
29 import 'package:observatory/src/elements/view_footer.dart'; | 29 import 'package:observatory/src/elements/view_footer.dart'; |
30 | 30 |
31 class IsolateViewElement extends HtmlElement implements Renderable { | 31 class IsolateViewElement extends HtmlElement implements Renderable { |
32 static const tag = const Tag<IsolateViewElement>('isolate-view', | 32 static const tag = |
33 dependencies: const [ | 33 const Tag<IsolateViewElement>('isolate-view', dependencies: const [ |
34 CurlyBlockElement.tag, | 34 CurlyBlockElement.tag, |
35 EvalBoxElement.tag, | 35 EvalBoxElement.tag, |
36 FunctionRefElement.tag, | 36 FunctionRefElement.tag, |
37 IsolateLocationElement.tag, | 37 IsolateLocationElement.tag, |
38 IsolateRunStateElement.tag, | 38 IsolateRunStateElement.tag, |
39 IsolateSharedSummaryElement.tag, | 39 IsolateSharedSummaryElement.tag, |
40 LibraryRefElement.tag, | 40 LibraryRefElement.tag, |
41 NavClassMenuElement.tag, | 41 NavClassMenuElement.tag, |
42 NavTopMenuElement.tag, | 42 NavTopMenuElement.tag, |
43 NavIsolateMenuElement.tag, | 43 NavIsolateMenuElement.tag, |
44 NavRefreshElement.tag, | 44 NavRefreshElement.tag, |
45 NavNotifyElement.tag, | 45 NavNotifyElement.tag, |
46 ScriptInsetElement.tag, | 46 ScriptInsetElement.tag, |
47 SourceInsetElement.tag, | 47 SourceInsetElement.tag, |
48 ViewFooterElement.tag | 48 ViewFooterElement.tag |
49 ]); | 49 ]); |
50 | 50 |
51 RenderingScheduler<IsolateViewElement> _r; | 51 RenderingScheduler<IsolateViewElement> _r; |
52 | 52 |
53 Stream<RenderedEvent<IsolateViewElement>> get onRendered => _r.onRendered; | 53 Stream<RenderedEvent<IsolateViewElement>> get onRendered => _r.onRendered; |
54 | 54 |
55 M.VM _vm; | 55 M.VM _vm; |
56 M.Isolate _isolate; | 56 M.Isolate _isolate; |
57 M.EventRepository _events; | 57 M.EventRepository _events; |
58 M.NotificationRepository _notifications; | 58 M.NotificationRepository _notifications; |
59 M.IsolateRepository _isolates; | 59 M.IsolateRepository _isolates; |
60 M.ScriptRepository _scripts; | 60 M.ScriptRepository _scripts; |
61 M.FunctionRepository _functions; | 61 M.FunctionRepository _functions; |
62 M.LibraryRepository _libraries; | 62 M.LibraryRepository _libraries; |
63 M.InstanceRepository _instances; | 63 M.InstanceRepository _instances; |
64 M.EvalRepository _eval; | 64 M.EvalRepository _eval; |
65 M.Function _function; | 65 M.Function _function; |
66 M.ScriptRef _rootScript; | 66 M.ScriptRef _rootScript; |
67 StreamSubscription _subscription; | 67 StreamSubscription _subscription; |
68 | 68 |
69 M.VMRef get vm => _vm; | 69 M.VMRef get vm => _vm; |
70 M.Isolate get isolate => _isolate; | 70 M.Isolate get isolate => _isolate; |
71 M.NotificationRepository get notifications => _notifications; | 71 M.NotificationRepository get notifications => _notifications; |
72 | 72 |
73 factory IsolateViewElement(M.VM vm, M.Isolate isolate, | 73 factory IsolateViewElement( |
74 M.EventRepository events, | 74 M.VM vm, |
75 M.NotificationRepository notifications, | 75 M.Isolate isolate, |
76 M.IsolateRepository isolates, | 76 M.EventRepository events, |
77 M.ScriptRepository scripts, | 77 M.NotificationRepository notifications, |
78 M.FunctionRepository functions, | 78 M.IsolateRepository isolates, |
79 M.LibraryRepository libraries, | 79 M.ScriptRepository scripts, |
80 M.InstanceRepository instances, | 80 M.FunctionRepository functions, |
81 M.EvalRepository eval, | 81 M.LibraryRepository libraries, |
82 {RenderingQueue queue}) { | 82 M.InstanceRepository instances, |
| 83 M.EvalRepository eval, |
| 84 {RenderingQueue queue}) { |
83 assert(vm != null); | 85 assert(vm != null); |
84 assert(isolate != null); | 86 assert(isolate != null); |
85 assert(events != null); | 87 assert(events != null); |
86 assert(notifications != null); | 88 assert(notifications != null); |
87 assert(isolates != null); | 89 assert(isolates != null); |
88 assert(scripts != null); | 90 assert(scripts != null); |
89 assert(functions != null); | 91 assert(functions != null); |
90 assert(instances != null); | 92 assert(instances != null); |
91 assert(eval != null); | 93 assert(eval != null); |
92 assert(libraries != null); | 94 assert(libraries != null); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 _subscription.cancel(); | 130 _subscription.cancel(); |
129 } | 131 } |
130 | 132 |
131 void render() { | 133 void render() { |
132 final uptime = new DateTime.now().difference(_isolate.startTime); | 134 final uptime = new DateTime.now().difference(_isolate.startTime); |
133 final libraries = _isolate.libraries.toList(); | 135 final libraries = _isolate.libraries.toList(); |
134 children = [ | 136 children = [ |
135 navBar([ | 137 navBar([ |
136 new NavTopMenuElement(queue: _r.queue), | 138 new NavTopMenuElement(queue: _r.queue), |
137 new NavVMMenuElement(_vm, _events, queue: _r.queue), | 139 new NavVMMenuElement(_vm, _events, queue: _r.queue), |
138 new NavIsolateMenuElement(_isolate, _events, | 140 new NavIsolateMenuElement(_isolate, _events, queue: _r.queue), |
139 queue: _r.queue), | |
140 new NavRefreshElement(label: 'reload source', queue: _r.queue) | 141 new NavRefreshElement(label: 'reload source', queue: _r.queue) |
141 ..onRefresh.listen((e) async { | 142 ..onRefresh.listen((e) async { |
142 e.element.disabled = true; | 143 e.element.disabled = true; |
143 await _isolates.reloadSources(_isolate); | 144 await _isolates.reloadSources(_isolate); |
144 _r.dirty(); | 145 _r.dirty(); |
145 }), | 146 }), |
146 new NavRefreshElement(queue: _r.queue) | 147 new NavRefreshElement(queue: _r.queue) |
147 ..onRefresh.listen((e) async { | 148 ..onRefresh.listen((e) async { |
148 e.element.disabled = true; | 149 e.element.disabled = true; |
149 _isolate = await _isolates.get(_isolate); | 150 _isolate = await _isolates.get(_isolate); |
150 await _loadExtraData(); | 151 await _loadExtraData(); |
151 _r.dirty(); | 152 _r.dirty(); |
152 }), | 153 }), |
153 new NavNotifyElement(_notifications, queue: _r.queue) | 154 new NavNotifyElement(_notifications, queue: _r.queue) |
154 ]), | 155 ]), |
155 new DivElement()..classes = ['content-centered-big'] | 156 new DivElement() |
| 157 ..classes = ['content-centered-big'] |
156 ..children = [ | 158 ..children = [ |
157 new HeadingElement.h2()..text = 'Isolate ${_isolate.name}', | 159 new HeadingElement.h2()..text = 'Isolate ${_isolate.name}', |
158 new BRElement(), | 160 new BRElement(), |
159 new DivElement()..classes = ['flex-row'] | 161 new DivElement() |
| 162 ..classes = ['flex-row'] |
160 ..children = [ | 163 ..children = [ |
161 new DivElement()..style.flex = '1', | 164 new DivElement()..style.flex = '1', |
162 new DivElement() | 165 new DivElement() |
163 ..children = [ | 166 ..children = [ |
164 new IsolateRunStateElement(_isolate, _events, queue: _r.queue)
, | 167 new IsolateRunStateElement(_isolate, _events, |
| 168 queue: _r.queue), |
165 new IsolateLocationElement(_isolate, _events, _scripts, | 169 new IsolateLocationElement(_isolate, _events, _scripts, |
166 queue: _r.queue), | 170 queue: _r.queue), |
167 new SpanElement()..text = ' [', | 171 new SpanElement()..text = ' [', |
168 new AnchorElement(href: Uris.debugger(_isolate)) | 172 new AnchorElement(href: Uris.debugger(_isolate)) |
169 ..text = 'debug', | 173 ..text = 'debug', |
170 new SpanElement()..text = ']' | 174 new SpanElement()..text = ']' |
171 ] | 175 ] |
172 ], | 176 ], |
173 new DivElement() | 177 new DivElement() |
174 ..children = _function != null | 178 ..children = _function != null |
175 ? [new BRElement(), | 179 ? [ |
176 new SourceInsetElement(_isolate, _function.location, | 180 new BRElement(), |
177 _scripts, | 181 new SourceInsetElement(_isolate, _function.location, |
178 _instances, | 182 _scripts, _instances, _events, |
179 _events, | 183 currentPos: |
180 currentPos: M.topFrame(isolate.pauseEvent).location.tokenPos, | 184 M.topFrame(isolate.pauseEvent).location.tokenPos, |
181 queue: _r.queue)..classes = ['header_inset']] | 185 queue: _r.queue)..classes = ['header_inset'] |
182 : const [], | 186 ] |
| 187 : const [], |
183 new HRElement(), | 188 new HRElement(), |
184 new IsolateSharedSummaryElement(_isolate, _events, queue: _r.queue), | 189 new IsolateSharedSummaryElement(_isolate, _events, queue: _r.queue), |
185 new HRElement(), | 190 new HRElement(), |
186 new DivElement()..classes = ['memberList'] | 191 new DivElement() |
| 192 ..classes = ['memberList'] |
187 ..children = [ | 193 ..children = [ |
188 new DivElement()..classes = ['memberItem'] | 194 new DivElement() |
| 195 ..classes = ['memberItem'] |
189 ..children = [ | 196 ..children = [ |
190 new DivElement()..classes = ['memberName'] | 197 new DivElement() |
| 198 ..classes = ['memberName'] |
191 ..text = 'started at', | 199 ..text = 'started at', |
192 new DivElement()..classes = ['memberValue'] | 200 new DivElement() |
| 201 ..classes = ['memberValue'] |
193 ..text = '${_isolate.startTime}' | 202 ..text = '${_isolate.startTime}' |
194 ], | 203 ], |
195 new DivElement()..classes = ['memberItem'] | 204 new DivElement() |
| 205 ..classes = ['memberItem'] |
196 ..children = [ | 206 ..children = [ |
197 new DivElement()..classes = ['memberName'] | 207 new DivElement() |
| 208 ..classes = ['memberName'] |
198 ..text = 'uptime', | 209 ..text = 'uptime', |
199 new DivElement()..classes = ['memberValue'] | 210 new DivElement() |
| 211 ..classes = ['memberValue'] |
200 ..text = '$uptime' | 212 ..text = '$uptime' |
201 ], | 213 ], |
202 new DivElement()..classes = ['memberItem'] | 214 new DivElement() |
| 215 ..classes = ['memberItem'] |
203 ..children = [ | 216 ..children = [ |
204 new DivElement()..classes = ['memberName'] | 217 new DivElement() |
| 218 ..classes = ['memberName'] |
205 ..text = 'root library', | 219 ..text = 'root library', |
206 new DivElement()..classes = ['memberValue'] | 220 new DivElement() |
| 221 ..classes = ['memberValue'] |
207 ..children = [ | 222 ..children = [ |
208 _isolate.rootLibrary == null | 223 _isolate.rootLibrary == null |
209 ? (new SpanElement()..text = 'loading...') | 224 ? (new SpanElement()..text = 'loading...') |
210 : new LibraryRefElement(_isolate, _isolate.rootLibrary, | 225 : new LibraryRefElement( |
211 queue: _r.queue) | 226 _isolate, _isolate.rootLibrary, |
| 227 queue: _r.queue) |
212 ] | 228 ] |
213 ], | 229 ], |
214 new DivElement()..classes = ['memberItem'] | 230 new DivElement() |
| 231 ..classes = ['memberItem'] |
215 ..children = _isolate.entry != null | 232 ..children = _isolate.entry != null |
216 ? [ | 233 ? [ |
217 new DivElement()..classes = ['memberName'] | 234 new DivElement() |
218 ..text = 'entry', | 235 ..classes = ['memberName'] |
219 new DivElement()..classes = ['memberValue'] | 236 ..text = 'entry', |
220 ..children = [ | 237 new DivElement() |
221 new FunctionRefElement(_isolate, _isolate.entry, | 238 ..classes = ['memberValue'] |
222 queue: _r.queue) | 239 ..children = [ |
223 ] | 240 new FunctionRefElement(_isolate, _isolate.entry, |
224 ] | 241 queue: _r.queue) |
225 : const [], | 242 ] |
226 new DivElement()..classes = ['memberItem'] | 243 ] |
| 244 : const [], |
| 245 new DivElement() |
| 246 ..classes = ['memberItem'] |
227 ..children = [ | 247 ..children = [ |
228 new DivElement()..classes = ['memberName'] | 248 new DivElement() |
| 249 ..classes = ['memberName'] |
229 ..text = 'isolate id', | 250 ..text = 'isolate id', |
230 new DivElement()..classes = ['memberValue'] | 251 new DivElement() |
| 252 ..classes = ['memberValue'] |
231 ..text = '${_isolate.number}' | 253 ..text = '${_isolate.number}' |
232 ], | 254 ], |
233 new DivElement()..classes = ['memberItem'] | 255 new DivElement() |
| 256 ..classes = ['memberItem'] |
234 ..children = [ | 257 ..children = [ |
235 new DivElement()..classes = ['memberName'] | 258 new DivElement() |
| 259 ..classes = ['memberName'] |
236 ..text = 'service protocol extensions', | 260 ..text = 'service protocol extensions', |
237 new DivElement()..classes = ['memberValue'] | 261 new DivElement() |
| 262 ..classes = ['memberValue'] |
238 ..text = '${_isolate.extensionRPCs}' | 263 ..text = '${_isolate.extensionRPCs}' |
239 ], | 264 ], |
240 new DivElement()..classes = ['memberItem'] | 265 new DivElement() |
| 266 ..classes = ['memberItem'] |
241 ..children = [ | 267 ..children = [ |
242 new DivElement()..classes = ['memberName'] | 268 new DivElement() |
| 269 ..classes = ['memberName'] |
243 ..text = 'object store', | 270 ..text = 'object store', |
244 new DivElement()..classes = ['memberValue'] | 271 new DivElement() |
| 272 ..classes = ['memberValue'] |
245 ..children = [ | 273 ..children = [ |
246 new AnchorElement(href: Uris.objectStore(_isolate)) | 274 new AnchorElement(href: Uris.objectStore(_isolate)) |
247 ..text = 'object store' | 275 ..text = 'object store' |
248 ] | 276 ] |
249 ], | 277 ], |
250 new BRElement(), | 278 new BRElement(), |
251 new DivElement()..classes = ['memberItem'] | 279 new DivElement() |
| 280 ..classes = ['memberItem'] |
252 ..children = [ | 281 ..children = [ |
253 new DivElement()..classes = ['memberName'] | 282 new DivElement() |
| 283 ..classes = ['memberName'] |
254 ..text = 'libraries (${libraries.length})', | 284 ..text = 'libraries (${libraries.length})', |
255 new DivElement()..classes = ['memberValue'] | 285 new DivElement() |
| 286 ..classes = ['memberValue'] |
256 ..children = [ | 287 ..children = [ |
257 new CurlyBlockElement(queue: _r.queue) | 288 new CurlyBlockElement(queue: _r.queue) |
258 ..content = libraries.map((l) => | 289 ..content = libraries |
259 new DivElement() | 290 .map((l) => new DivElement() |
260 ..children = [ | 291 ..children = [ |
261 new LibraryRefElement(_isolate, l, | 292 new LibraryRefElement(_isolate, l, |
262 queue: _r.queue) | 293 queue: _r.queue) |
263 ] | 294 ]) |
264 ).toList() | 295 .toList() |
265 ] | 296 ] |
266 ] | 297 ] |
267 ], | 298 ], |
268 new HRElement(), | 299 new HRElement(), |
269 new EvalBoxElement(_isolate, _isolate.rootLibrary, _instances, _eval, | 300 new EvalBoxElement(_isolate, _isolate.rootLibrary, _instances, _eval, |
270 queue: _r.queue), | 301 queue: _r.queue), |
271 new DivElement() | 302 new DivElement() |
272 ..children = _rootScript != null | 303 ..children = _rootScript != null |
273 ? [new HRElement(), | 304 ? [ |
274 new ScriptInsetElement(_isolate, _rootScript, _scripts, | 305 new HRElement(), |
275 _instances, _events, queue: _r.queue)] | 306 new ScriptInsetElement( |
276 : const [], | 307 _isolate, _rootScript, _scripts, _instances, _events, |
| 308 queue: _r.queue) |
| 309 ] |
| 310 : const [], |
277 new HRElement(), | 311 new HRElement(), |
278 new ViewFooterElement(queue: _r.queue) | 312 new ViewFooterElement(queue: _r.queue) |
279 ] | 313 ] |
280 ]; | 314 ]; |
281 } | 315 } |
282 | 316 |
283 Future _loadExtraData() async{ | 317 Future _loadExtraData() async { |
284 _function = null; | 318 _function = null; |
285 _rootScript = null; | 319 _rootScript = null; |
286 final frame = M.topFrame(_isolate.pauseEvent); | 320 final frame = M.topFrame(_isolate.pauseEvent); |
287 if (frame != null) { | 321 if (frame != null) { |
288 _function = await _functions.get(_isolate, frame.function.id); | 322 _function = await _functions.get(_isolate, frame.function.id); |
289 } | 323 } |
290 if (_isolate.rootLibrary != null) { | 324 if (_isolate.rootLibrary != null) { |
291 final rootLibrary = await _libraries.get(_isolate, | 325 final rootLibrary = |
292 _isolate.rootLibrary.id); | 326 await _libraries.get(_isolate, _isolate.rootLibrary.id); |
293 _rootScript = rootLibrary.rootScript; | 327 _rootScript = rootLibrary.rootScript; |
294 } | 328 } |
295 _r.dirty(); | 329 _r.dirty(); |
296 } | 330 } |
297 } | 331 } |
OLD | NEW |