1 // Copyright 2021 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 BASE_POWER_MONITOR_TIMER_SAMPLING_EVENT_SOURCE_H_ 6 #define BASE_POWER_MONITOR_TIMER_SAMPLING_EVENT_SOURCE_H_ 7 8 #include "base/base_export.h" 9 #include "base/power_monitor/sampling_event_source.h" 10 #include "base/time/time.h" 11 #include "base/timer/timer.h" 12 13 namespace base { 14 15 // Generates a sampling event at regular time intervals. 16 class BASE_EXPORT TimerSamplingEventSource : public SamplingEventSource { 17 public: 18 // |interval| is the time interval between sampling events. 19 explicit TimerSamplingEventSource(TimeDelta interval); 20 21 ~TimerSamplingEventSource() override; 22 23 // SamplingEventSource: 24 bool Start(SamplingEventCallback callback) override; 25 26 private: 27 const TimeDelta interval_; 28 RepeatingTimer timer_; 29 }; 30 31 } // namespace base 32 33 #endif // BASE_POWER_MONITOR_TIMER_SAMPLING_EVENT_SOURCE_H_ 34