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

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

Issue 8555028: Change the "source location" column on about:profiler to only display the filename (rather than t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' 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 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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 function setSelectedOptionByValue(select, value) { 696 function setSelectedOptionByValue(select, value) {
697 for (var i = 0; i < select.options.length; ++i) { 697 for (var i = 0; i < select.options.length; ++i) {
698 if (select.options[i].value == value) { 698 if (select.options[i].value == value) {
699 select.options[i].selected = true; 699 select.options[i].selected = true;
700 return true; 700 return true;
701 } 701 }
702 } 702 }
703 return false; 703 return false;
704 } 704 }
705 705
706 /**
707 * Return the last component in a path which is separated by either forward
708 * slashes or backslashes.
709 */
710 function getFilenameFromPath(path) {
711 var lastSlash = Math.max(path.lastIndexOf('/'),
712 path.lastIndexOf('\\'));
713 if (lastSlash == -1)
714 return path;
715
716 return path.substr(lastSlash + 1);
717 }
718
706 // -------------------------------------------------------------------------- 719 // --------------------------------------------------------------------------
707 // Functions that augment, bucket, and compute aggregates for the input data. 720 // Functions that augment, bucket, and compute aggregates for the input data.
708 // -------------------------------------------------------------------------- 721 // --------------------------------------------------------------------------
709 722
710 /** 723 /**
711 * Selects all the data in |rows| which are matched by |filterFunc|, and 724 * Selects all the data in |rows| which are matched by |filterFunc|, and
712 * buckets the results using |entryToGroupKeyFunc|. For each bucket aggregates 725 * buckets the results using |entryToGroupKeyFunc|. For each bucket aggregates
713 * are computed, and the results are sorted. 726 * are computed, and the results are sorted.
714 * 727 *
715 * Returns a dictionary whose keys are the group name, and the value is an 728 * Returns a dictionary whose keys are the group name, and the value is an
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 */ 1006 */
994 function drawValueToCell(td, key, value) { 1007 function drawValueToCell(td, key, value) {
995 // Get a text representation of the value. 1008 // Get a text representation of the value.
996 var text = getTextValueForProperty(key, value); 1009 var text = getTextValueForProperty(key, value);
997 1010
998 // Apply the desired cell alignment. 1011 // Apply the desired cell alignment.
999 var cellAlignment = KEY_PROPERTIES[key].cellAlignment; 1012 var cellAlignment = KEY_PROPERTIES[key].cellAlignment;
1000 if (cellAlignment) 1013 if (cellAlignment)
1001 td.align = cellAlignment; 1014 td.align = cellAlignment;
1002 1015
1003 var parent = td;
1004
1005 if (key == KEY_SOURCE_LOCATION) { 1016 if (key == KEY_SOURCE_LOCATION) {
1006 // Linkify the source column so it jumps to the source code. This doesn't 1017 // Linkify the source column so it jumps to the source code. This doesn't
1007 // take into account the particular code this build was compiled from, or 1018 // take into account the particular code this build was compiled from, or
1008 // local edits to source. It should however work correctly for top of tree 1019 // local edits to source. It should however work correctly for top of tree
1009 // builds. 1020 // builds.
1010 var m = /^(.*) \[(\d+)\]$/.exec(text); 1021 var m = /^(.*) \[(\d+)\]$/.exec(text);
1011 if (m) { 1022 if (m) {
1012 var link = addNode(td, 'a'); 1023 var filepath = m[1];
1024 var filename = getFilenameFromPath(filepath);
1025 var linenumber = m[2];
1026
1027 var link = addNode(td, 'a', filename + ' [' + linenumber + ']');
1013 // http://chromesrc.appspot.com is a server I wrote specifically for 1028 // http://chromesrc.appspot.com is a server I wrote specifically for
1014 // this task. It redirects to the appropriate source file; the file 1029 // this task. It redirects to the appropriate source file; the file
1015 // paths given by the compiler can be pretty crazy and different 1030 // paths given by the compiler can be pretty crazy and different
1016 // between platforms. 1031 // between platforms.
1017 link.href = 'http://chromesrc.appspot.com/?path=' + 1032 link.href = 'http://chromesrc.appspot.com/?path=' +
1018 encodeURIComponent(m[1]) + '&line=' + m[2]; 1033 encodeURIComponent(filepath) + '&line=' + linenumber;
1019 parent = link; 1034 return;
1020 } 1035 }
1021 } 1036 }
1022 1037
1023 // String values can get pretty long. If the string contains no spaces, then 1038 // String values can get pretty long. If the string contains no spaces, then
1024 // CSS fails to wrap it, and it overflows the cell causing the table to get 1039 // CSS fails to wrap it, and it overflows the cell causing the table to get
1025 // really big. We solve this using a hack: insert a <wbr> element after 1040 // really big. We solve this using a hack: insert a <wbr> element after
1026 // every single character. This will allow the rendering engine to wrap the 1041 // every single character. This will allow the rendering engine to wrap the
1027 // value, and hence avoid it overflowing! 1042 // value, and hence avoid it overflowing!
1028 var kMinLengthBeforeWrap = 20; 1043 var kMinLengthBeforeWrap = 20;
1029 1044
1030 addText(parent, text.substr(0, kMinLengthBeforeWrap)); 1045 addText(td, text.substr(0, kMinLengthBeforeWrap));
1031 for (var i = kMinLengthBeforeWrap; i < text.length; ++i) { 1046 for (var i = kMinLengthBeforeWrap; i < text.length; ++i) {
1032 addNode(parent, 'wbr'); 1047 addNode(td, 'wbr');
1033 addText(parent, text.substr(i, 1)); 1048 addText(td, text.substr(i, 1));
1034 } 1049 }
1035 } 1050 }
1036 1051
1037 function drawTableBody(tbody, rows, columns) { 1052 function drawTableBody(tbody, rows, columns) {
1038 for (var i = 0; i < rows.length; ++i) { 1053 for (var i = 0; i < rows.length; ++i) {
1039 var e = rows[i]; 1054 var e = rows[i];
1040 1055
1041 var tr = addNode(tbody, 'tr'); 1056 var tr = addNode(tbody, 'tr');
1042 1057
1043 for (var c = 0; c < columns.length; ++c) { 1058 for (var c = 0; c < columns.length; ++c) {
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 groupKey.push(entry); 1538 groupKey.push(entry);
1524 } 1539 }
1525 1540
1526 return JSON.stringify(groupKey); 1541 return JSON.stringify(groupKey);
1527 }; 1542 };
1528 }, 1543 },
1529 }; 1544 };
1530 1545
1531 return MainView; 1546 return MainView;
1532 })(); 1547 })();
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