| 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 library native_memory_profile; | 5 library native_memory_profile; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'package:observatory/models.dart' as M; | 9 import 'package:observatory/models.dart' as M; |
| 10 import 'package:observatory/src/elements/cpu_profile/virtual_tree.dart'; | 10 import 'package:observatory/src/elements/cpu_profile/virtual_tree.dart'; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 M.NativeMemorySampleProfileRepository _profiles; | 44 M.NativeMemorySampleProfileRepository _profiles; |
| 45 Stream<M.SampleProfileLoadingProgressEvent> _progressStream; | 45 Stream<M.SampleProfileLoadingProgressEvent> _progressStream; |
| 46 M.SampleProfileLoadingProgress _progress; | 46 M.SampleProfileLoadingProgress _progress; |
| 47 M.SampleProfileTag _tag = M.SampleProfileTag.none; | 47 M.SampleProfileTag _tag = M.SampleProfileTag.none; |
| 48 ProfileTreeMode _mode = ProfileTreeMode.function; | 48 ProfileTreeMode _mode = ProfileTreeMode.function; |
| 49 M.ProfileTreeDirection _direction = M.ProfileTreeDirection.exclusive; | 49 M.ProfileTreeDirection _direction = M.ProfileTreeDirection.exclusive; |
| 50 String _filter = ''; | 50 String _filter = ''; |
| 51 | 51 |
| 52 M.NotificationRepository get notifications => _notifications; | 52 M.NotificationRepository get notifications => _notifications; |
| 53 M.NativeMemorySampleProfileRepository get profiles => _profiles; | 53 M.NativeMemorySampleProfileRepository get profiles => _profiles; |
| 54 // With non-isolate version. | |
| 55 M.VMRef get vm => _vm; | |
| 56 | 54 |
| 57 factory NativeMemoryProfileElement( | 55 factory NativeMemoryProfileElement( |
| 58 M.VM vm, | 56 M.VM vm, |
| 59 M.EventRepository events, | 57 M.EventRepository events, |
| 60 M.NotificationRepository notifications, | 58 M.NotificationRepository notifications, |
| 61 M.NativeMemorySampleProfileRepository profiles, | 59 M.NativeMemorySampleProfileRepository profiles, |
| 62 {RenderingQueue queue}) { | 60 {RenderingQueue queue}) { |
| 63 assert(vm != null); | 61 assert(vm != null); |
| 64 assert(events != null); | 62 assert(events != null); |
| 65 assert(notifications != null); | 63 assert(notifications != null); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 }), | 134 }), |
| 137 new BRElement(), | 135 new BRElement(), |
| 138 tree = new CpuProfileVirtualTreeElement(_vm, _progress.profile, | 136 tree = new CpuProfileVirtualTreeElement(_vm, _progress.profile, |
| 139 queue: _r.queue, type: M.SampleProfileType.memory) | 137 queue: _r.queue, type: M.SampleProfileType.memory) |
| 140 ]); | 138 ]); |
| 141 } | 139 } |
| 142 children = content; | 140 children = content; |
| 143 } | 141 } |
| 144 | 142 |
| 145 Future _request({bool forceFetch: false}) async { | 143 Future _request({bool forceFetch: false}) async { |
| 146 for (Isolate isolate in vm.isolates) { | 144 for (M.Isolate isolate in _vm.isolates) { |
| 147 await isolate.invokeRpc("_collectAllGarbage", {}); | 145 await isolate.collectAllGarbage(); |
| 148 } | 146 } |
| 149 _progress = null; | 147 _progress = null; |
| 150 _progressStream = _profiles.get(_vm, _tag, forceFetch: forceFetch); | 148 _progressStream = _profiles.get(_vm, _tag, forceFetch: forceFetch); |
| 151 _r.dirty(); | 149 _r.dirty(); |
| 152 _progress = (await _progressStream.first).progress; | 150 _progress = (await _progressStream.first).progress; |
| 153 _r.dirty(); | 151 _r.dirty(); |
| 154 if (M.isSampleProcessRunning(_progress.status)) { | 152 if (M.isSampleProcessRunning(_progress.status)) { |
| 155 _progress = (await _progressStream.last).progress; | 153 _progress = (await _progressStream.last).progress; |
| 156 _r.dirty(); | 154 _r.dirty(); |
| 157 } | 155 } |
| 158 } | 156 } |
| 159 | 157 |
| 160 Future _refresh(e) async { | 158 Future _refresh(e) async { |
| 161 e.element.disabled = true; | 159 e.element.disabled = true; |
| 162 await _request(forceFetch: true); | 160 await _request(forceFetch: true); |
| 163 e.element.disabled = false; | 161 e.element.disabled = false; |
| 164 } | 162 } |
| 165 } | 163 } |
| OLD | NEW |