| Index: content/browser/renderer_host/one_shot_metric_host.cc
|
| diff --git a/content/browser/renderer_host/one_shot_metric_host.cc b/content/browser/renderer_host/one_shot_metric_host.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d635a4c6a1e7a2738e7f30cf02b367105d2663df
|
| --- /dev/null
|
| +++ b/content/browser/renderer_host/one_shot_metric_host.cc
|
| @@ -0,0 +1,49 @@
|
| +// Copyright 2017 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.
|
| +
|
| +#include "content/browser/renderer_host/one_shot_metric_host.h"
|
| +
|
| +#include "base/metrics/histogram_macros.h"
|
| +#include "mojo/public/cpp/bindings/strong_binding.h"
|
| +
|
| +namespace content {
|
| +
|
| +// static
|
| +void OneShotMetricHost::Create(mojom::OneShotMetricHostRequest request) {
|
| + LOG(ERROR) << __func__;
|
| + mojo::MakeStrongBinding(base::MakeUnique<OneShotMetricHost>(),
|
| + std::move(request));
|
| +}
|
| +
|
| +OneShotMetricHost::OneShotMetricHost() {
|
| + LOG(ERROR) << __func__;
|
| +}
|
| +
|
| +OneShotMetricHost::~OneShotMetricHost() {
|
| + LOG(ERROR) << __func__;
|
| + if (!sample_)
|
| + return;
|
| +
|
| + DCHECK(metric_);
|
| + base::Histogram::FactoryGet(metric_->name_, metric_->min_, metric_->max_,
|
| + metric_->bucket_count,
|
| + base::HistogramBase::kUmaTargetedHistogramFlag)
|
| + ->Add(*sample_);
|
| +}
|
| +
|
| +void OneShotMetricHost::Initialize(const std::string& name,
|
| + base::HistogramBase::Sample min,
|
| + base::HistogramBase::Sample max,
|
| + uint32_t bucket_count) {
|
| + LOG(ERROR) << __func__;
|
| + DCHECK(!metric_);
|
| + metric_.reset(new Metric{name, min, max, bucket_count});
|
| +}
|
| +
|
| +void OneShotMetricHost::SetSample(base::HistogramBase::Sample sample) {
|
| + DCHECK(metric_);
|
| + sample_.reset(new base::HistogramBase::Sample{sample});
|
| +}
|
| +
|
| +} // namespace content
|
|
|