Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1203)

Side by Side Diff: chrome/browser/resources/tracking.js

Issue 8503027: Add support for process ID and process type to about:tracking2. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix comment typo Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 comma-separate PID numbers (since they aren't
9 // really quantities).
10
8 /** 11 /**
9 * Main entry point called once the page has loaded. 12 * Main entry point called once the page has loaded.
10 */ 13 */
11 function onLoad() { 14 function onLoad() {
12 g_browserBridge = new BrowserBridge(); 15 g_browserBridge = new BrowserBridge();
13 g_mainView = new MainView(); 16 g_mainView = new MainView();
14 17
15 // Ask the browser to send us the current data. 18 // Ask the browser to send us the current data.
16 g_browserBridge.sendGetData(); 19 g_browserBridge.sendGetData();
17 } 20 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 var KEY_BIRTH_THREAD = 'birth_thread'; 114 var KEY_BIRTH_THREAD = 'birth_thread';
112 var KEY_DEATH_THREAD = 'death_thread'; 115 var KEY_DEATH_THREAD = 'death_thread';
113 var KEY_FUNCTION_NAME = 'location.function_name'; 116 var KEY_FUNCTION_NAME = 'location.function_name';
114 var KEY_FILE_NAME = 'location.file_name'; 117 var KEY_FILE_NAME = 'location.file_name';
115 var KEY_LINE_NUMBER = 'location.line_number'; 118 var KEY_LINE_NUMBER = 'location.line_number';
116 var KEY_COUNT = 'death_data.count'; 119 var KEY_COUNT = 'death_data.count';
117 var KEY_QUEUE_TIME = 'death_data.queue_ms'; 120 var KEY_QUEUE_TIME = 'death_data.queue_ms';
118 var KEY_MAX_QUEUE_TIME = 'death_data.queue_ms_max'; 121 var KEY_MAX_QUEUE_TIME = 'death_data.queue_ms_max';
119 var KEY_RUN_TIME = 'death_data.run_ms'; 122 var KEY_RUN_TIME = 'death_data.run_ms';
120 var KEY_MAX_RUN_TIME = 'death_data.run_ms_max'; 123 var KEY_MAX_RUN_TIME = 'death_data.run_ms_max';
124 var KEY_PROCESS_ID = 'process_id';
125 var KEY_PROCESS_TYPE = 'process_type';
121 126
122 // The following are computed properties which we add to each row. They 127 // The following are computed properties which we add to each row. They
123 // are not present in the original JSON stream. 128 // are not present in the original JSON stream.
124 var KEY_AVG_QUEUE_TIME = 'avg_queue_ms'; 129 var KEY_AVG_QUEUE_TIME = 'avg_queue_ms';
125 var KEY_AVG_RUN_TIME = 'avg_run_ms'; 130 var KEY_AVG_RUN_TIME = 'avg_run_ms';
126 var KEY_SOURCE_LOCATION = 'source_location'; 131 var KEY_SOURCE_LOCATION = 'source_location';
127 132
128 // -------------------------------------------------------------------------- 133 // --------------------------------------------------------------------------
129 // Aggregators 134 // Aggregators
130 // -------------------------------------------------------------------------- 135 // --------------------------------------------------------------------------
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 ]); 267 ]);
263 268
264 /** 269 /**
265 * Enumerates information about various keys. Such as whether their data is 270 * Enumerates information about various keys. Such as whether their data is
266 * expected to be numeric or is a string, a descriptive name (title) for the 271 * expected to be numeric or is a string, a descriptive name (title) for the
267 * property, and what function should be used to aggregate the property when 272 * property, and what function should be used to aggregate the property when
268 * displayed in a column. 273 * displayed in a column.
269 */ 274 */
270 var KEY_PROPERTIES = {}; 275 var KEY_PROPERTIES = {};
271 276
277 KEY_PROPERTIES[KEY_PROCESS_ID] = {
278 name: 'PID',
279 type: 'number',
280 aggregator: UniquifyAggregator,
281 };
282
283 KEY_PROPERTIES[KEY_PROCESS_TYPE] = {
284 name: 'Process type',
285 type: 'string',
286 aggregator: UniquifyAggregator,
287 };
288
272 KEY_PROPERTIES[KEY_BIRTH_THREAD] = { 289 KEY_PROPERTIES[KEY_BIRTH_THREAD] = {
273 name: 'Birth thread', 290 name: 'Birth thread',
274 type: 'string', 291 type: 'string',
275 aggregator: UniquifyAggregator, 292 aggregator: UniquifyAggregator,
276 comparator: threadNameComparator, 293 comparator: threadNameComparator,
277 }; 294 };
278 295
279 KEY_PROPERTIES[KEY_DEATH_THREAD] = { 296 KEY_PROPERTIES[KEY_DEATH_THREAD] = {
280 name: 'Death thread', 297 name: 'Death thread',
281 type: 'string', 298 type: 'string',
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 var ALL_KEYS = [ 383 var ALL_KEYS = [
367 KEY_COUNT, 384 KEY_COUNT,
368 KEY_RUN_TIME, 385 KEY_RUN_TIME,
369 KEY_AVG_RUN_TIME, 386 KEY_AVG_RUN_TIME,
370 KEY_MAX_RUN_TIME, 387 KEY_MAX_RUN_TIME,
371 KEY_QUEUE_TIME, 388 KEY_QUEUE_TIME,
372 KEY_AVG_QUEUE_TIME, 389 KEY_AVG_QUEUE_TIME,
373 KEY_MAX_QUEUE_TIME, 390 KEY_MAX_QUEUE_TIME,
374 KEY_BIRTH_THREAD, 391 KEY_BIRTH_THREAD,
375 KEY_DEATH_THREAD, 392 KEY_DEATH_THREAD,
393 KEY_PROCESS_TYPE,
394 KEY_PROCESS_ID,
376 KEY_FUNCTION_NAME, 395 KEY_FUNCTION_NAME,
377 KEY_SOURCE_LOCATION, 396 KEY_SOURCE_LOCATION,
378 KEY_FILE_NAME, 397 KEY_FILE_NAME,
379 KEY_LINE_NUMBER, 398 KEY_LINE_NUMBER,
380 ]; 399 ];
381 400
382 // -------------------------------------------------------------------------- 401 // --------------------------------------------------------------------------
383 // Default settings 402 // Default settings
384 // -------------------------------------------------------------------------- 403 // --------------------------------------------------------------------------
385 404
386 /** 405 /**
387 * List of keys for those properties which we want to initially omit 406 * List of keys for those properties which we want to initially omit
388 * from the table. (They can be re-enabled by clicking [Edit columns]). 407 * from the table. (They can be re-enabled by clicking [Edit columns]).
389 */ 408 */
390 var INITIALLY_HIDDEN_KEYS = [ 409 var INITIALLY_HIDDEN_KEYS = [
391 KEY_FILE_NAME, 410 KEY_FILE_NAME,
392 KEY_LINE_NUMBER, 411 KEY_LINE_NUMBER,
393 KEY_QUEUE_TIME, 412 KEY_QUEUE_TIME,
394 ]; 413 ];
395 414
396 /** 415 /**
397 * The ordered list of grouping choices to expose in the "Group by" 416 * The ordered list of grouping choices to expose in the "Group by"
398 * dropdowns. We don't include the numeric properties, since they 417 * dropdowns. We don't include the numeric properties, since they
399 * leads to awkward bucketing. 418 * leads to awkward bucketing.
400 */ 419 */
401 var GROUPING_DROPDOWN_CHOICES = [ 420 var GROUPING_DROPDOWN_CHOICES = [
421 KEY_PROCESS_TYPE,
422 KEY_PROCESS_ID,
402 KEY_BIRTH_THREAD, 423 KEY_BIRTH_THREAD,
403 KEY_DEATH_THREAD, 424 KEY_DEATH_THREAD,
404 KEY_FUNCTION_NAME, 425 KEY_FUNCTION_NAME,
405 KEY_SOURCE_LOCATION, 426 KEY_SOURCE_LOCATION,
406 KEY_FILE_NAME, 427 KEY_FILE_NAME,
407 KEY_LINE_NUMBER, 428 KEY_LINE_NUMBER,
408 ]; 429 ];
409 430
410 /** 431 /**
411 * The ordered list of sorting choices to expose in the "Sort by" 432 * The ordered list of sorting choices to expose in the "Sort by"
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 948
928 /** 949 /**
929 * @constructor 950 * @constructor
930 */ 951 */
931 function MainView() { 952 function MainView() {
932 this.init_(); 953 this.init_();
933 } 954 }
934 955
935 MainView.prototype = { 956 MainView.prototype = {
936 addData: function(data) { 957 addData: function(data) {
937 if (this.allData_) { 958 var pid = data[KEY_PROCESS_ID];
938 // TODO(eroman): once the browser is calling receivedData() multiple 959 var ptype = data[KEY_PROCESS_TYPE];
939 // times, will need to concatenate it. For now disregard any call after 960
940 // the first. This way when the C++ side change lands to call multiple 961 // Augment each data row with the process information.
941 // times, the javascript will keep working until I upgrade it. 962 var rows = data.list;
942 return; 963 for (var i = 0; i < rows.length; ++i) {
964 var e = rows[i];
965 e[KEY_PROCESS_ID] = pid;
966 e[KEY_PROCESS_TYPE] = ptype;
943 } 967 }
944 this.allData_ = data; 968
969 this.allData_ = this.allData_.concat(rows);
945 this.redrawData_(); 970 this.redrawData_();
946 }, 971 },
947 972
948 redrawData_: function() { 973 redrawData_: function() {
949 var data = this.allData_; 974 var data = this.allData_;
950 975
951 // Figure out what columns to include, based on the selected checkboxes. 976 // Figure out what columns to include, based on the selected checkboxes.
952 var columns = []; 977 var columns = [];
953 for (var i = 0; i < ALL_TABLE_COLUMNS.length; ++i) { 978 for (var i = 0; i < ALL_TABLE_COLUMNS.length; ++i) {
954 var key = ALL_TABLE_COLUMNS[i]; 979 var key = ALL_TABLE_COLUMNS[i];
955 if (this.selectionCheckboxes_[key].checked) { 980 if (this.selectionCheckboxes_[key].checked) {
956 columns.push(key); 981 columns.push(key);
957 } 982 }
958 } 983 }
959 984
960 // Group, aggregate, filter, and sort the data. 985 // Group, aggregate, filter, and sort the data.
961 var groupedData = prepareData( 986 var groupedData = prepareData(
962 data.list, this.getGroupingFunction_(), this.getFilterFunction_(), 987 data, this.getGroupingFunction_(), this.getFilterFunction_(),
963 this.getSortingFunction_()); 988 this.getSortingFunction_());
964 989
965 // Figure out a display order for the groups. 990 // Figure out a display order for the groups.
966 var groupKeys = getDictionaryKeys(groupedData); 991 var groupKeys = getDictionaryKeys(groupedData);
967 groupKeys.sort(this.getGroupSortingFunction_()); 992 groupKeys.sort(this.getGroupSortingFunction_());
968 993
969 // Clear the results div, sine we may be overwriting older data. 994 // Clear the results div, sine we may be overwriting older data.
970 var parent = $(RESULTS_DIV_ID); 995 var parent = $(RESULTS_DIV_ID);
971 parent.innerHTML = ''; 996 parent.innerHTML = '';
972 997
(...skipping 18 matching lines...) Expand all
991 var groupKeyString = groupKeys[i]; 1016 var groupKeyString = groupKeys[i];
992 var groupData = groupedData[groupKeyString]; 1017 var groupData = groupedData[groupKeyString];
993 var groupKey = JSON.parse(groupKeyString); 1018 var groupKey = JSON.parse(groupKeyString);
994 1019
995 drawGroup(parent, groupKey, groupData, columns, 1020 drawGroup(parent, groupKey, groupData, columns,
996 columnOnClickHandler, this.currentSortKeys_); 1021 columnOnClickHandler, this.currentSortKeys_);
997 } 1022 }
998 }, 1023 },
999 1024
1000 init_: function() { 1025 init_: function() {
1026 this.allData_ = [];
1001 this.fillSelectionCheckboxes_($(COLUMN_TOGGLES_CONTAINER_ID)); 1027 this.fillSelectionCheckboxes_($(COLUMN_TOGGLES_CONTAINER_ID));
1002 1028
1003 $(FILTER_SEARCH_ID).onsearch = this.onChangedFilter_.bind(this); 1029 $(FILTER_SEARCH_ID).onsearch = this.onChangedFilter_.bind(this);
1004 1030
1005 this.currentSortKeys_ = INITIAL_SORT_KEYS.slice(0); 1031 this.currentSortKeys_ = INITIAL_SORT_KEYS.slice(0);
1006 this.currentGroupingKeys_ = INITIAL_GROUP_KEYS.slice(0); 1032 this.currentGroupingKeys_ = INITIAL_GROUP_KEYS.slice(0);
1007 1033
1008 this.fillGroupingDropdowns_(); 1034 this.fillGroupingDropdowns_();
1009 this.fillSortingDropdowns_(); 1035 this.fillSortingDropdowns_();
1010 1036
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 groupKey.push(entry); 1293 groupKey.push(entry);
1268 } 1294 }
1269 1295
1270 return JSON.stringify(groupKey); 1296 return JSON.stringify(groupKey);
1271 }; 1297 };
1272 }, 1298 },
1273 }; 1299 };
1274 1300
1275 return MainView; 1301 return MainView;
1276 })(); 1302 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698