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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: components/ukm/public/ukm_entry_builder.cc
diff --git a/components/ukm/public/ukm_entry_builder.cc b/components/ukm/public/ukm_entry_builder.cc
new file mode 100644
index 0000000000000000000000000000000000000000..72a227acc085557a1c4734ba9fdc150dae8ef024
--- /dev/null
+++ b/components/ukm/public/ukm_entry_builder.cc
@@ -0,0 +1,32 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/ukm/public/ukm_entry_builder.h"
+
+#include <memory>
+
+#include "base/metrics/metrics_hashes.h"
+#include "components/ukm/public/interfaces/ukm_interface.mojom.h"
+
+namespace ukm {
+
+UkmEntryBuilder::UkmEntryBuilder(
+ const UkmEntryBuilder::AddEntryCallback& callback,
+ ukm::SourceId source_id,
+ const char* event_name)
+ : add_entry_callback_(callback), entry_(mojom::UkmEntry::New()) {
+ entry_->source_id = source_id;
+ entry_->event_hash = base::HashMetricName(event_name);
+}
+
+UkmEntryBuilder::~UkmEntryBuilder() {
+ add_entry_callback_.Run(std::move(entry_));
+}
+
+void UkmEntryBuilder::AddMetric(const char* metric_name, int64_t value) {
+ entry_->metrics.emplace_back(
+ mojom::UkmMetric::New(base::HashMetricName(metric_name), value));
+}
+
+} // namespace ukm

Powered by Google App Engine
This is Rietveld 408576698