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 #ifndef COMPONENTS_UKM_PUBLIC_MOJO_UKM_RECORDER_H_ |
| 6 #define COMPONENTS_UKM_PUBLIC_MOJO_UKM_RECORDER_H_ |
| 7 |
| 8 #include "components/ukm/public/interfaces/ukm_interface.mojom.h" |
| 9 #include "components/ukm/public/ukm_recorder.h" |
| 10 |
| 11 namespace ukm { |
| 12 |
| 13 /** |
| 14 * A helper wrapper that lets UKM data be recorded on other processes with the |
| 15 * same interface that is used in the browser process. |
| 16 * |
| 17 * Usage Example: |
| 18 * |
| 19 * ukm::mojom::UkmRecorderInterfacePtr interface; |
| 20 * content::RenderThread::Get()->GetConnector()->BindInterface( |
| 21 * content::mojom::kBrowserServiceName, mojo::MakeRequest(&interface)); |
| 22 * ukm::MojoUkmRecorder recorder(std::move(interface)); |
| 23 * std::unique_ptr<ukm::UkmEntryBuilder> builder = |
| 24 * recorder.GetEntryBuilder(coordination_unit_id, "MyEvent"); |
| 25 * builder->AddMetric("MyMetric", metric_value); |
| 26 */ |
| 27 class MojoUkmRecorder : public UkmRecorder { |
| 28 public: |
| 29 MojoUkmRecorder(mojom::UkmRecorderInterfacePtr interface); |
| 30 ~MojoUkmRecorder() override; |
| 31 |
| 32 private: |
| 33 // UkmRecorder: |
| 34 void UpdateSourceURL(SourceId source_id, const GURL& url) override; |
| 35 void AddEntry(mojom::UkmEntryPtr entry) override; |
| 36 |
| 37 mojom::UkmRecorderInterfacePtr interface_; |
| 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(MojoUkmRecorder); |
| 40 }; |
| 41 |
| 42 } // namespace ukm |
| 43 |
| 44 #endif // COMPONENTS_UKM_PUBLIC_MOJO_UKM_RECORDER_H_ |
OLD | NEW |