| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:html'; | 6 import 'dart:html'; |
| 7 import 'package:observatory/models.dart' as M; | 7 import 'package:observatory/models.dart' as M; |
| 8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | 8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; |
| 9 import 'package:observatory/src/elements/helpers/tag.dart'; | 9 import 'package:observatory/src/elements/helpers/tag.dart'; |
| 10 import 'package:observatory/src/elements/helpers/uris.dart'; | 10 import 'package:observatory/src/elements/helpers/uris.dart'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 RenderingScheduler<SampleBufferControlElement> _r; | 22 RenderingScheduler<SampleBufferControlElement> _r; |
| 23 | 23 |
| 24 Stream<RenderedEvent<SampleBufferControlElement>> get onRendered => | 24 Stream<RenderedEvent<SampleBufferControlElement>> get onRendered => |
| 25 _r.onRendered; | 25 _r.onRendered; |
| 26 | 26 |
| 27 StreamController<SampleBufferControlChangedElement> _onTagChange = | 27 StreamController<SampleBufferControlChangedElement> _onTagChange = |
| 28 new StreamController<SampleBufferControlChangedElement>.broadcast(); | 28 new StreamController<SampleBufferControlChangedElement>.broadcast(); |
| 29 Stream<SampleBufferControlChangedElement> get onTagChange => | 29 Stream<SampleBufferControlChangedElement> get onTagChange => |
| 30 _onTagChange.stream; | 30 _onTagChange.stream; |
| 31 | 31 |
| 32 M.VM _vm; | |
| 33 Stream<M.SampleProfileLoadingProgressEvent> _progressStream; | 32 Stream<M.SampleProfileLoadingProgressEvent> _progressStream; |
| 34 M.SampleProfileLoadingProgress _progress; | 33 M.SampleProfileLoadingProgress _progress; |
| 35 M.SampleProfileTag _tag; | 34 M.SampleProfileTag _tag; |
| 36 bool _showTag = false; | 35 bool _showTag = false; |
| 37 bool _profileVM = false; | 36 bool _profileVM = false; |
| 38 StreamSubscription _subscription; | 37 StreamSubscription _subscription; |
| 39 | 38 |
| 40 M.SampleProfileLoadingProgress get progress => _progress; | 39 M.SampleProfileLoadingProgress get progress => _progress; |
| 41 M.SampleProfileTag get selectedTag => _tag; | 40 M.SampleProfileTag get selectedTag => _tag; |
| 42 bool get showTag => _showTag; | 41 bool get showTag => _showTag; |
| 43 bool get profileVM => _profileVM; | 42 bool get profileVM => _profileVM; |
| 44 | 43 |
| 45 set selectedTag(M.SampleProfileTag value) => | 44 set selectedTag(M.SampleProfileTag value) => |
| 46 _tag = _r.checkAndReact(_tag, value); | 45 _tag = _r.checkAndReact(_tag, value); |
| 47 set showTag(bool value) => _showTag = _r.checkAndReact(_showTag, value); | 46 set showTag(bool value) => _showTag = _r.checkAndReact(_showTag, value); |
| 48 set profileVM(bool value) => _profileVM = _r.checkAndReact(_profileVM, value); | 47 set profileVM(bool value) => _profileVM = _r.checkAndReact(_profileVM, value); |
| 49 | 48 |
| 50 factory SampleBufferControlElement( | 49 factory SampleBufferControlElement(M.SampleProfileLoadingProgress progress, |
| 51 M.VM vm, | |
| 52 M.SampleProfileLoadingProgress progress, | |
| 53 Stream<M.SampleProfileLoadingProgressEvent> progressStream, | 50 Stream<M.SampleProfileLoadingProgressEvent> progressStream, |
| 54 {M.SampleProfileTag selectedTag: M.SampleProfileTag.none, | 51 {M.SampleProfileTag selectedTag: M.SampleProfileTag.none, |
| 55 bool showTag: true, | 52 bool showTag: true, |
| 56 RenderingQueue queue}) { | 53 RenderingQueue queue}) { |
| 57 assert(vm != null); | |
| 58 assert(progress != null); | 54 assert(progress != null); |
| 59 assert(progressStream != null); | 55 assert(progressStream != null); |
| 60 assert(selectedTag != null); | 56 assert(selectedTag != null); |
| 61 assert(showTag != null); | 57 assert(showTag != null); |
| 62 SampleBufferControlElement e = document.createElement(tag.name); | 58 SampleBufferControlElement e = document.createElement(tag.name); |
| 63 e._r = new RenderingScheduler(e, queue: queue); | 59 e._r = new RenderingScheduler(e, queue: queue); |
| 64 e._vm = vm; | |
| 65 e._progress = progress; | 60 e._progress = progress; |
| 66 e._progressStream = progressStream; | 61 e._progressStream = progressStream; |
| 67 e._tag = selectedTag; | 62 e._tag = selectedTag; |
| 68 e._showTag = showTag; | 63 e._showTag = showTag; |
| 69 return e; | 64 return e; |
| 70 } | 65 } |
| 71 | 66 |
| 72 SampleBufferControlElement.created() : super.created(); | 67 SampleBufferControlElement.created() : super.created(); |
| 73 | 68 |
| 74 @override | 69 @override |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 ..text = message, | 122 ..text = message, |
| 128 new DivElement() | 123 new DivElement() |
| 129 ..style.background = '#0489c3' | 124 ..style.background = '#0489c3' |
| 130 ..style.width = '$progress%' | 125 ..style.width = '$progress%' |
| 131 ..style.height = '15px' | 126 ..style.height = '15px' |
| 132 ..style.borderRadius = '4px' | 127 ..style.borderRadius = '4px' |
| 133 ] | 128 ] |
| 134 ]; | 129 ]; |
| 135 } | 130 } |
| 136 | 131 |
| 137 List<Element> _createDisabledMessage() { | 132 static List<Element> _createDisabledMessage() { |
| 138 return [ | 133 return [ |
| 139 new DivElement() | 134 new DivElement() |
| 140 ..classes = ['statusBox' 'shadow' 'center'] | 135 ..classes = ['statusBox' 'shadow' 'center'] |
| 141 ..children = [ | 136 ..children = [ |
| 142 new DivElement() | 137 new DivElement() |
| 143 ..children = [ | 138 ..children = [ |
| 144 new HeadingElement.h1()..text = 'Profiling is disabled', | 139 new HeadingElement.h1()..text = 'Profiling is disabled', |
| 145 new BRElement(), | 140 new BRElement(), |
| 146 new DivElement() | 141 new DivElement() |
| 147 ..innerHtml = 'Perhaps the <b>profile</b> ' | 142 ..innerHtml = 'Perhaps the <b>profile</b> ' |
| 148 'flag has been disabled for this VM.', | 143 'flag has been disabled for this VM.', |
| 149 new BRElement(), | 144 new BRElement(), |
| 150 new ButtonElement() | 145 new SpanElement()..text = 'See all ', |
| 151 ..text = 'Enable profiler' | 146 new AnchorElement(href: Uris.flags())..text = 'vm flags' |
| 152 ..onClick.listen((_) { | |
| 153 _enableProfiler(); | |
| 154 }) | |
| 155 ] | 147 ] |
| 156 ] | 148 ] |
| 157 ]; | 149 ]; |
| 158 } | 150 } |
| 159 | 151 |
| 160 List<Element> _createStatusReport() { | 152 List<Element> _createStatusReport() { |
| 161 final fetchT = Utils.formatDurationInSeconds(_progress.fetchingTime); | 153 final fetchT = Utils.formatDurationInSeconds(_progress.fetchingTime); |
| 162 final loadT = Utils.formatDurationInSeconds(_progress.loadingTime); | 154 final loadT = Utils.formatDurationInSeconds(_progress.loadingTime); |
| 163 final sampleCount = _progress.profile.sampleCount; | 155 final sampleCount = _progress.profile.sampleCount; |
| 164 final refreshT = new DateTime.now(); | 156 final refreshT = new DateTime.now(); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 case M.SampleProfileTag.none: | 246 case M.SampleProfileTag.none: |
| 255 return 'None'; | 247 return 'None'; |
| 256 } | 248 } |
| 257 throw new Exception('Unknown tagToString'); | 249 throw new Exception('Unknown tagToString'); |
| 258 } | 250 } |
| 259 | 251 |
| 260 SampleBufferControlChangedElement _toEvent(_) { | 252 SampleBufferControlChangedElement _toEvent(_) { |
| 261 return new SampleBufferControlChangedElement(this); | 253 return new SampleBufferControlChangedElement(this); |
| 262 } | 254 } |
| 263 | 255 |
| 264 void _enableProfiler() { | |
| 265 _vm.enableProfiler().then((_) { | |
| 266 _triggerModeChange(_toEvent(null)); | |
| 267 }); | |
| 268 } | |
| 269 | |
| 270 void _triggerModeChange(e) => _onTagChange.add(e); | 256 void _triggerModeChange(e) => _onTagChange.add(e); |
| 271 } | 257 } |
| OLD | NEW |