Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Side by Side Diff: content/browser/renderer_host/one_shot_metric_host.cc

Issue 2687583002: Add support for single sample metrics. (Closed)
Patch Set: Add mojo approach. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698