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

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

Issue 2310003004: Removed polymer & mirror from Observatory (Closed)
Patch Set: Fixed crash in heap-map page 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) 2016, the Dart project authors. Please see the AUTHORS file 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 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 import 'dart:html'; 5 import 'dart:html';
6 import 'dart:async'; 6 import 'dart:async';
7 import 'package:observatory/models.dart' as M 7 import 'package:observatory/models.dart' as M
8 show IsolateRef, EventRepository; 8 show IsolateRef, EventRepository;
9 import 'package:observatory/src/elements/helpers/nav_menu.dart';
9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; 10 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
10 import 'package:observatory/src/elements/helpers/tag.dart'; 11 import 'package:observatory/src/elements/helpers/tag.dart';
11 import 'package:observatory/src/elements/helpers/uris.dart'; 12 import 'package:observatory/src/elements/helpers/uris.dart';
12 import 'package:observatory/src/elements/nav/menu.dart';
13 import 'package:observatory/src/elements/nav/menu_item.dart'; 13 import 'package:observatory/src/elements/nav/menu_item.dart';
14 14
15 class NavIsolateMenuElement extends HtmlElement implements Renderable { 15 class NavIsolateMenuElement extends HtmlElement implements Renderable {
16 static const tag = const Tag<NavIsolateMenuElement>('nav-isolate-menu', 16 static const tag = const Tag<NavIsolateMenuElement>('nav-isolate-menu',
17 dependencies: const [NavMenuElement.tag, 17 dependencies: const [NavMenuItemElement.tag]);
18 NavMenuItemElement.tag]);
19 18
20 RenderingScheduler _r; 19 RenderingScheduler _r;
21 20
22 Stream<RenderedEvent<NavIsolateMenuElement>> get onRendered => _r.onRendered; 21 Stream<RenderedEvent<NavIsolateMenuElement>> get onRendered => _r.onRendered;
23 22
24 bool _last;
25 M.IsolateRef _isolate; 23 M.IsolateRef _isolate;
26 M.EventRepository _events; 24 M.EventRepository _events;
27 StreamSubscription _updatesSubscription; 25 StreamSubscription _updatesSubscription;
26 Iterable<Element> _content = const [];
28 27
29 bool get last => _last;
30 M.IsolateRef get isolate => _isolate; 28 M.IsolateRef get isolate => _isolate;
29 Iterable<Element> get content => _content;
31 30
32 set last(bool value) => _last = _r.checkAndReact(_last, value); 31 set content(Iterable<Element> value) {
32 _content = value.toList();
33 _r.dirty();
34 }
33 35
34 factory NavIsolateMenuElement(M.IsolateRef isolate, 36 factory NavIsolateMenuElement(M.IsolateRef isolate,
35 M.EventRepository events, {bool last: false, 37 M.EventRepository events, {RenderingQueue queue}) {
36 RenderingQueue queue}) {
37 assert(isolate != null); 38 assert(isolate != null);
38 assert(events != null); 39 assert(events != null);
39 assert(last != null);
40 NavIsolateMenuElement e = document.createElement(tag.name); 40 NavIsolateMenuElement e = document.createElement(tag.name);
41 e._r = new RenderingScheduler(e, queue: queue); 41 e._r = new RenderingScheduler(e, queue: queue);
42 e._isolate = isolate; 42 e._isolate = isolate;
43 e._last = last;
44 e._events = events; 43 e._events = events;
45 return e; 44 return e;
46 } 45 }
47 46
48 NavIsolateMenuElement.created() : super.created() { 47 NavIsolateMenuElement.created() : super.created();
49 _r = new RenderingScheduler(this);
50 createShadowRoot();
51 }
52 48
53 @override 49 @override
54 void attached() { 50 void attached() {
55 super.attached(); 51 super.attached();
56 _updatesSubscription = _events.onIsolateUpdate 52 _updatesSubscription = _events.onIsolateUpdate
57 .where((e) => e.isolate.id == isolate.id) 53 .where((e) => e.isolate.id == isolate.id)
58 .listen((e) { _isolate = e.isolate; _r.dirty(); }); 54 .listen((e) { _isolate = e.isolate; _r.dirty(); });
59 _r.enable(); 55 _r.enable();
60 } 56 }
61 57
62 @override 58 @override
63 void detached() { 59 void detached() {
64 super.detached(); 60 super.detached();
61 children = [];
65 _r.disable(notify: true); 62 _r.disable(notify: true);
66 shadowRoot.children = [];
67 assert(_updatesSubscription != null); 63 assert(_updatesSubscription != null);
68 _updatesSubscription.cancel(); 64 _updatesSubscription.cancel();
69 _updatesSubscription = null; 65 _updatesSubscription = null;
70 } 66 }
71 67
72 void render() { 68 void render() {
73 shadowRoot.children = [ 69 final content = [
74 new NavMenuElement(isolate.name, last: last, queue: _r.queue, 70 new NavMenuItemElement('debugger', queue: _r.queue,
71 link: Uris.debugger(isolate)),
72 new NavMenuItemElement('class hierarchy', queue: _r.queue,
73 link: Uris.classTree(isolate)),
74 new NavMenuItemElement('cpu profile', queue: _r.queue,
75 link: Uris.cpuProfiler(isolate)),
76 new NavMenuItemElement('cpu profile (table)', queue: _r.queue,
77 link: Uris.cpuProfilerTable(isolate)),
78 new NavMenuItemElement('allocation profile', queue: _r.queue,
79 link: Uris.allocationProfiler(isolate)),
80 new NavMenuItemElement('heap map', queue: _r.queue,
81 link: Uris.heapMap(isolate)),
82 new NavMenuItemElement('metrics', queue: _r.queue,
83 link: Uris.metrics(isolate)),
84 new NavMenuItemElement('heap snapshot', queue: _r.queue,
85 link: Uris.heapSnapshot(isolate)),
86 new NavMenuItemElement('persistent handles', queue: _r.queue,
87 link: Uris.persistentHandles(isolate)),
88 new NavMenuItemElement('ports', queue: _r.queue,
89 link: Uris.ports(isolate)),
90 new NavMenuItemElement('logging', queue: _r.queue,
91 link: Uris.logging(isolate)),
92 ]..addAll(_content);
93 children = [
94 navMenu(isolate.name, content: content,
75 link: Uris.inspect(isolate)) 95 link: Uris.inspect(isolate))
76 ..children = [
77 new NavMenuItemElement('debugger', queue: _r.queue,
78 link: Uris.debugger(isolate)),
79 new NavMenuItemElement('class hierarchy', queue: _r.queue,
80 link: Uris.classTree(isolate)),
81 new NavMenuItemElement('cpu profile', queue: _r.queue,
82 link: Uris.cpuProfiler(isolate)),
83 new NavMenuItemElement('cpu profile (table)', queue: _r.queue,
84 link: Uris.cpuProfilerTable(isolate)),
85 new NavMenuItemElement('allocation profile', queue: _r.queue,
86 link: Uris.allocationProfiler(isolate)),
87 new NavMenuItemElement('heap map', queue: _r.queue,
88 link: Uris.heapMap(isolate)),
89 new NavMenuItemElement('metrics', queue: _r.queue,
90 link: Uris.metrics(isolate)),
91 new NavMenuItemElement('heap snapshot', queue: _r.queue,
92 link: Uris.heapSnapshot(isolate)),
93 new NavMenuItemElement('persistent handles', queue: _r.queue,
94 link: Uris.persistentHandles(isolate)),
95 new NavMenuItemElement('ports', queue: _r.queue,
96 link: Uris.ports(isolate)),
97 new NavMenuItemElement('logging', queue: _r.queue,
98 link: Uris.logging(isolate)),
99 new ContentElement()
100 ]
101 ]; 96 ];
102 } 97 }
103 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698