Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <!-- | |
| 3 Copyright 2017 The Chromium Authors. All rights reserved. | |
| 4 Use of this source code is governed by a BSD-style license that can be | |
| 5 found in the LICENSE file. | |
|
CalebRouleau
2017/08/18 22:10:03
There should be overall description of what mediaM
charliea (OOO until 10-5)
2017/08/25 19:35:09
There's definitely a way to add an OWNERS file and
benjhayden
2017/08/28 17:40:15
+100, thank you!
johnchen
2017/08/29 22:45:46
Added comments about the purpose of this metric, w
| |
| 6 --> | |
| 7 | |
| 8 <link rel="import" href="/tracing/metrics/metric_registry.html"> | |
| 9 <link rel="import" href="/tracing/value/histogram.html"> | |
| 10 | |
| 11 <script> | |
| 12 'use strict'; | |
| 13 | |
| 14 tr.exportTo('tr.metrics', function() { | |
| 15 function mediaMetric(histograms, model) { | |
| 16 let playStart; | |
| 17 let timeToPlay; | |
| 18 | |
| 19 for (const event of model.getDescendantEvents()) { | |
|
benjhayden
2017/08/28 17:40:15
Metric performance doesn't matter terribly much wh
johnchen
2017/08/29 22:45:46
Modified the code to look for events in the render
| |
| 20 if (event.title === 'EventDispatch') { | |
| 21 const type = event.args.data.type; | |
| 22 if (type === 'willPlay') { | |
|
CalebRouleau
2017/08/18 22:10:03
Discussed offline: maybe we should either use "wil
benjhayden
2017/08/28 17:40:15
This is a metric design question, which is mostly
| |
| 23 playStart = event.start; | |
| 24 } else if (type === 'play' || type === 'loadedmetadata') { | |
| 25 if (playStart === undefined) { | |
| 26 playStart = event.start; | |
| 27 } | |
| 28 } else if (type === 'playing') { | |
| 29 if (playStart !== undefined && timeToPlay === undefined) { | |
| 30 timeToPlay = event.start - playStart; | |
|
nednguyen
2017/08/18 23:50:55
How can we be sure that these two events belong to
johnchen
2017/08/29 22:45:46
For now we only support one video on the page, tho
| |
| 31 } | |
| 32 } | |
| 33 } | |
| 34 } | |
| 35 | |
| 36 if (timeToPlay !== undefined) { | |
| 37 addTimeValue(histograms, 'time_to_play', timeToPlay); | |
|
CalebRouleau
2017/08/18 22:10:03
Is there at place where time_to_play is documented
charliea (OOO until 10-5)
2017/08/25 19:35:09
Yea - I agree with you in this, but I'm not sure t
johnchen
2017/08/29 22:45:46
Added comments in the file header.
| |
| 38 } | |
| 39 } | |
| 40 | |
| 41 function addTimeValue(histograms, name, value) { | |
|
benjhayden
2017/08/28 17:40:15
Instead of defining this helper function, please u
johnchen
2017/08/29 22:45:46
Done.
| |
| 42 const hist = new tr.v.Histogram(name, | |
| 43 tr.b.Unit.byName.timeDurationInMs_smallerIsBetter); | |
| 44 hist.addSample(value); | |
| 45 histograms.addHistogram(hist); | |
| 46 } | |
| 47 | |
| 48 tr.metrics.MetricRegistry.register(mediaMetric); | |
| 49 | |
| 50 return { | |
| 51 mediaMetric, | |
| 52 }; | |
| 53 }); | |
| 54 </script> | |
| OLD | NEW |