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

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

Issue 2304463002: Converted Observatory vm-view && isolate-view elements (Closed)
Patch Set: Fixed typo 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) 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 'observatory_element.dart'; 8 import 'dart:html';
9 import 'package:observatory/service.dart'; 9 import 'package:observatory/models.dart' as M;
10 import 'package:polymer/polymer.dart'; 10 import 'package:observatory/src/elements/curly_block.dart';
11 11 import 'package:observatory/src/elements/eval_box.dart';
12 @CustomTag('isolate-view') 12 import 'package:observatory/src/elements/function_ref.dart';
13 class IsolateViewElement extends ObservatoryElement { 13 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
14 @published Isolate isolate; 14 import 'package:observatory/src/elements/helpers/tag.dart';
15 @published Library rootLibrary; 15 import 'package:observatory/src/elements/helpers/uris.dart';
16 import 'package:observatory/src/elements/isolate/location.dart';
17 import 'package:observatory/src/elements/isolate/run_state.dart';
18 import 'package:observatory/src/elements/isolate/shared_summary.dart';
19 import 'package:observatory/src/elements/library_ref.dart';
20 import 'package:observatory/src/elements/nav/bar.dart';
21 import 'package:observatory/src/elements/nav/class_menu.dart';
22 import 'package:observatory/src/elements/nav/isolate_menu.dart';
23 import 'package:observatory/src/elements/nav/notify.dart';
24 import 'package:observatory/src/elements/nav/refresh.dart';
25 import 'package:observatory/src/elements/nav/top_menu.dart';
26 import 'package:observatory/src/elements/nav/vm_menu.dart';
27 import 'package:observatory/src/elements/script_inset.dart';
28 import 'package:observatory/src/elements/source_inset.dart';
29 import 'package:observatory/src/elements/view_footer.dart';
30
31 class IsolateViewElement extends HtmlElement implements Renderable {
32 static const tag = const Tag<IsolateViewElement>('isolate-view',
33 dependencies: const [
34 CurlyBlockElement.tag,
35 EvalBoxElement.tag,
36 FunctionRefElement.tag,
37 IsolateLocationElement.tag,
38 IsolateRunStateElement.tag,
39 IsolateSharedSummaryElement.tag,
40 LibraryRefElement.tag,
41 NavBarElement.tag,
42 NavClassMenuElement.tag,
43 NavTopMenuElement.tag,
44 NavIsolateMenuElement.tag,
45 NavRefreshElement.tag,
46 NavNotifyElement.tag,
47 ScriptInsetElement.tag,
48 SourceInsetElement.tag,
49 ViewFooterElement.tag
50 ]);
51
52 RenderingScheduler<IsolateViewElement> _r;
53
54 Stream<RenderedEvent<IsolateViewElement>> get onRendered => _r.onRendered;
55
56 M.VM _vm;
57 M.Isolate _isolate;
58 M.EventRepository _events;
59 M.NotificationRepository _notifications;
60 M.IsolateRepository _isolates;
61 M.ScriptRepository _scripts;
62 M.FunctionRepository _functions;
63 M.LibraryRepository _libraries;
64 M.InstanceRepository _instances;
65 M.EvalRepository _eval;
66 M.Function _function;
67 M.ScriptRef _rootScript;
68 StreamSubscription _subscription;
69
70 M.VMRef get vm => _vm;
71 M.Isolate get isolate => _isolate;
72 M.NotificationRepository get notifications => _notifications;
73
74 factory IsolateViewElement(M.VM vm, M.Isolate isolate,
75 M.EventRepository events,
76 M.NotificationRepository notifications,
77 M.IsolateRepository isolates,
78 M.ScriptRepository scripts,
79 M.FunctionRepository functions,
80 M.LibraryRepository libraries,
81 M.InstanceRepository instances,
82 M.EvalRepository eval,
83 {RenderingQueue queue}) {
84 assert(vm != null);
85 assert(isolate != null);
86 assert(events != null);
87 assert(notifications != null);
88 assert(isolates != null);
89 assert(scripts != null);
90 assert(functions != null);
91 assert(instances != null);
92 assert(eval != null);
93 assert(libraries != null);
94 IsolateViewElement e = document.createElement(tag.name);
95 e._r = new RenderingScheduler(e, queue: queue);
96 e._vm = vm;
97 e._isolate = isolate;
98 e._events = events;
99 e._notifications = notifications;
100 e._isolates = isolates;
101 e._scripts = scripts;
102 e._functions = functions;
103 e._instances = instances;
104 e._eval = eval;
105 e._libraries = libraries;
106 return e;
107 }
108
16 IsolateViewElement.created() : super.created(); 109 IsolateViewElement.created() : super.created();
17 110
18 Future<ServiceObject> evaluate(String expression) { 111 @override
19 return isolate.rootLibrary.evaluate(expression); 112 attached() {
20 }
21
22 void attached() {
23 super.attached(); 113 super.attached();
24 if (isolate.topFrame != null) { 114 _r.enable();
25 isolate.topFrame.function.load(); 115 _loadExtraData();
116 _subscription = _events.onIsolateUpdate.listen((e) {
117 if (e.isolate.id == _isolate) {
118 _isolate = isolate;
119 _r.dirty();
120 }
121 });
122 }
123
124 @override
125 detached() {
126 super.detached();
127 _r.disable(notify: true);
128 children = [];
129 _subscription.cancel();
130 }
131
132 void render() {
133 final uptime = new DateTime.now().difference(_isolate.startTime);
134 final libraries = _isolate.libraries.toList();
135 children = [
136 new NavBarElement(queue: _r.queue)
137 ..children = [
138 new NavTopMenuElement(queue: _r.queue),
139 new NavVMMenuElement(_vm, _events, queue: _r.queue),
140 new NavIsolateMenuElement(_isolate, _events, last: true,
141 queue: _r.queue),
142 new NavRefreshElement(label: 'reload source', queue: _r.queue)
143 ..onRefresh.listen((e) async {
144 e.element.disabled = true;
145 await _isolates.reloadSources(_isolate);
146 _r.dirty();
147 }),
148 new NavRefreshElement(queue: _r.queue)
149 ..onRefresh.listen((e) async {
150 e.element.disabled = true;
151 _isolate = await _isolates.get(_isolate);
152 await _loadExtraData();
153 _r.dirty();
154 }),
155 new NavNotifyElement(_notifications, queue: _r.queue)
156 ],
157 new DivElement()..classes = ['content-centered-big']
158 ..children = [
159 new HeadingElement.h2()..text = 'Isolate ${_isolate.name}',
160 new BRElement(),
161 new DivElement()..classes = ['flex-row']
162 ..children = [
163 new DivElement()..style.flex = '1',
164 new DivElement()
165 ..children = [
166 new IsolateRunStateElement(_isolate, _events, queue: _r.queue) ,
167 new IsolateLocationElement(_isolate, _events, _scripts,
168 queue: _r.queue),
169 new SpanElement()..text = ' [',
170 new AnchorElement(href: Uris.debugger(_isolate))
171 ..text = 'debug',
172 new SpanElement()..text = ']'
173 ]
174 ],
175 new DivElement()
176 ..children = _function != null
177 ? [new BRElement(),
178 new SourceInsetElement(_isolate, _function.location,
179 _scripts,
180 _instances,
181 _events,
182 currentPos: M.topFrame(isolate.pauseEvent).location.tokenPos,
183 queue: _r.queue)..classes = ['header_inset']]
184 : const [],
185 new HRElement(),
186 new IsolateSharedSummaryElement(_isolate, _events, queue: _r.queue),
187 new HRElement(),
188 new DivElement()..classes = ['memberList']
189 ..children = [
190 new DivElement()..classes = ['memberItem']
191 ..children = [
192 new DivElement()..classes = ['memberName']
193 ..text = 'started at',
194 new DivElement()..classes = ['memberValue']
195 ..text = '${_isolate.startTime}'
196 ],
197 new DivElement()..classes = ['memberItem']
198 ..children = [
199 new DivElement()..classes = ['memberName']
200 ..text = 'uptime',
201 new DivElement()..classes = ['memberValue']
202 ..text = '$uptime'
203 ],
204 new DivElement()..classes = ['memberItem']
205 ..children = [
206 new DivElement()..classes = ['memberName']
207 ..text = 'root library',
208 new DivElement()..classes = ['memberValue']
209 ..children = [
210 _isolate.rootLibrary == null
211 ? (new SpanElement()..text = 'loading...')
212 : new LibraryRefElement(_isolate, _isolate.rootLibrary,
213 queue: _r.queue)
214 ]
215 ],
216 new DivElement()..classes = ['memberItem']
217 ..children = _isolate.entry != null
218 ? [
219 new DivElement()..classes = ['memberName']
220 ..text = 'entry',
221 new DivElement()..classes = ['memberValue']
222 ..children = [
223 new FunctionRefElement(_isolate, _isolate.entry,
224 queue: _r.queue)
225 ]
226 ]
227 : const [],
228 new DivElement()..classes = ['memberItem']
229 ..children = [
230 new DivElement()..classes = ['memberName']
231 ..text = 'isolate id',
232 new DivElement()..classes = ['memberValue']
233 ..text = '${_isolate.number}'
234 ],
235 new DivElement()..classes = ['memberItem']
236 ..children = [
237 new DivElement()..classes = ['memberName']
238 ..text = 'service protocol extensions',
239 new DivElement()..classes = ['memberValue']
240 ..text = '${_isolate.extensionRPCs}'
241 ],
242 new DivElement()..classes = ['memberItem']
243 ..children = [
244 new DivElement()..classes = ['memberName']
245 ..text = 'object store',
246 new DivElement()..classes = ['memberValue']
247 ..children = [
248 new AnchorElement(href: Uris.objectStore(_isolate))
249 ..text = 'object store'
250 ]
251 ],
252 new BRElement(),
253 new DivElement()..classes = ['memberItem']
254 ..children = [
255 new DivElement()..classes = ['memberName']
256 ..text = 'libraries (${libraries.length})',
257 new DivElement()..classes = ['memberValue']
258 ..children = [
259 new CurlyBlockElement(queue: _r.queue)
260 ..children = libraries.map((l) =>
261 new DivElement()
262 ..children = [
263 new LibraryRefElement(_isolate, l,
264 queue: _r.queue)
265 ]
266 ).toList()
267 ]
268 ]
269 ],
270 new HRElement(),
271 new EvalBoxElement(_isolate, _isolate.rootLibrary, _instances, _eval,
272 queue: _r.queue),
273 new DivElement()
274 ..children = _rootScript != null
275 ? [new HRElement(),
276 new ScriptInsetElement(_isolate, _rootScript, _scripts,
277 _instances, _events, queue: _r.queue)]
278 : const [],
279 new HRElement(),
280 new ViewFooterElement(queue: _r.queue)
281 ]
282 ];
283 }
284
285 Future _loadExtraData() async{
286 _function = null;
287 _rootScript = null;
288 final frame = M.topFrame(_isolate.pauseEvent);
289 if (frame != null) {
290 _function = await _functions.get(_isolate, frame.function.id);
26 } 291 }
27 isolate.rootLibrary.load().then((lib) => rootLibrary = lib); 292 if (_isolate.rootLibrary != null) {
28 } 293 final rootLibrary = await _libraries.get(_isolate,
29 294 _isolate.rootLibrary.id);
30 Future refresh() async { 295 _rootScript = rootLibrary.rootScript;
31 await isolate.reload();
32 if (isolate.topFrame != null) {
33 await isolate.topFrame.function.load();
34 } 296 }
35 } 297 _r.dirty();
36
37 Future reloadSources() {
38 return isolate.reloadSources();
39 } 298 }
40 } 299 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/elements/isolate_summary.html ('k') | runtime/observatory/lib/src/elements/isolate_view.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698