Avi Drissman | 3a215d1e | 2022-09-07 19:43:09 | [diff] [blame] | 1 | // Copyright 2022 The Chromium Authors |
Drew Davenport | efec322 | 2022-07-18 22:31:42 | [diff] [blame] | 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 ASH_DISPLAY_REFRESH_RATE_THROTTLE_CONTROLLER_H_ |
| 6 | #define ASH_DISPLAY_REFRESH_RATE_THROTTLE_CONTROLLER_H_ |
| 7 | |
| 8 | #include "ash/ash_export.h" |
| 9 | #include "ash/system/power/power_status.h" |
| 10 | #include "base/scoped_observation.h" |
| 11 | #include "ui/display/manager/display_configurator.h" |
| 12 | |
| 13 | namespace ash { |
| 14 | |
| 15 | // Watches device power state and requests the refresh rate to be throttled |
| 16 | // when in a low power state. |
| 17 | class ASH_EXPORT RefreshRateThrottleController : public PowerStatus::Observer { |
| 18 | public: |
| 19 | RefreshRateThrottleController( |
| 20 | display::DisplayConfigurator* display_configurator, |
| 21 | PowerStatus* power_status); |
| 22 | |
| 23 | RefreshRateThrottleController(const RefreshRateThrottleController&) = delete; |
| 24 | RefreshRateThrottleController& operator=( |
| 25 | const RefreshRateThrottleController&) = delete; |
| 26 | ~RefreshRateThrottleController() override; |
| 27 | |
| 28 | // PowerStatus::Observer: |
| 29 | void OnPowerStatusChanged() override; |
| 30 | |
| 31 | private: |
| 32 | base::ScopedObservation<ash::PowerStatus, ash::PowerStatus::Observer> |
| 33 | power_status_observer_; |
| 34 | |
| 35 | // Not owned. |
| 36 | display::DisplayConfigurator* const display_configurator_; |
| 37 | PowerStatus* const power_status_; |
| 38 | }; |
| 39 | |
| 40 | } // namespace ash |
| 41 | |
| 42 | #endif // ASH_DISPLAY_REFRESH_RATE_THROTTLE_CONTROLLER_H_ |