OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/renderer_host/one_shot_metric_host.h" |
| 6 |
| 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 9 |
| 10 namespace content { |
| 11 |
| 12 // static |
| 13 void OneShotMetricHost::Create(mojom::OneShotMetricHostRequest request) { |
| 14 LOG(ERROR) << __func__; |
| 15 mojo::MakeStrongBinding(base::MakeUnique<OneShotMetricHost>(), |
| 16 std::move(request)); |
| 17 } |
| 18 |
| 19 OneShotMetricHost::OneShotMetricHost() { |
| 20 LOG(ERROR) << __func__; |
| 21 } |
| 22 |
| 23 OneShotMetricHost::~OneShotMetricHost() { |
| 24 LOG(ERROR) << __func__; |
| 25 if (!sample_) |
| 26 return; |
| 27 |
| 28 DCHECK(metric_); |
| 29 base::Histogram::FactoryGet(metric_->name_, metric_->min_, metric_->max_, |
| 30 metric_->bucket_count, |
| 31 base::HistogramBase::kUmaTargetedHistogramFlag) |
| 32 ->Add(*sample_); |
| 33 } |
| 34 |
| 35 void OneShotMetricHost::Initialize(const std::string& name, |
| 36 base::HistogramBase::Sample min, |
| 37 base::HistogramBase::Sample max, |
| 38 uint32_t bucket_count) { |
| 39 LOG(ERROR) << __func__; |
| 40 DCHECK(!metric_); |
| 41 metric_.reset(new Metric{name, min, max, bucket_count}); |
| 42 } |
| 43 |
| 44 void OneShotMetricHost::SetSample(base::HistogramBase::Sample sample) { |
| 45 DCHECK(metric_); |
| 46 sample_.reset(new base::HistogramBase::Sample{sample}); |
| 47 } |
| 48 |
| 49 } // namespace content |
OLD | NEW |