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

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

Issue 2855053002: Allow empty UKM entries to be recorded. (Closed)
Patch Set: Fix test 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
« no previous file with comments | « components/ukm/ukm_entry.cc ('k') | components/ukm/ukm_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_builder.h" 5 #include "components/ukm/ukm_entry_builder.h"
6 6
7 #include "base/metrics/metrics_hashes.h" 7 #include "base/metrics/metrics_hashes.h"
8 #include "components/ukm/ukm_entry.h" 8 #include "components/ukm/ukm_entry.h"
9 #include "components/ukm/ukm_service.h" 9 #include "components/ukm/ukm_service.h"
10 10
11 namespace ukm { 11 namespace ukm {
12 12
13 UkmEntryBuilder::UkmEntryBuilder(const UkmService::AddEntryCallback& callback, 13 UkmEntryBuilder::UkmEntryBuilder(const UkmService::AddEntryCallback& callback,
14 int32_t source_id, 14 int32_t source_id,
15 const char* event_name) 15 const char* event_name)
16 : add_entry_callback_(callback), 16 : add_entry_callback_(callback),
17 entry_(new UkmEntry(source_id, event_name)) {} 17 entry_(new UkmEntry(source_id, event_name)) {}
18 18
19 UkmEntryBuilder::~UkmEntryBuilder() { 19 UkmEntryBuilder::~UkmEntryBuilder() {
20 if (entry_->metrics_.empty())
21 return;
22
23 add_entry_callback_.Run(std::move(entry_)); 20 add_entry_callback_.Run(std::move(entry_));
24 } 21 }
25 22
26 void UkmEntryBuilder::AddMetric(const char* metric_name, int64_t value) { 23 void UkmEntryBuilder::AddMetric(const char* metric_name, int64_t value) {
27 entry_->metrics_.emplace_back( 24 entry_->metrics_.emplace_back(
28 std::make_pair(base::HashMetricName(metric_name), value)); 25 std::make_pair(base::HashMetricName(metric_name), value));
29 } 26 }
30 27
31 } // namespace ukm 28 } // namespace ukm
OLDNEW
« no previous file with comments | « components/ukm/ukm_entry.cc ('k') | components/ukm/ukm_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698