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

Side by Side Diff: components/ukm/public/ukm_entry_builder.cc

Issue 2883563002: Refactor UKM interface for mojo-ification (Closed)
Patch Set: Fix uma_session_stats.cc Created 3 years, 7 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 "components/ukm/public/ukm_entry_builder.h"
6
7 #include <memory>
8
9 #include "base/metrics/metrics_hashes.h"
10 #include "components/ukm/public/interfaces/ukm_interface.mojom.h"
11
12 namespace ukm {
13
14 UkmEntryBuilder::UkmEntryBuilder(
15 const UkmEntryBuilder::AddEntryCallback& callback,
16 ukm::SourceId source_id,
17 const char* event_name)
18 : add_entry_callback_(callback), entry_(mojom::UkmEntry::New()) {
19 entry_->source_id = source_id;
20 entry_->event_hash = base::HashMetricName(event_name);
21 }
22
23 UkmEntryBuilder::~UkmEntryBuilder() {
24 add_entry_callback_.Run(std::move(entry_));
25 }
26
27 void UkmEntryBuilder::AddMetric(const char* metric_name, int64_t value) {
28 entry_->metrics.emplace_back(
29 mojom::UkmMetric::New(base::HashMetricName(metric_name), value));
30 }
31
32 } // namespace ukm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698