Add support for single sample metrics.
Single sample metrics offer a mechanism for clients to modify a histogram sample repeatedly while having it only reported once; either upon destruction of a helper class or at process termination. This is helpful since the fast shutdown path simply kills renderer processes without going through any destructors. In this case we lose histogram values that might otherwise be reported at that time. In media/ code we've created a cumbersome proxy mechanism which sends histogram values like this to the browser process and records them there (see WatchTimeReporter and MediaInternals interactions). Single sample histograms are implemented through a new mojo service hosted by the browser process that receives samples and logs the last received sample upon mojo channel closure. base:: shims are provided so that these metrics can be created by anyone in the renderer process. For non-renderer processes a default implementation is provided without the mojo channel behavior. Usage looks like the following: std::unique_ptr<base::SingleSampleMetric> metric( base::SingleSampleMetricsFactory::Get()->CreateCustomCountsMetric( "Media.VideoRenderer.CadenceChanges", 1, 10, 10)); metric->SetSample(1); metric->SetSample(2); metric->SetSample(3); metric.reset(); Only the last sample (3) would end up being reported to the histogram. BUG=689751 TEST=new tests Review-Url: https://codereview.chromium.org/2687583002 Cr-Commit-Position: refs/heads/master@{#469524}
Showing
Please register or sign in to comment