OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var g_browserBridge; | 5 var g_browserBridge; |
6 var g_mainView; | 6 var g_mainView; |
7 | 7 |
8 // TODO(eroman): Don't repeat the work of grouping, sorting, merging on every | 8 // TODO(eroman): Don't repeat the work of grouping, sorting, merging on every |
9 // redraw. Rather do it only once when one of its dependencies | 9 // redraw. Rather do it only once when one of its dependencies |
10 // change and cache the result. | 10 // change and cache the result. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // The anchor which toggles visibility of column checkboxes. | 92 // The anchor which toggles visibility of column checkboxes. |
93 var EDIT_COLUMNS_LINK_ID = 'edit-columns-link'; | 93 var EDIT_COLUMNS_LINK_ID = 'edit-columns-link'; |
94 | 94 |
95 // The container node to show/hide when toggling the column checkboxes. | 95 // The container node to show/hide when toggling the column checkboxes. |
96 var EDIT_COLUMNS_ROW = 'edit-columns-row'; | 96 var EDIT_COLUMNS_ROW = 'edit-columns-row'; |
97 | 97 |
98 // The checkbox which controls whether things like "Worker Threads" and | 98 // The checkbox which controls whether things like "Worker Threads" and |
99 // "PAC threads" will be merged together. | 99 // "PAC threads" will be merged together. |
100 var MERGE_SIMILAR_THREADS_CHECKBOX_ID = 'merge-similar-threads-checkbox'; | 100 var MERGE_SIMILAR_THREADS_CHECKBOX_ID = 'merge-similar-threads-checkbox'; |
101 | 101 |
| 102 var RESET_DATA_LINK_ID = 'reset-data-link'; |
| 103 |
102 // -------------------------------------------------------------------------- | 104 // -------------------------------------------------------------------------- |
103 // Row keys | 105 // Row keys |
104 // -------------------------------------------------------------------------- | 106 // -------------------------------------------------------------------------- |
105 | 107 |
106 // Each row of our data is an array of values rather than a dictionary. This | 108 // Each row of our data is an array of values rather than a dictionary. This |
107 // avoids some overhead from repeating the key string multiple times, and | 109 // avoids some overhead from repeating the key string multiple times, and |
108 // speeds up the property accesses a bit. The following keys are well-known | 110 // speeds up the property accesses a bit. The following keys are well-known |
109 // indexes into the array for various properties. | 111 // indexes into the array for various properties. |
110 // | 112 // |
111 // Note that the declaration order will also define the default display order. | 113 // Note that the declaration order will also define the default display order. |
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1190 newRow[KEY_PROCESS_TYPE] = ptype; | 1192 newRow[KEY_PROCESS_TYPE] = ptype; |
1191 | 1193 |
1192 // Copy over the known properties which have a 1:1 mapping with JSON. | 1194 // Copy over the known properties which have a 1:1 mapping with JSON. |
1193 for (var k = BEGIN_KEY; k < END_KEY; ++k) { | 1195 for (var k = BEGIN_KEY; k < END_KEY; ++k) { |
1194 var inputJsonKey = KEY_PROPERTIES[k].inputJsonKey; | 1196 var inputJsonKey = KEY_PROPERTIES[k].inputJsonKey; |
1195 if (inputJsonKey != undefined) { | 1197 if (inputJsonKey != undefined) { |
1196 newRow[k] = getPropertyByPath(origRow, inputJsonKey); | 1198 newRow[k] = getPropertyByPath(origRow, inputJsonKey); |
1197 } | 1199 } |
1198 } | 1200 } |
1199 | 1201 |
| 1202 if (newRow[KEY_COUNT] == 0) { |
| 1203 // When resetting the data, it is possible for the backend to give us |
| 1204 // counts of "0". There is no point adding these rows (in fact they |
| 1205 // will cause us to do divide by zeros when calculating averages and |
| 1206 // stuff), so we skip past them. |
| 1207 continue; |
| 1208 } |
| 1209 |
1200 // Add our computed properties. | 1210 // Add our computed properties. |
1201 augmentDataRow(newRow); | 1211 augmentDataRow(newRow); |
1202 | 1212 |
1203 this.allData_.push(newRow); | 1213 this.allData_.push(newRow); |
1204 } | 1214 } |
1205 | 1215 |
1206 this.redrawData_(); | 1216 this.redrawData_(); |
1207 }, | 1217 }, |
1208 | 1218 |
1209 redrawData_: function() { | 1219 redrawData_: function() { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 this.currentSortKeys_ = INITIAL_SORT_KEYS.slice(0); | 1276 this.currentSortKeys_ = INITIAL_SORT_KEYS.slice(0); |
1267 this.currentGroupingKeys_ = INITIAL_GROUP_KEYS.slice(0); | 1277 this.currentGroupingKeys_ = INITIAL_GROUP_KEYS.slice(0); |
1268 | 1278 |
1269 this.fillGroupingDropdowns_(); | 1279 this.fillGroupingDropdowns_(); |
1270 this.fillSortingDropdowns_(); | 1280 this.fillSortingDropdowns_(); |
1271 | 1281 |
1272 $(EDIT_COLUMNS_LINK_ID).onclick = this.toggleEditColumns_.bind(this); | 1282 $(EDIT_COLUMNS_LINK_ID).onclick = this.toggleEditColumns_.bind(this); |
1273 | 1283 |
1274 $(MERGE_SIMILAR_THREADS_CHECKBOX_ID).onchange = | 1284 $(MERGE_SIMILAR_THREADS_CHECKBOX_ID).onchange = |
1275 this.onMergeSimilarThreadsCheckboxChanged_.bind(this); | 1285 this.onMergeSimilarThreadsCheckboxChanged_.bind(this); |
| 1286 |
| 1287 $(RESET_DATA_LINK_ID).onclick = |
| 1288 g_browserBridge.sendResetData.bind(g_browserBridge); |
1276 }, | 1289 }, |
1277 | 1290 |
1278 toggleEditColumns_: function() { | 1291 toggleEditColumns_: function() { |
1279 var n = $(EDIT_COLUMNS_ROW); | 1292 var n = $(EDIT_COLUMNS_ROW); |
1280 if (n.style.display == '') { | 1293 if (n.style.display == '') { |
1281 n.style.display = 'none'; | 1294 n.style.display = 'none'; |
1282 } else { | 1295 } else { |
1283 n.style.display = ''; | 1296 n.style.display = ''; |
1284 } | 1297 } |
1285 }, | 1298 }, |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1538 groupKey.push(entry); | 1551 groupKey.push(entry); |
1539 } | 1552 } |
1540 | 1553 |
1541 return JSON.stringify(groupKey); | 1554 return JSON.stringify(groupKey); |
1542 }; | 1555 }; |
1543 }, | 1556 }, |
1544 }; | 1557 }; |
1545 | 1558 |
1546 return MainView; | 1559 return MainView; |
1547 })(); | 1560 })(); |
OLD | NEW |