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 15 // DelegatingEventsProcessor manages a set of other EventsProcessorInterfaces. 16 // Calls to this events processor are forwarded to all of the registered events 17 // processors. 18 class DelegatingEventsProcessor final : public EventsProcessorInterface { 19 public: 20 DelegatingEventsProcessor(); 21 ~DelegatingEventsProcessor() override; 22 23 // Adds a |events_processor| to forward calls to. 24 void AddEventsProcessor( 25 std::unique_ptr<EventsProcessorInterface> events_processor); 26 27 // EventsProcessor: 28 bool ShouldProcessOnEventRecord(const Event& event) override; 29 void OnEventsRecord(Event* event) override; 30 31 private: 32 std::vector<std::unique_ptr<EventsProcessorInterface>> events_processors_; 33 }; 34 35 } // namespace metrics::structured 36 37 #endif // COMPONENTS_METRICS_STRUCTURED_DELEGATING_EVENTS_PROCESSOR_H_ 38