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_METRICS_SINGLE_SAMPLE_METRICS_H_ |
| 6 #define COMPONENTS_METRICS_SINGLE_SAMPLE_METRICS_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "components/metrics/public/interfaces/single_sample_metrics.mojom.h" |
| 10 #include "services/service_manager/public/cpp/bind_source_info.h" |
| 11 |
| 12 namespace metrics { |
| 13 |
| 14 using CreateProviderCB = |
| 15 base::RepeatingCallback<void(mojom::SingleSampleMetricsProviderRequest)>; |
| 16 |
| 17 // Initializes and sets the base::SingleSampleMetricsFactory for the current |
| 18 // process. |create_provider_cb| is used to create provider instances per each |
| 19 // thread that the factory is used on; this is necessary since the underlying |
| 20 // providers must only be used on the same thread as construction. |
| 21 // |
| 22 // We use a callback here to avoid taking additional DEPS on content and a |
| 23 // service_manager::Connector() for simplicity and to avoid the need for |
| 24 // using the service test harness in metrics unittests. |
| 25 // |
| 26 // Typically this is called in the process where termination may occur without |
| 27 // warning; e.g. perhaps a renderer process. |
| 28 extern void InitializeSingleSampleMetricsFactory( |
| 29 CreateProviderCB create_provider_cb); |
| 30 |
| 31 // Creates a mojom::SingleSampleMetricsProvider capable of vending single sample |
| 32 // metrics attached to a mojo pipe. |
| 33 // |
| 34 // Typically this is given to a service_manager::BinderRegistry in the process |
| 35 // that has a deterministic shutdown path and which serves as a stable endpoint |
| 36 // for the factory created by the above initialize method in another process. |
| 37 extern void CreateSingleSampleMetricsProvider( |
| 38 const service_manager::BindSourceInfo& source_info, |
| 39 mojom::SingleSampleMetricsProviderRequest request); |
| 40 |
| 41 } // namespace metrics |
| 42 |
| 43 #endif // COMPONENTS_METRICS_SINGLE_SAMPLE_METRICS_H_ |
OLD | NEW |