Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 heap_profile_element; | 5 library heap_profile_element; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:html'; | 8 import 'dart:html'; |
| 9 import 'observatory_element.dart'; | 9 import 'observatory_element.dart'; |
| 10 import 'package:observatory/app.dart'; | 10 import 'package:observatory/app.dart'; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 var _newPieChart; | 36 var _newPieChart; |
| 37 | 37 |
| 38 // Pie chart of old space usage. | 38 // Pie chart of old space usage. |
| 39 var _oldPieDataTable; | 39 var _oldPieDataTable; |
| 40 var _oldPieChart; | 40 var _oldPieChart; |
| 41 | 41 |
| 42 @observable ClassSortedTable classTable; | 42 @observable ClassSortedTable classTable; |
| 43 var _classTableBody; | 43 var _classTableBody; |
| 44 | 44 |
| 45 @published bool autoRefresh = false; | 45 @published bool autoRefresh = false; |
| 46 var _subscription; | 46 var _subscriptionFuture; |
| 47 | 47 |
| 48 @published Isolate isolate; | 48 @published Isolate isolate; |
| 49 @observable ServiceMap profile; | 49 @observable ServiceMap profile; |
| 50 | 50 |
| 51 HeapProfileElement.created() : super.created() { | 51 HeapProfileElement.created() : super.created() { |
| 52 // Create pie chart models. | 52 // Create pie chart models. |
| 53 _newPieDataTable = new DataTable(); | 53 _newPieDataTable = new DataTable(); |
| 54 _newPieDataTable.addColumn('string', 'Type'); | 54 _newPieDataTable.addColumn('string', 'Type'); |
| 55 _newPieDataTable.addColumn('number', 'Size'); | 55 _newPieDataTable.addColumn('number', 'Size'); |
| 56 _oldPieDataTable = new DataTable(); | 56 _oldPieDataTable = new DataTable(); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 86 | 86 |
| 87 @override | 87 @override |
| 88 void attached() { | 88 void attached() { |
| 89 super.attached(); | 89 super.attached(); |
| 90 // Grab the pie chart divs. | 90 // Grab the pie chart divs. |
| 91 _newPieChart = new Chart('PieChart', | 91 _newPieChart = new Chart('PieChart', |
| 92 shadowRoot.querySelector('#newPieChart')); | 92 shadowRoot.querySelector('#newPieChart')); |
| 93 _oldPieChart = new Chart('PieChart', | 93 _oldPieChart = new Chart('PieChart', |
| 94 shadowRoot.querySelector('#oldPieChart')); | 94 shadowRoot.querySelector('#oldPieChart')); |
| 95 _classTableBody = shadowRoot.querySelector('#classTableBody'); | 95 _classTableBody = shadowRoot.querySelector('#classTableBody'); |
| 96 _subscription = app.vm.events.stream.where( | 96 _subscriptionFuture = app.vm.getGCEventStream().then((stream) { |
|
Cutch
2015/07/07 23:16:09
This looks like the code in the previous file. Can
turnidge
2015/07/08 20:23:39
Done.
| |
| 97 (event) => event.isolate == isolate).listen(_onEvent); | 97 return stream.listen(_onEvent); |
| 98 }); | |
| 98 } | 99 } |
| 99 | 100 |
| 100 @override | 101 @override |
| 101 void detached() { | 102 void detached() { |
| 102 _subscription.cancel(); | 103 _subscriptionFuture.then((subscription) => subscription.cancel()); |
|
Cutch
2015/07/07 23:16:09
ditto?
void cancelFutureSubscription(Future<Strea
turnidge
2015/07/08 20:23:39
Done.
| |
| 103 super.detached(); | 104 super.detached(); |
| 104 } | 105 } |
| 105 | 106 |
| 106 // Keep at most one outstanding auto-refresh RPC. | 107 // Keep at most one outstanding auto-refresh RPC. |
| 107 bool refreshAutoPending = false; | 108 bool refreshAutoPending = false; |
| 108 bool refreshAutoQueued = false; | 109 bool refreshAutoQueued = false; |
| 109 | 110 |
| 110 void _onEvent(ServiceEvent event) { | 111 void _onEvent(ServiceEvent event) { |
| 111 if (autoRefresh && event.kind == 'GC') { | 112 assert(event.kind == 'GC'); |
| 113 if (autoRefresh) { | |
| 112 if (!refreshAutoPending) { | 114 if (!refreshAutoPending) { |
| 113 refreshAuto(); | 115 refreshAuto(); |
| 114 } else { | 116 } else { |
| 115 // Remember to refresh once more, to ensure latest profile. | 117 // Remember to refresh once more, to ensure latest profile. |
| 116 refreshAutoQueued = true; | 118 refreshAutoQueued = true; |
| 117 } | 119 } |
| 118 } | 120 } |
| 119 } | 121 } |
| 120 | 122 |
| 121 void refreshAuto() { | 123 void refreshAuto() { |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 } | 365 } |
| 364 | 366 |
| 365 @observable String formattedTotalCollectionTime(bool newSpace) { | 367 @observable String formattedTotalCollectionTime(bool newSpace) { |
| 366 if (profile == null) { | 368 if (profile == null) { |
| 367 return ''; | 369 return ''; |
| 368 } | 370 } |
| 369 var heap = newSpace ? isolate.newSpace : isolate.oldSpace; | 371 var heap = newSpace ? isolate.newSpace : isolate.oldSpace; |
| 370 return '${Utils.formatSeconds(heap.totalCollectionTimeInSeconds)} secs'; | 372 return '${Utils.formatSeconds(heap.totalCollectionTimeInSeconds)} secs'; |
| 371 } | 373 } |
| 372 } | 374 } |
| OLD | NEW |