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 "components/ukm/ukm_entry.h" | |
6 | |
7 #include "base/metrics/metrics_hashes.h" | |
8 #include "components/metrics/proto/ukm/entry.pb.h" | |
9 #include "components/ukm/ukm_source.h" | |
10 | |
11 namespace ukm { | |
12 | |
13 UkmEntry::UkmEntry(int32_t source_id, const char* event_name) | |
14 : source_id_(source_id), event_hash_(base::HashMetricName(event_name)) {} | |
15 | |
16 UkmEntry::~UkmEntry() {} | |
17 | |
18 void UkmEntry::PopulateProto(Entry* proto_entry) const { | |
19 DCHECK(!proto_entry->has_source_id()); | |
20 DCHECK(!proto_entry->has_event_hash()); | |
21 | |
22 proto_entry->set_source_id(source_id_); | |
23 proto_entry->set_event_hash(event_hash_); | |
24 for (auto& metric : metrics_) { | |
25 Entry::Metric* proto_metric = proto_entry->add_metrics(); | |
26 proto_metric->set_metric_hash(std::get<0>(metric)); | |
27 proto_metric->set_value(std::get<1>(metric)); | |
28 } | |
29 } | |
30 | |
31 } // namespace ukm | |
OLD | NEW |