Index: tools/perf/metrics/media.js |
diff --git a/tools/perf/metrics/media.js b/tools/perf/metrics/media.js |
index f2d466f615d282e8897ea46d95d5d2f15b23cd1c..4a1f6c7c3e0f33fbab92fc8c2f4463decc9aadd2 100644 |
--- a/tools/perf/metrics/media.js |
+++ b/tools/perf/metrics/media.js |
@@ -123,12 +123,17 @@ |
}; |
HTMLMediaMetric.prototype.getMetrics = function() { |
- this.metrics['decoded_frame_count'] = this.element.webkitDecodedFrameCount; |
- this.metrics['dropped_frame_count'] = this.element.webkitDroppedFrameCount; |
+ var decodedFrames = this.element.webkitDecodedFrameCount; |
+ var droppedFrames = this.element.webkitDroppedFrameCount; |
+ // Audio media does not report decoded/dropped frame count |
+ if (decodedFrames != undefined) |
+ this.metrics['decoded_frame_count'] = decodedFrames; |
+ if (droppedFrames != undefined) |
+ this.metrics['dropped_frame_count'] = droppedFrames; |
this.metrics['decoded_video_bytes'] = |
- this.element.webkitVideoDecodedByteCount; |
+ this.element.webkitVideoDecodedByteCount || 0; |
this.metrics['decoded_audio_bytes'] = |
- this.element.webkitAudioDecodedByteCount; |
+ this.element.webkitAudioDecodedByteCount || 0; |
return this.metrics; |
}; |
@@ -157,10 +162,16 @@ |
function checkElementIsNotBound(element) { |
if (!element) |
return; |
+ if (getMediaMetric(element)) |
+ throw new Error('Can not create MediaMetric for same element twice.'); |
+ } |
+ |
+ function getMediaMetric(element) { |
for (var i = 0; i < window.__mediaMetrics.length; i++) { |
if (window.__mediaMetrics[i].element == element) |
- throw new Error('Can not create MediaMetric for same element twice.'); |
+ return window.__mediaMetrics[i]; |
} |
+ return null; |
} |
function createMediaMetricsForDocument() { |
@@ -192,6 +203,7 @@ |
window.__globalCounter = 0; |
window.__mediaMetrics = []; |
+ window.__getMediaMetric = getMediaMetric; |
window.__getAllMetrics = getAllMetrics; |
window.__createMediaMetricsForDocument = createMediaMetricsForDocument; |
})(); |