xref: /aosp_15_r20/external/cronet/components/metrics/structured/delegating_events_processor.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2022 The Chromium Authors
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_STRUCTURED_DELEGATING_EVENTS_PROCESSOR_H_
6 #define COMPONENTS_METRICS_STRUCTURED_DELEGATING_EVENTS_PROCESSOR_H_
7 
8 #include <memory>
9 
10 #include "components/metrics/structured/event.h"
11 #include "components/metrics/structured/events_processor_interface.h"
12 
13 namespace metrics::structured {
14 namespace {
15 
16 using ::metrics::ChromeUserMetricsExtension;
17 
18 }
19 
20 // DelegatingEventsProcessor manages a set of other EventsProcessorInterfaces.
21 // Calls to this events processor are forwarded to all of the registered events
22 // processors.
23 class DelegatingEventsProcessor final : public EventsProcessorInterface {
24  public:
25   DelegatingEventsProcessor();
26   ~DelegatingEventsProcessor() override;
27 
28   // Adds a |events_processor| to forward calls to.
29   void AddEventsProcessor(
30       std::unique_ptr<EventsProcessorInterface> events_processor);
31 
32   // EventsProcessor:
33   bool ShouldProcessOnEventRecord(const Event& event) override;
34   void OnEventsRecord(Event* event) override;
35   void OnEventRecorded(StructuredEventProto* event) override;
36   void OnProvideIndependentMetrics(
37       ChromeUserMetricsExtension* uma_proto) override;
38   void OnProfileAdded(const base::FilePath& path) override;
39 
40  private:
41   std::vector<std::unique_ptr<EventsProcessorInterface>> events_processors_;
42 };
43 
44 }  // namespace metrics::structured
45 
46 #endif  // COMPONENTS_METRICS_STRUCTURED_DELEGATING_EVENTS_PROCESSOR_H_
47