diff options
Diffstat (limited to 'chromium/chrome/browser/resources/memory_internals/memory_internals.js')
-rw-r--r-- | chromium/chrome/browser/resources/memory_internals/memory_internals.js | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/chromium/chrome/browser/resources/memory_internals/memory_internals.js b/chromium/chrome/browser/resources/memory_internals/memory_internals.js index 8124b6b98c5..5a1d310c636 100644 --- a/chromium/chrome/browser/resources/memory_internals/memory_internals.js +++ b/chromium/chrome/browser/resources/memory_internals/memory_internals.js @@ -25,16 +25,16 @@ var MainView = (function() { * @param {Object} Information about memory in JSON format. */ onSetSnapshot: function(browser) { - this.updateSnapshot(browser['processes']); - this.updateExtensions(browser['extensions']); + $('json').textContent = JSON.stringify(browser); + $('json').style.display = 'block'; $('os-value').textContent = browser['os'] + ' (' + browser['os_version'] + ')'; - $('uptime-value').textContent = Math.floor(browser['uptime'] / 1000) + - ' sec'; + $('uptime-value').textContent = + secondsToHMS(Math.floor(browser['uptime'] / 1000)); - $('json').textContent = JSON.stringify(browser); - $('json').style.display = 'block'; + this.updateSnapshot(browser['processes']); + this.updateExtensions(browser['extensions']); }, /** @@ -63,7 +63,7 @@ var MainView = (function() { break; case 'process-info': value = process['type']; - if (process['type'].match(/^Tab/)) { + if (process['type'].match(/^Tab/) && 'history' in process) { // Append each tab's history. for (var j = 0; j < process['history'].length; ++j) { value += '<dl><dt>History ' + j + ':' + @@ -135,8 +135,8 @@ var MainView = (function() { for (var l in tab['history']) { var history = tab['history'][l]; var title = (history['title'] == '') ? history['url'] : history['title']; - var url = '<a href="' + history['url'] + '">' + title + '</a> (' + - history['time'] + ' sec. ago)'; + var url = '<a href="' + history['url'] + '">' + HTMLEscape(title) + + '</a> (' + secondsToHMS(history['time']) + ' ago)'; if (l == tab['index']) { url = '<strong>' + url + '</strong>'; } @@ -145,6 +145,22 @@ var MainView = (function() { return line; }; + /** + * Produces a readable string int the format '<HH> hours <MM> min. <SS> sec.' + * representing the amount of time provided as the number of seconds. + * @param {number} totalSeconds The total amount of seconds. + * @return {string} The formatted HH hours/hours MM min. SS sec. string + */ + function secondsToHMS(totalSeconds) { + totalSeconds = Number(totalSeconds); + var hour = Math.floor(totalSeconds / 3600); + var min = Math.floor(totalSeconds % 3600 / 60); + var sec = Math.floor(totalSeconds % 60); + return (hour > 0 ? (hour + (hour > 1 ? ' hours ' : ' hour ')) : '') + + (min > 0 ? (min + ' min. ') : '') + + (sec + ' sec. '); + } + return MainView; })(); |