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

Unified Diff: tools/perf/metrics/media.js

Issue 21134002: Add Telemetry media loop action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 7 years, 4 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 | tools/perf/metrics/media.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/metrics/media.js
diff --git a/tools/perf/metrics/media.js b/tools/perf/metrics/media.js
index 7cef7cd0c74ce2794cc298b611dd176a6b397d07..8cd3dc23e0048820f5b3ad950aeeabb374fb95fe 100644
--- a/tools/perf/metrics/media.js
+++ b/tools/perf/metrics/media.js
@@ -54,6 +54,9 @@
this.element.addEventListener('willSeek', function (e) {
metric.onWillSeek(e);
}, false);
+ this.element.addEventListener('willLoop', function (e) {
+ metric.onWillLoop(e);
+ }, false);
}
HTMLMediaMetric.prototype = new MediaMetricBase();
@@ -85,6 +88,20 @@
this.element.addEventListener('seeked', onSeeked);
};
+ HTMLMediaMetric.prototype.onWillLoop = function(e) {
+ var loopTimer = new Timer();
+ var metric = this;
+ var loopCount = e.loopCount;
+ var onEndLoop = function(e) {
+ var actualDuration = loopTimer.stop();
+ var idealDuration = metric.element.duration * loopCount;
+ var avg_loop_time = (actualDuration - idealDuration) / loopCount;
+ metric.metrics['avg_loop_time'] = avg_loop_time.toFixed(3);
+ e.target.removeEventListener('endLoop', onEndLoop);
+ };
+ this.element.addEventListener('endLoop', onEndLoop);
+ };
+
HTMLMediaMetric.prototype.appendMetric = function(metric, value) {
if (!this.metrics[metric])
this.metrics[metric] = [];
« no previous file with comments | « no previous file | tools/perf/metrics/media.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698