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

Unified Diff: components/ukm/public/mojo_ukm_recorder.h

Issue 2882353002: Implement Ukm Mojo interface. (Closed)
Patch Set: Fix nits 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
« no previous file with comments | « components/ukm/public/BUILD.gn ('k') | components/ukm/public/mojo_ukm_recorder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ukm/public/mojo_ukm_recorder.h
diff --git a/components/ukm/public/mojo_ukm_recorder.h b/components/ukm/public/mojo_ukm_recorder.h
new file mode 100644
index 0000000000000000000000000000000000000000..de959b31f4324dc2da62a8f0d179dd67c328a2fd
--- /dev/null
+++ b/components/ukm/public/mojo_ukm_recorder.h
@@ -0,0 +1,44 @@
+// 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.
+
+#ifndef COMPONENTS_UKM_PUBLIC_MOJO_UKM_RECORDER_H_
+#define COMPONENTS_UKM_PUBLIC_MOJO_UKM_RECORDER_H_
+
+#include "components/ukm/public/interfaces/ukm_interface.mojom.h"
+#include "components/ukm/public/ukm_recorder.h"
+
+namespace ukm {
+
+/**
+ * A helper wrapper that lets UKM data be recorded on other processes with the
+ * same interface that is used in the browser process.
+ *
+ * Usage Example:
+ *
+ * ukm::mojom::UkmRecorderInterfacePtr interface;
+ * content::RenderThread::Get()->GetConnector()->BindInterface(
+ * content::mojom::kBrowserServiceName, mojo::MakeRequest(&interface));
+ * ukm::MojoUkmRecorder recorder(std::move(interface));
+ * std::unique_ptr<ukm::UkmEntryBuilder> builder =
+ * recorder.GetEntryBuilder(coordination_unit_id, "MyEvent");
+ * builder->AddMetric("MyMetric", metric_value);
+ */
+class MojoUkmRecorder : public UkmRecorder {
+ public:
+ MojoUkmRecorder(mojom::UkmRecorderInterfacePtr interface);
+ ~MojoUkmRecorder() override;
+
+ private:
+ // UkmRecorder:
+ void UpdateSourceURL(SourceId source_id, const GURL& url) override;
+ void AddEntry(mojom::UkmEntryPtr entry) override;
+
+ mojom::UkmRecorderInterfacePtr interface_;
+
+ DISALLOW_COPY_AND_ASSIGN(MojoUkmRecorder);
+};
+
+} // namespace ukm
+
+#endif // COMPONENTS_UKM_PUBLIC_MOJO_UKM_RECORDER_H_
« no previous file with comments | « components/ukm/public/BUILD.gn ('k') | components/ukm/public/mojo_ukm_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698