| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/ukm/ukm_entry.h" | 5 #include "components/ukm/ukm_entry.h" |
| 6 | 6 |
| 7 #include "base/metrics/metrics_hashes.h" | 7 #include "base/metrics/metrics_hashes.h" |
| 8 #include "components/metrics/proto/ukm/entry.pb.h" | 8 #include "components/metrics/proto/ukm/entry.pb.h" |
| 9 #include "components/ukm/ukm_source.h" | 9 #include "components/ukm/ukm_source.h" |
| 10 | 10 |
| 11 namespace ukm { | 11 namespace ukm { |
| 12 | 12 |
| 13 UkmEntry::UkmEntry(int32_t source_id, const char* event_name) | 13 UkmEntry::UkmEntry(int32_t source_id, const char* event_name) |
| 14 : source_id_(source_id), event_hash_(base::HashMetricName(event_name)) {} | 14 : source_id_(source_id), event_hash_(base::HashMetricName(event_name)) {} |
| 15 | 15 |
| 16 UkmEntry::~UkmEntry() {} | 16 UkmEntry::~UkmEntry() {} |
| 17 | 17 |
| 18 void UkmEntry::PopulateProto(Entry* proto_entry) { | 18 void UkmEntry::PopulateProto(Entry* proto_entry) const { |
| 19 DCHECK(!proto_entry->has_source_id()); | 19 DCHECK(!proto_entry->has_source_id()); |
| 20 DCHECK(!proto_entry->has_event_hash()); | 20 DCHECK(!proto_entry->has_event_hash()); |
| 21 DCHECK(proto_entry->metrics_size() == 0); | 21 DCHECK(proto_entry->metrics_size() == 0); |
| 22 | 22 |
| 23 proto_entry->set_source_id(source_id_); | 23 proto_entry->set_source_id(source_id_); |
| 24 proto_entry->set_event_hash(event_hash_); | 24 proto_entry->set_event_hash(event_hash_); |
| 25 for (auto& metric : metrics_) { | 25 for (auto& metric : metrics_) { |
| 26 Entry::Metric* proto_metric = proto_entry->add_metrics(); | 26 Entry::Metric* proto_metric = proto_entry->add_metrics(); |
| 27 proto_metric->set_metric_hash(std::get<0>(metric)); | 27 proto_metric->set_metric_hash(std::get<0>(metric)); |
| 28 proto_metric->set_value(std::get<1>(metric)); | 28 proto_metric->set_value(std::get<1>(metric)); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace ukm | 32 } // namespace ukm |
| OLD | NEW |