power_mode.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // Copyright 2021 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 COMPONENTS_POWER_SCHEDULER_POWER_MODE_H_
  5. #define COMPONENTS_POWER_SCHEDULER_POWER_MODE_H_
  6. #include "base/component_export.h"
  7. namespace power_scheduler {
  8. // Power modes are "use cases" for the power scheduler. This enum is used both
  9. // as a PowerModeVoter's input to PowerModeArbiter and as the arbiter's output,
  10. // i.e. as the process's current power mode.
  11. enum class PowerMode {
  12. // Values in ascending priority order. See
  13. // PowerModeArbiter::ComputeActiveModeLocked.
  14. // Default mode: none of the other use cases were detected.
  15. kIdle,
  16. // The vsync signal is observed, but no frames are produced/submitted.
  17. kNopAnimation,
  18. // Like kMainThreadAnimation, but the animation affects only a small screen
  19. // area (see FrameProductionPowerModeVoter).
  20. kSmallMainThreadAnimation,
  21. // Like kAnimation, but the animation affects only a small screen area (see
  22. // FrameProductionPowerModeVoter).
  23. kSmallAnimation,
  24. // Like kMainThreadAnimation, but the animation affects only a medium screen
  25. // area (see FrameProductionPowerModeVoter).
  26. kMediumMainThreadAnimation,
  27. // Like kAnimation, but the animation affects only a medium screen area (see
  28. // FrameProductionPowerModeVoter).
  29. kMediumAnimation,
  30. // The process is playing audio.
  31. kAudible,
  32. // A video is playing in the process and producing frames.
  33. kVideoPlayback,
  34. // The main thread is producing frames. This is broken out into a separate
  35. // PowerMode to override kNopAnimation votes in cases where the main thread
  36. // takes a long time to produce a new frame.
  37. kMainThreadAnimation,
  38. // The process is executing a script at the browser's request. Mainly relevant
  39. // for background work in WebView/WebLayer.
  40. kScriptExecution,
  41. // A page or tab associated with the process is loading.
  42. kLoading,
  43. // A surface rendered by the process is animating and producing frames.
  44. kAnimation,
  45. // Both kLoading + kAnimation modes are active.
  46. kLoadingAnimation,
  47. // The process is responding to user input.
  48. kResponse,
  49. // The (Android) app is showing an uninstrumented activity (e.g., Chromium's
  50. // settings activity) for which we can't determine a more specific use case.
  51. // Only valid in Chromium's browser process.
  52. kNonWebActivity,
  53. // All pages and tabs associated with the process are backgrounded, or the app
  54. // itself is backgrounded.
  55. kBackground,
  56. // The device is connected to an external power source.
  57. kCharging,
  58. kMaxValue = kCharging,
  59. };
  60. COMPONENT_EXPORT(POWER_SCHEDULER) const char* PowerModeToString(PowerMode);
  61. } // namespace power_scheduler
  62. #endif // COMPONENTS_POWER_SCHEDULER_POWER_MODE_H_