1*6777b538SAndroid Build Coastguard Worker // Copyright 2017 The Chromium Authors 2*6777b538SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*6777b538SAndroid Build Coastguard Worker // found in the LICENSE file. 4*6777b538SAndroid Build Coastguard Worker 5*6777b538SAndroid Build Coastguard Worker #ifndef COMPONENTS_METRICS_SINGLE_SAMPLE_METRICS_H_ 6*6777b538SAndroid Build Coastguard Worker #define COMPONENTS_METRICS_SINGLE_SAMPLE_METRICS_H_ 7*6777b538SAndroid Build Coastguard Worker 8*6777b538SAndroid Build Coastguard Worker #include "base/functional/callback.h" 9*6777b538SAndroid Build Coastguard Worker #include "components/metrics/public/mojom/single_sample_metrics.mojom.h" 10*6777b538SAndroid Build Coastguard Worker #include "mojo/public/cpp/bindings/pending_receiver.h" 11*6777b538SAndroid Build Coastguard Worker 12*6777b538SAndroid Build Coastguard Worker namespace metrics { 13*6777b538SAndroid Build Coastguard Worker 14*6777b538SAndroid Build Coastguard Worker using CreateProviderCB = base::RepeatingCallback<void( 15*6777b538SAndroid Build Coastguard Worker mojo::PendingReceiver<mojom::SingleSampleMetricsProvider>)>; 16*6777b538SAndroid Build Coastguard Worker 17*6777b538SAndroid Build Coastguard Worker // Initializes and sets the base::SingleSampleMetricsFactory for the current 18*6777b538SAndroid Build Coastguard Worker // process. |create_provider_cb| is used to create provider instances per each 19*6777b538SAndroid Build Coastguard Worker // thread that the factory is used on; this is necessary since the underlying 20*6777b538SAndroid Build Coastguard Worker // providers must only be used on the same thread as construction. 21*6777b538SAndroid Build Coastguard Worker // 22*6777b538SAndroid Build Coastguard Worker // We use a callback here to avoid taking additional DEPS on content and a 23*6777b538SAndroid Build Coastguard Worker // service_manager::Connector() for simplicity and to avoid the need for 24*6777b538SAndroid Build Coastguard Worker // using the service test harness in metrics unittests. 25*6777b538SAndroid Build Coastguard Worker // 26*6777b538SAndroid Build Coastguard Worker // Typically this is called in the process where termination may occur without 27*6777b538SAndroid Build Coastguard Worker // warning; e.g. perhaps a renderer process. 28*6777b538SAndroid Build Coastguard Worker extern void InitializeSingleSampleMetricsFactory( 29*6777b538SAndroid Build Coastguard Worker CreateProviderCB create_provider_cb); 30*6777b538SAndroid Build Coastguard Worker 31*6777b538SAndroid Build Coastguard Worker // Creates a mojom::SingleSampleMetricsProvider capable of vending single sample 32*6777b538SAndroid Build Coastguard Worker // metrics attached to a mojo pipe. 33*6777b538SAndroid Build Coastguard Worker // 34*6777b538SAndroid Build Coastguard Worker // Typically this is given to a service_manager::BinderRegistry in the process 35*6777b538SAndroid Build Coastguard Worker // that has a deterministic shutdown path and which serves as a stable endpoint 36*6777b538SAndroid Build Coastguard Worker // for the factory created by the above initialize method in another process. 37*6777b538SAndroid Build Coastguard Worker extern void CreateSingleSampleMetricsProvider( 38*6777b538SAndroid Build Coastguard Worker mojo::PendingReceiver<mojom::SingleSampleMetricsProvider> receiver); 39*6777b538SAndroid Build Coastguard Worker 40*6777b538SAndroid Build Coastguard Worker } // namespace metrics 41*6777b538SAndroid Build Coastguard Worker 42*6777b538SAndroid Build Coastguard Worker #endif // COMPONENTS_METRICS_SINGLE_SAMPLE_METRICS_H_ 43