Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: chromeos/dbus/power_manager_client.h

Issue 2768543002: chromeos: Add PowerManagerClient::GetSwitchStates(). (Closed)
Patch Set: document that callbacks aren't run on error Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/dbus/fake_power_manager_client.cc ('k') | chromeos/dbus/power_manager_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/power_manager_client.h
diff --git a/chromeos/dbus/power_manager_client.h b/chromeos/dbus/power_manager_client.h
index 9f341deb67370d0e6b51d309357591d960abb5e2..1381287cecf36975d93e0b9c67830272cf51f1a6 100644
--- a/chromeos/dbus/power_manager_client.h
+++ b/chromeos/dbus/power_manager_client.h
@@ -23,16 +23,31 @@ class PowerSupplyProperties;
namespace chromeos {
-// Callback used for getting the current screen brightness. The param is in the
-// range [0.0, 100.0].
-typedef base::Callback<void(double)> GetScreenBrightnessPercentCallback;
-
-// Callback used for getting the current backlights forced off state.
-typedef base::Callback<void(bool)> GetBacklightsForcedOffCallback;
-
// PowerManagerClient is used to communicate with the power manager.
class CHROMEOS_EXPORT PowerManagerClient : public DBusClient {
public:
+ enum class LidState {
+ OPEN,
+ CLOSED,
+ NOT_PRESENT,
+ };
+
+ enum class TabletMode {
+ ON,
+ OFF,
+ UNSUPPORTED,
+ };
+
+ // Callback used for getting the current screen brightness. The param is in
+ // the range [0.0, 100.0].
+ typedef base::Callback<void(double)> GetScreenBrightnessPercentCallback;
+
+ // Callback passed to GetBacklightsForcedOff().
+ typedef base::Callback<void(bool forced_off)> GetBacklightsForcedOffCallback;
+
+ // Callback passed to GetSwitchStates().
+ typedef base::Callback<void(LidState, TabletMode)> GetSwitchStatesCallback;
+
// Interface for observing changes from the power manager.
class Observer {
public:
@@ -87,12 +102,14 @@ class CHROMEOS_EXPORT PowerManagerClient : public DBusClient {
virtual void PowerButtonEventReceived(bool down,
const base::TimeTicks& timestamp) {}
- // Called when the device's lid is opened or closed.
- virtual void LidEventReceived(bool open,
+ // Called when the device's lid is opened or closed. LidState::NOT_PRESENT
+ // is never passed.
+ virtual void LidEventReceived(LidState state,
const base::TimeTicks& timestamp) {}
// Called when the device's tablet mode switch is on or off.
- virtual void TabletModeEventReceived(bool on,
+ // TabletMode::UNSUPPORTED is never passed.
+ virtual void TabletModeEventReceived(TabletMode mode,
const base::TimeTicks& timestamp) {}
// Called when the idle action will be performed after
@@ -143,7 +160,8 @@ class CHROMEOS_EXPORT PowerManagerClient : public DBusClient {
virtual void SetScreenBrightnessPercent(double percent, bool gradual) = 0;
// Asynchronously gets the current screen brightness, in the range
- // [0.0, 100.0].
+ // [0.0, 100.0]. On error (e.g. powerd not running), |callback| will not be
+ // run.
virtual void GetScreenBrightnessPercent(
const GetScreenBrightnessPercentCallback& callback) = 0;
@@ -187,13 +205,19 @@ class CHROMEOS_EXPORT PowerManagerClient : public DBusClient {
// causes powerd to switch to using the battery on devices with type-C ports.
virtual void SetPowerSource(const std::string& id) = 0;
- // Forces the display and keyboard backlights (if present) to |forced_off|.
+ // Forces the display and (if present) keyboard backlights to |forced_off|.
virtual void SetBacklightsForcedOff(bool forced_off) = 0;
- // Gets the display and keyboard backlights (if present) forced off state.
+ // Gets the display and (if present) keyboard backlights' forced-off state. On
+ // error (e.g. powerd not running), |callback| will not be run.
virtual void GetBacklightsForcedOff(
const GetBacklightsForcedOffCallback& callback) = 0;
+ // Asynchronously fetches the current state of various hardware switches (e.g.
+ // the lid switch and the tablet-mode switch). On error (e.g. powerd not
+ // running), |callback| will not be run.
+ virtual void GetSwitchStates(const GetSwitchStatesCallback& callback) = 0;
+
// Returns a callback that can be called by an observer to report
// readiness for suspend. See Observer::SuspendImminent().
virtual base::Closure GetSuspendReadinessCallback() = 0;
« no previous file with comments | « chromeos/dbus/fake_power_manager_client.cc ('k') | chromeos/dbus/power_manager_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698