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

Unified Diff: chrome/browser/resources/memory_internals/memory_internals.js

Issue 208833003: Show time in hours, minutes and seconds in chrome://memory-internals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved secondsToHMS() into the annonymous function Created 6 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/memory_internals/memory_internals.js
diff --git a/chrome/browser/resources/memory_internals/memory_internals.js b/chrome/browser/resources/memory_internals/memory_internals.js
index 5bb10c7947a7d22f4f93c95640ee6e6799829065..5a1d310c6361c02297fed787613a1e339a0ffcf6 100644
--- a/chrome/browser/resources/memory_internals/memory_internals.js
+++ b/chrome/browser/resources/memory_internals/memory_internals.js
@@ -30,8 +30,8 @@ var MainView = (function() {
$('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));
this.updateSnapshot(browser['processes']);
this.updateExtensions(browser['extensions']);
@@ -136,7 +136,7 @@ var MainView = (function() {
var history = tab['history'][l];
var title = (history['title'] == '') ? history['url'] : history['title'];
var url = '<a href="' + history['url'] + '">' + HTMLEscape(title) +
- '</a> (' + history['time'] + ' sec. ago)';
+ '</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;
})();
« 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