
This class and its subclasses will be used in the future to drive the collection of power metrics in Chrome. Bug: 1248057 Change-Id: Ie0b0c7ef9d29ebb56a6962847f4e321559d773b1 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3319536 Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org> Commit-Queue: Patrick Monette <pmonette@chromium.org> Cr-Commit-Position: refs/heads/main@{#950286}
33 lines
996 B
C++
33 lines
996 B
C++
// Copyright 2021 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef COMPONENTS_POWER_METRICS_TIMER_SAMPLING_EVENT_SOURCE_H_
|
|
#define COMPONENTS_POWER_METRICS_TIMER_SAMPLING_EVENT_SOURCE_H_
|
|
|
|
#include "base/time/time.h"
|
|
#include "base/timer/timer.h"
|
|
#include "components/power_metrics/sampling_event_source.h"
|
|
|
|
namespace power_sampler {
|
|
|
|
// Generates a sampling event at regular time intervals.
|
|
class TimerSamplingEventSource : public SamplingEventSource {
|
|
public:
|
|
// |interval| is the time interval between sampling events.
|
|
explicit TimerSamplingEventSource(base::TimeDelta interval);
|
|
|
|
~TimerSamplingEventSource() override;
|
|
|
|
// SamplingEventSource:
|
|
bool Start(SamplingEventCallback callback) override;
|
|
|
|
private:
|
|
const base::TimeDelta interval_;
|
|
base::RepeatingTimer timer_;
|
|
};
|
|
|
|
} // namespace power_sampler
|
|
|
|
#endif // COMPONENTS_POWER_METRICS_TIMER_SAMPLING_EVENT_SOURCE_H_
|