| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'dart:html'; |
| 6 import 'dart:async'; |
| 7 import 'package:observatory/models.dart' as M; |
| 8 import 'package:observatory/utils.dart'; |
| 9 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/uris.dart'; |
| 12 import 'package:observatory/src/elements/isolate/counter_chart.dart'; |
| 13 |
| 14 class IsolateSharedSummaryElement extends HtmlElement implements Renderable { |
| 15 static const tag = |
| 16 const Tag<IsolateSharedSummaryElement>('isolate-shared-summary-wrapped', |
| 17 dependencies: const [ |
| 18 IsolateCounterChartElement.tag |
| 19 ]); |
| 20 |
| 21 RenderingScheduler<IsolateSharedSummaryElement> _r; |
| 22 |
| 23 Stream<RenderedEvent<IsolateSharedSummaryElement>> get onRendered => |
| 24 _r.onRendered; |
| 25 |
| 26 M.Isolate _isolate; |
| 27 |
| 28 factory IsolateSharedSummaryElement(M.Isolate isolate, |
| 29 {RenderingQueue queue}) { |
| 30 assert(isolate != null); |
| 31 IsolateSharedSummaryElement e = document.createElement(tag.name); |
| 32 e._r = new RenderingScheduler(e, queue: queue); |
| 33 e._isolate = isolate; |
| 34 return e; |
| 35 } |
| 36 |
| 37 IsolateSharedSummaryElement.created() : super.created(); |
| 38 |
| 39 @override |
| 40 void attached() { |
| 41 super.attached(); |
| 42 _r.enable(); |
| 43 } |
| 44 |
| 45 @override |
| 46 void detached() { |
| 47 super.detached(); |
| 48 children = []; |
| 49 _r.disable(notify: true); |
| 50 } |
| 51 |
| 52 void render() { |
| 53 children = []; |
| 54 if (_isolate.error != null) { |
| 55 children = [ |
| 56 new PreElement()..classes = const ["errorBox"] |
| 57 ..text = _isolate.error.message |
| 58 ]; |
| 59 } |
| 60 final newHeapUsed = Utils.formatSize(_isolate.newSpace.used); |
| 61 final newHeapCapacity = Utils.formatSize(_isolate.newSpace.capacity); |
| 62 final oldHeapUsed = Utils.formatSize(_isolate.oldSpace.used); |
| 63 final oldHeapCapacity = Utils.formatSize(_isolate.oldSpace.capacity); |
| 64 children.addAll([ |
| 65 new DivElement()..classes = ['menu'] |
| 66 ..children = [ |
| 67 new DivElement()..classes = const ['memberList'] |
| 68 ..children = [ |
| 69 new DivElement()..classes = const ['memberItem'] |
| 70 ..children = [ |
| 71 new DivElement()..classes = const ['memberName'] |
| 72 ..text = 'new heap', |
| 73 new DivElement()..classes = const ['memberValue'] |
| 74 ..text = '$newHeapUsed of $newHeapCapacity', |
| 75 ], |
| 76 new DivElement()..classes = const ['memberItem'] |
| 77 ..children = [ |
| 78 new DivElement()..classes = const ['memberName'] |
| 79 ..text = 'old heap', |
| 80 new DivElement()..classes = const ['memberValue'] |
| 81 ..text = '$oldHeapUsed of $oldHeapCapacity', |
| 82 ] |
| 83 ], |
| 84 new BRElement(), |
| 85 new DivElement() |
| 86 ..children = [ |
| 87 new SpanElement()..text = 'see ', |
| 88 new AnchorElement(href: Uris.debugger(_isolate)) |
| 89 ..text = 'debug' |
| 90 ], |
| 91 new DivElement() |
| 92 ..children = [ |
| 93 new SpanElement()..text = 'see ', |
| 94 new AnchorElement(href: Uris.classTree(_isolate)) |
| 95 ..text = 'class hierarchy' |
| 96 ], |
| 97 new DivElement() |
| 98 ..children = [ |
| 99 new SpanElement()..text = 'see ', |
| 100 new AnchorElement(href: Uris.cpuProfiler(_isolate)) |
| 101 ..text = 'cpu profile' |
| 102 ], |
| 103 new DivElement() |
| 104 ..children = [ |
| 105 new SpanElement()..text = 'see ', |
| 106 new AnchorElement(href: Uris.cpuProfilerTable(_isolate)) |
| 107 ..text = 'cpu profile (table)' |
| 108 ], |
| 109 new DivElement() |
| 110 ..children = [ |
| 111 new SpanElement()..text = 'see ', |
| 112 new AnchorElement(href: Uris.allocationProfiler(_isolate)) |
| 113 ..text = 'allocation profile' |
| 114 ], |
| 115 new DivElement() |
| 116 ..children = [ |
| 117 new SpanElement()..text = 'see ', |
| 118 new AnchorElement(href: Uris.heapMap(_isolate)) |
| 119 ..text = 'heap map' |
| 120 ], |
| 121 new DivElement() |
| 122 ..children = [ |
| 123 new SpanElement()..text = 'see ', |
| 124 new AnchorElement(href: Uris.metrics(_isolate)) |
| 125 ..text = 'metrics' |
| 126 ], |
| 127 new DivElement() |
| 128 ..children = [ |
| 129 new SpanElement()..text = 'see ', |
| 130 new AnchorElement(href: Uris.heapSnapshot(_isolate)) |
| 131 ..text = 'heap snapshot' |
| 132 ], |
| 133 new DivElement() |
| 134 ..children = [ |
| 135 new SpanElement()..text = 'see ', |
| 136 new AnchorElement(href: Uris.persistentHandles(_isolate)) |
| 137 ..text = 'persistent handles' |
| 138 ], |
| 139 new DivElement() |
| 140 ..children = [ |
| 141 new SpanElement()..text = 'see ', |
| 142 new AnchorElement(href: Uris.ports(_isolate)) |
| 143 ..text = 'ports' |
| 144 ], |
| 145 new DivElement() |
| 146 ..children = [ |
| 147 new SpanElement()..text = 'see ', |
| 148 new AnchorElement(href: Uris.logging(_isolate)) |
| 149 ..text = 'logging' |
| 150 ] |
| 151 ], |
| 152 new IsolateCounterChartElement(_isolate.counters, queue: _r.queue) |
| 153 ]); |
| 154 } |
| 155 } |
| OLD | NEW |