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

Unified Diff: tools/perf/perf_tools/media_metrics.js

Issue 19482009: Telemetry media Seek action and metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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/perf_tools/media_metrics.py » ('j') | tools/perf/perf_tools/media_metrics.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/perf_tools/media_metrics.js
diff --git a/tools/perf/perf_tools/media_metrics.js b/tools/perf/perf_tools/media_metrics.js
index 8b0938b76faf351fc0876805471115c188afa53c..0bbec913e8de77911c91a0c407386bad8d9bdaf7 100644
--- a/tools/perf/perf_tools/media_metrics.js
+++ b/tools/perf/perf_tools/media_metrics.js
@@ -1,4 +1,4 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,10 +13,6 @@
this.metrics = {};
this.id = '';
this.element = element;
- // Listen to when a Telemetry 'Play' action gets called.
- // TODO(shadi): Add event listeners for other media actions here.
- if (this.element)
- this.element.addEventListener('willPlay', this.onWillPlay, false);
}
MediaMetricBase.prototype.getMetrics = function() {
@@ -30,10 +26,6 @@
};
};
- MediaMetricBase.prototype.onWillPlay = function() {
- this.playbackTimer = new Timer();
- };
-
function HTMLMediaMetric(element) {
MediaMetricBase.prototype.constructor.call(this, element);
// Set the basic event handlers for HTML5 media element.
@@ -54,10 +46,19 @@
metric.onEnded(e);
});
this.setID();
+
+ // Listen to when a Telemetry actions gets called.
+ this.element.addEventListener('willPlay', function (e) {
+ metric.onWillPlay(e);
+ }, false);
+ this.element.addEventListener('willSeek', function (e) {
+ metric.onWillSeek(e);
+ }, false);
}
HTMLMediaMetric.prototype = new MediaMetricBase();
HTMLMediaMetric.prototype.constructor = HTMLMediaMetric;
+
HTMLMediaMetric.prototype.setID = function() {
if (this.element.src)
this.id = this.element.src.substring(this.element.src.lastIndexOf("/")+1);
@@ -67,16 +68,29 @@
this.id = 'media_' + window.__globalCounter++;
};
- HTMLMediaMetric.prototype.getMetrics = function() {
- this.metrics['decoded_frame_count'] = this.element.webkitDecodedFrameCount;
- this.metrics['dropped_frame_count'] = this.element.webkitDroppedFrameCount;
- this.metrics['decoded_video_bytes'] =
- this.element.webkitVideoDecodedByteCount;
- this.metrics['decoded_audio_bytes'] =
- this.element.webkitAudioDecodedByteCount;
- return this.metrics;
+ HTMLMediaMetric.prototype.onWillPlay = function(e) {
+ this.playbackTimer = new Timer();
};
+ HTMLMediaMetric.prototype.onWillSeek = function(e) {
+ var seekLabel = '';
+ if (e.seekLabel)
+ seekLabel = '_' + e.seekLabel;
+ var metric = this;
+ var onSeeked = function(e) {
+ metric.appendMetric('seek' + seekLabel, metric.seekTimer.stop())
+ e.target.removeEventListener('seeked', onSeeked);
+ };
+ this.seekTimer = new Timer();
+ this.element.addEventListener('seeked', onSeeked);
+ };
+
+ HTMLMediaMetric.prototype.appendMetric = function(metric, value) {
+ if (!this.metrics[metric])
+ this.metrics[metric] = [];
+ this.metrics[metric].push(value);
+ }
+
HTMLMediaMetric.prototype.onPlaying = function(event) {
// Playing event can fire more than once if seeking.
if (!this.metrics['time_to_play'])
@@ -87,6 +101,16 @@
this.metrics['playback_time'] = this.playbackTimer.stop();
};
+ HTMLMediaMetric.prototype.getMetrics = function() {
+ this.metrics['decoded_frame_count'] = this.element.webkitDecodedFrameCount;
+ this.metrics['dropped_frame_count'] = this.element.webkitDroppedFrameCount;
+ this.metrics['decoded_video_bytes'] =
+ this.element.webkitVideoDecodedByteCount;
+ this.metrics['decoded_audio_bytes'] =
+ this.element.webkitAudioDecodedByteCount;
+ return this.metrics;
+ };
+
function MediaMetric(element) {
if (element instanceof HTMLMediaElement)
return new HTMLMediaMetric(element);
« no previous file with comments | « no previous file | tools/perf/perf_tools/media_metrics.py » ('j') | tools/perf/perf_tools/media_metrics.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698