power_utils.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_PUBLIC_CPP_POWER_UTILS_H_
  5. #define ASH_PUBLIC_CPP_POWER_UTILS_H_
  6. #include "ash/public/cpp/ash_public_export.h"
  7. namespace base {
  8. class TimeDelta;
  9. }
  10. namespace ash {
  11. namespace power_utils {
  12. // Returns true if |time| should be displayed in the UI. Less-than-a-minute or
  13. // very large values aren't displayed.
  14. bool ASH_PUBLIC_EXPORT ShouldDisplayBatteryTime(const base::TimeDelta& time);
  15. // Returns the battery's remaining charge, rounded to an integer with a
  16. // maximum value of 100.
  17. int ASH_PUBLIC_EXPORT GetRoundedBatteryPercent(double battery_percent);
  18. // Copies the hour and minute components of |time| to |hours| and |minutes|.
  19. // The minute component is rounded rather than truncated: a |time| value
  20. // corresponding to 92 seconds will produce a |minutes| value of 2, for
  21. // example.
  22. void ASH_PUBLIC_EXPORT SplitTimeIntoHoursAndMinutes(const base::TimeDelta& time,
  23. int* hours,
  24. int* minutes);
  25. } // namespace power_utils
  26. } // namespace ash
  27. #endif // ASH_PUBLIC_CPP_POWER_UTILS_H_