| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import logging | 4 import logging |
| 5 import os | 5 import os |
| 6 | 6 |
| 7 from metrics import Metric | 7 from metrics import Metric |
| 8 | 8 |
| 9 | 9 |
| 10 class MediaMetric(Metric): | 10 class MediaMetric(Metric): |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 """Create the media metrics for all media elements in the document.""" | 27 """Create the media metrics for all media elements in the document.""" |
| 28 if hasattr(page, 'skip_basic_metrics'): | 28 if hasattr(page, 'skip_basic_metrics'): |
| 29 self._skip_basic_metrics = page.skip_basic_metrics | 29 self._skip_basic_metrics = page.skip_basic_metrics |
| 30 tab.ExecuteJavaScript('window.__createMediaMetricsForDocument()') | 30 tab.ExecuteJavaScript('window.__createMediaMetricsForDocument()') |
| 31 | 31 |
| 32 def Stop(self, page, tab): | 32 def Stop(self, page, tab): |
| 33 self._results = tab.EvaluateJavaScript('window.__getAllMetrics()') | 33 self._results = tab.EvaluateJavaScript('window.__getAllMetrics()') |
| 34 | 34 |
| 35 def AddResults(self, tab, results): | 35 def AddResults(self, tab, results): |
| 36 """Reports all recorded metrics as Telemetry perf results.""" | 36 """Reports all recorded metrics as Telemetry perf results.""" |
| 37 assert self._results | |
| 38 trace_names = [] | 37 trace_names = [] |
| 39 for media_metric in self._results: | 38 for media_metric in self._results: |
| 40 trace_names.append(self._AddResultsForMediaElement(media_metric, results)) | 39 trace_names.append(self._AddResultsForMediaElement(media_metric, results)) |
| 41 | 40 |
| 42 return '_'.join(trace_names) or tab.url | 41 return '_'.join(trace_names) or tab.url |
| 43 | 42 |
| 44 def _AddResultsForMediaElement(self, media_metric, results): | 43 def _AddResultsForMediaElement(self, media_metric, results): |
| 45 """Reports metrics for one media element. | 44 """Reports metrics for one media element. |
| 46 | 45 |
| 47 Media metrics contain an ID identifying the media element and values: | 46 Media metrics contain an ID identifying the media element and values: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 71 AddOneResult('buffering_time', 'ms') | 70 AddOneResult('buffering_time', 'ms') |
| 72 AddOneResult('decoded_audio_bytes', 'bytes') | 71 AddOneResult('decoded_audio_bytes', 'bytes') |
| 73 AddOneResult('decoded_video_bytes', 'bytes') | 72 AddOneResult('decoded_video_bytes', 'bytes') |
| 74 AddOneResult('decoded_frame_count', 'frames') | 73 AddOneResult('decoded_frame_count', 'frames') |
| 75 AddOneResult('dropped_frame_count', 'frames') | 74 AddOneResult('dropped_frame_count', 'frames') |
| 76 AddOneResult('time_to_play', 'ms') | 75 AddOneResult('time_to_play', 'ms') |
| 77 | 76 |
| 78 AddOneResult('avg_loop_time', 'ms') | 77 AddOneResult('avg_loop_time', 'ms') |
| 79 AddOneResult('seek', 'ms') | 78 AddOneResult('seek', 'ms') |
| 80 return trace | 79 return trace |
| OLD | NEW |