| OLD | NEW |
| 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 import 'package:observatory/utils.dart'; | 8 import 'package:observatory/utils.dart'; |
| 9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 9 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
| 10 import 'package:observatory/src/elements/helpers/tag.dart'; | 10 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 11 import 'package:observatory/src/elements/helpers/uris.dart'; | 11 import 'package:observatory/src/elements/helpers/uris.dart'; |
| 12 import 'package:observatory/src/elements/isolate/counter_chart.dart'; | 12 import 'package:observatory/src/elements/isolate/counter_chart.dart'; |
| 13 | 13 |
| 14 class IsolateSharedSummaryElement extends HtmlElement implements Renderable { | 14 class IsolateSharedSummaryElement extends HtmlElement implements Renderable { |
| 15 static const tag = | 15 static const tag = const Tag<IsolateSharedSummaryElement>( |
| 16 const Tag<IsolateSharedSummaryElement>('isolate-shared-summary', | 16 'isolate-shared-summary', |
| 17 dependencies: const [ | 17 dependencies: const [IsolateCounterChartElement.tag]); |
| 18 IsolateCounterChartElement.tag | |
| 19 ]); | |
| 20 | 18 |
| 21 RenderingScheduler<IsolateSharedSummaryElement> _r; | 19 RenderingScheduler<IsolateSharedSummaryElement> _r; |
| 22 | 20 |
| 23 Stream<RenderedEvent<IsolateSharedSummaryElement>> get onRendered => | 21 Stream<RenderedEvent<IsolateSharedSummaryElement>> get onRendered => |
| 24 _r.onRendered; | 22 _r.onRendered; |
| 25 | 23 |
| 26 M.Isolate _isolate; | 24 M.Isolate _isolate; |
| 27 M.EventRepository _events; | 25 M.EventRepository _events; |
| 28 StreamSubscription _isolateSubscription; | 26 StreamSubscription _isolateSubscription; |
| 29 | 27 |
| 30 factory IsolateSharedSummaryElement(M.Isolate isolate, | 28 factory IsolateSharedSummaryElement( |
| 31 M.EventRepository events, | 29 M.Isolate isolate, M.EventRepository events, |
| 32 {RenderingQueue queue}) { | 30 {RenderingQueue queue}) { |
| 33 assert(isolate != null); | 31 assert(isolate != null); |
| 34 assert(events != null); | 32 assert(events != null); |
| 35 IsolateSharedSummaryElement e = document.createElement(tag.name); | 33 IsolateSharedSummaryElement e = document.createElement(tag.name); |
| 36 e._r = new RenderingScheduler(e, queue: queue); | 34 e._r = new RenderingScheduler(e, queue: queue); |
| 37 e._isolate = isolate; | 35 e._isolate = isolate; |
| 38 e._events = events; | 36 e._events = events; |
| 39 return e; | 37 return e; |
| 40 } | 38 } |
| 41 | 39 |
| 42 IsolateSharedSummaryElement.created() : super.created(); | 40 IsolateSharedSummaryElement.created() : super.created(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 55 _r.disable(notify: true); | 53 _r.disable(notify: true); |
| 56 _isolateSubscription.cancel(); | 54 _isolateSubscription.cancel(); |
| 57 } | 55 } |
| 58 | 56 |
| 59 void render() { | 57 void render() { |
| 60 final newHeapUsed = Utils.formatSize(_isolate.newSpace.used); | 58 final newHeapUsed = Utils.formatSize(_isolate.newSpace.used); |
| 61 final newHeapCapacity = Utils.formatSize(_isolate.newSpace.capacity); | 59 final newHeapCapacity = Utils.formatSize(_isolate.newSpace.capacity); |
| 62 final oldHeapUsed = Utils.formatSize(_isolate.oldSpace.used); | 60 final oldHeapUsed = Utils.formatSize(_isolate.oldSpace.used); |
| 63 final oldHeapCapacity = Utils.formatSize(_isolate.oldSpace.capacity); | 61 final oldHeapCapacity = Utils.formatSize(_isolate.oldSpace.capacity); |
| 64 final content = [ | 62 final content = [ |
| 65 new DivElement()..classes = ['menu'] | 63 new DivElement() |
| 64 ..classes = ['menu'] |
| 66 ..children = [ | 65 ..children = [ |
| 67 new DivElement()..classes = ['memberList'] | 66 new DivElement() |
| 67 ..classes = ['memberList'] |
| 68 ..children = [ | 68 ..children = [ |
| 69 new DivElement()..classes = ['memberItem'] | 69 new DivElement() |
| 70 ..classes = ['memberItem'] |
| 70 ..children = [ | 71 ..children = [ |
| 71 new DivElement()..classes = ['memberName'] | 72 new DivElement() |
| 73 ..classes = ['memberName'] |
| 72 ..text = 'new heap', | 74 ..text = 'new heap', |
| 73 new DivElement()..classes = ['memberValue'] | 75 new DivElement() |
| 76 ..classes = ['memberValue'] |
| 74 ..text = '$newHeapUsed of $newHeapCapacity', | 77 ..text = '$newHeapUsed of $newHeapCapacity', |
| 75 ], | 78 ], |
| 76 new DivElement()..classes = ['memberItem'] | 79 new DivElement() |
| 80 ..classes = ['memberItem'] |
| 77 ..children = [ | 81 ..children = [ |
| 78 new DivElement()..classes = ['memberName'] | 82 new DivElement() |
| 83 ..classes = ['memberName'] |
| 79 ..text = 'old heap', | 84 ..text = 'old heap', |
| 80 new DivElement()..classes = ['memberValue'] | 85 new DivElement() |
| 86 ..classes = ['memberValue'] |
| 81 ..text = '$oldHeapUsed of $oldHeapCapacity', | 87 ..text = '$oldHeapUsed of $oldHeapCapacity', |
| 82 ] | 88 ] |
| 83 ], | 89 ], |
| 84 new BRElement(), | 90 new BRElement(), |
| 85 new DivElement() | 91 new DivElement() |
| 86 ..children = [ | 92 ..children = [ |
| 87 new SpanElement()..text = 'see ', | 93 new SpanElement()..text = 'see ', |
| 88 new AnchorElement(href: Uris.debugger(_isolate)) | 94 new AnchorElement(href: Uris.debugger(_isolate))..text = 'debug' |
| 89 ..text = 'debug' | |
| 90 ], | 95 ], |
| 91 new DivElement() | 96 new DivElement() |
| 92 ..children = [ | 97 ..children = [ |
| 93 new SpanElement()..text = 'see ', | 98 new SpanElement()..text = 'see ', |
| 94 new AnchorElement(href: Uris.classTree(_isolate)) | 99 new AnchorElement(href: Uris.classTree(_isolate)) |
| 95 ..text = 'class hierarchy' | 100 ..text = 'class hierarchy' |
| 96 ], | 101 ], |
| 97 new DivElement() | 102 new DivElement() |
| 98 ..children = [ | 103 ..children = [ |
| 99 new SpanElement()..text = 'see ', | 104 new SpanElement()..text = 'see ', |
| 100 new AnchorElement(href: Uris.cpuProfiler(_isolate)) | 105 new AnchorElement(href: Uris.cpuProfiler(_isolate)) |
| 101 ..text = 'cpu profile' | 106 ..text = 'cpu profile' |
| 102 ], | 107 ], |
| 103 new DivElement() | 108 new DivElement() |
| 104 ..children = [ | 109 ..children = [ |
| 105 new SpanElement()..text = 'see ', | 110 new SpanElement()..text = 'see ', |
| 106 new AnchorElement(href: Uris.cpuProfilerTable(_isolate)) | 111 new AnchorElement(href: Uris.cpuProfilerTable(_isolate)) |
| 107 ..text = 'cpu profile (table)' | 112 ..text = 'cpu profile (table)' |
| 108 ], | 113 ], |
| 109 new DivElement() | 114 new DivElement() |
| 110 ..children = [ | 115 ..children = [ |
| 111 new SpanElement()..text = 'see ', | 116 new SpanElement()..text = 'see ', |
| 112 new AnchorElement(href: Uris.allocationProfiler(_isolate)) | 117 new AnchorElement(href: Uris.allocationProfiler(_isolate)) |
| 113 ..text = 'allocation profile' | 118 ..text = 'allocation profile' |
| 114 ], | 119 ], |
| 115 new DivElement() | 120 new DivElement() |
| 116 ..children = [ | 121 ..children = [ |
| 117 new SpanElement()..text = 'see ', | 122 new SpanElement()..text = 'see ', |
| 118 new AnchorElement(href: Uris.heapMap(_isolate)) | 123 new AnchorElement(href: Uris.heapMap(_isolate))..text = 'heap map' |
| 119 ..text = 'heap map' | |
| 120 ], | 124 ], |
| 121 new DivElement() | 125 new DivElement() |
| 122 ..children = [ | 126 ..children = [ |
| 123 new SpanElement()..text = 'see ', | 127 new SpanElement()..text = 'see ', |
| 124 new AnchorElement(href: Uris.metrics(_isolate)) | 128 new AnchorElement(href: Uris.metrics(_isolate))..text = 'metrics' |
| 125 ..text = 'metrics' | |
| 126 ], | 129 ], |
| 127 new DivElement() | 130 new DivElement() |
| 128 ..children = [ | 131 ..children = [ |
| 129 new SpanElement()..text = 'see ', | 132 new SpanElement()..text = 'see ', |
| 130 new AnchorElement(href: Uris.heapSnapshot(_isolate)) | 133 new AnchorElement(href: Uris.heapSnapshot(_isolate)) |
| 131 ..text = 'heap snapshot' | 134 ..text = 'heap snapshot' |
| 132 ], | 135 ], |
| 133 new DivElement() | 136 new DivElement() |
| 134 ..children = [ | 137 ..children = [ |
| 135 new SpanElement()..text = 'see ', | 138 new SpanElement()..text = 'see ', |
| 136 new AnchorElement(href: Uris.persistentHandles(_isolate)) | 139 new AnchorElement(href: Uris.persistentHandles(_isolate)) |
| 137 ..text = 'persistent handles' | 140 ..text = 'persistent handles' |
| 138 ], | 141 ], |
| 139 new DivElement() | 142 new DivElement() |
| 140 ..children = [ | 143 ..children = [ |
| 141 new SpanElement()..text = 'see ', | 144 new SpanElement()..text = 'see ', |
| 142 new AnchorElement(href: Uris.ports(_isolate)) | 145 new AnchorElement(href: Uris.ports(_isolate))..text = 'ports' |
| 143 ..text = 'ports' | |
| 144 ], | 146 ], |
| 145 new DivElement() | 147 new DivElement() |
| 146 ..children = [ | 148 ..children = [ |
| 147 new SpanElement()..text = 'see ', | 149 new SpanElement()..text = 'see ', |
| 148 new AnchorElement(href: Uris.logging(_isolate)) | 150 new AnchorElement(href: Uris.logging(_isolate))..text = 'logging' |
| 149 ..text = 'logging' | |
| 150 ] | 151 ] |
| 151 ], | 152 ], |
| 152 new IsolateCounterChartElement(_isolate.counters, queue: _r.queue) | 153 new IsolateCounterChartElement(_isolate.counters, queue: _r.queue) |
| 153 ]; | 154 ]; |
| 154 if (_isolate.error != null) { | 155 if (_isolate.error != null) { |
| 155 children = [ | 156 children = [ |
| 156 new PreElement()..classes = ['errorBox'] | 157 new PreElement() |
| 158 ..classes = ['errorBox'] |
| 157 ..text = _isolate.error.message, | 159 ..text = _isolate.error.message, |
| 158 new DivElement()..classes = ['summary'] | 160 new DivElement() |
| 161 ..classes = ['summary'] |
| 159 ..children = content | 162 ..children = content |
| 160 ]; | 163 ]; |
| 161 } else { | 164 } else { |
| 162 children = [ | 165 children = [ |
| 163 new DivElement()..classes = ['summary'] | 166 new DivElement() |
| 167 ..classes = ['summary'] |
| 164 ..children = content | 168 ..children = content |
| 165 ]; | 169 ]; |
| 166 } | 170 } |
| 167 } | 171 } |
| 168 | 172 |
| 169 void _eventListener(e) { | 173 void _eventListener(e) { |
| 170 if (e.isolate.id == _isolate.id) { | 174 if (e.isolate.id == _isolate.id) { |
| 171 _isolate = e.isolate; | 175 _isolate = e.isolate; |
| 172 _r.dirty(); | 176 _r.dirty(); |
| 173 } | 177 } |
| 174 } | 178 } |
| 175 } | 179 } |
| OLD | NEW |