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