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

Unified Diff: trunk/src/content/browser/resources/media/timeline_graph_view.js

Issue 15021010: Revert 199008 "Fixes a memory leak when running webrtc-internals..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 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
Index: trunk/src/content/browser/resources/media/timeline_graph_view.js
===================================================================
--- trunk/src/content/browser/resources/media/timeline_graph_view.js (revision 199028)
+++ trunk/src/content/browser/resources/media/timeline_graph_view.js (working copy)
@@ -214,9 +214,42 @@
* time range.
*/
drawTimeLabels: function(context, width, height, textHeight, startTime) {
- // Draw the labels 1 minute apart.
- var timeStep = 1000 * 60;
+ // Text for a time string to use in determining how far apart
+ // to place text labels.
+ var sampleText = (new Date(startTime)).toLocaleTimeString();
+ // The desired spacing for text labels.
+ var targetSpacing = context.measureText(sampleText).width +
+ LABEL_LABEL_HORIZONTAL_SPACING;
+
+ // The allowed time step values between adjacent labels. Anything much
+ // over a couple minutes isn't terribly realistic, given how much memory
+ // we use, and how slow a lot of the net-internals code is.
+ var timeStepValues = [
+ 1000, // 1 second
+ 1000 * 5,
+ 1000 * 30,
+ 1000 * 60, // 1 minute
+ 1000 * 60 * 5,
+ 1000 * 60 * 30,
+ 1000 * 60 * 60, // 1 hour
+ 1000 * 60 * 60 * 5
+ ];
+
+ // Find smallest time step value that gives us at least |targetSpacing|,
+ // if any.
+ var timeStep = null;
+ for (var i = 0; i < timeStepValues.length; ++i) {
+ if (timeStepValues[i] / DEFAULT_SCALE >= targetSpacing) {
+ timeStep = timeStepValues[i];
+ break;
+ }
+ }
+
+ // If no such value, give up.
+ if (!timeStep)
+ return;
+
// Find the time for the first label. This time is a perfect multiple of
// timeStep because of how UTC times work.
var time = Math.ceil(startTime / timeStep) * timeStep;

Powered by Google App Engine
This is Rietveld 408576698