summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/power_policy_controller.h
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-21 21:48:49 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-21 21:48:49 +0000
commit3cacfc46545272662f7f4dafa215536880da4423 (patch)
tree9500e631ca02d340c697647ffb3318d229d346ca /chromeos/dbus/power_policy_controller.h
parentfbd54c0709c623d943650a2805f9471b477b36a6 (diff)
downloadchromium_src-3cacfc46545272662f7f4dafa215536880da4423.zip
chromium_src-3cacfc46545272662f7f4dafa215536880da4423.tar.gz
chromium_src-3cacfc46545272662f7f4dafa215536880da4423.tar.bz2
chromeos: Remove PowerStateOverride.
This removes the PowerStateOverride class, which made D-Bus requests to powerd to override various aspects of power management. It updates the Chrome OS implementation of PowerSaveBlocker to instead register requests with PowerPolicyController, which integrates said requests with the pref-derived power management policy. BUG=176405 Review URL: https://codereview.chromium.org/12775019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189699 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/power_policy_controller.h')
-rw-r--r--chromeos/dbus/power_policy_controller.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/chromeos/dbus/power_policy_controller.h b/chromeos/dbus/power_policy_controller.h
index d0c0b46..3d45769 100644
--- a/chromeos/dbus/power_policy_controller.h
+++ b/chromeos/dbus/power_policy_controller.h
@@ -5,6 +5,9 @@
#ifndef CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_
#define CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_
+#include <map>
+#include <string>
+
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/prefs/pref_service.h"
@@ -53,6 +56,17 @@ class CHROMEOS_EXPORT PowerPolicyController
const PrefService::Preference& use_video_activity_pref,
const PrefService::Preference& presentation_idle_delay_factor_pref);
+ // Registers a request to temporarily prevent the screen from getting
+ // dimmed or turned off or the system from suspending in response to user
+ // inactivity. Returns a unique ID that can be passed to RemoveBlock()
+ // later.
+ int AddScreenBlock(const std::string& reason);
+ int AddSuspendBlock(const std::string& reason);
+
+ // Unregisters a request previously created via AddScreenBlock() or
+ // AddSuspendBlock().
+ void RemoveBlock(int id);
+
// DBusThreadManagerObserver implementation:
virtual void OnDBusThreadManagerDestroying(DBusThreadManager* manager)
OVERRIDE;
@@ -61,6 +75,8 @@ class CHROMEOS_EXPORT PowerPolicyController
virtual void PowerManagerRestarted() OVERRIDE;
private:
+ typedef std::map<int, std::string> BlockMap;
+
// Sends a policy based on |prefs_policy_| to the power manager.
void SendCurrentPolicy();
@@ -74,6 +90,18 @@ class CHROMEOS_EXPORT PowerPolicyController
// UpdatePolicyFromPrefs().
power_manager::PowerManagementPolicy prefs_policy_;
+ // Are one or more fields set in |prefs_policy_|?
+ bool prefs_were_set_;
+
+ // Maps from an ID representing a request to prevent the screen from
+ // getting dimmed or turned off or to prevent the system from suspending
+ // to the reason for the request.
+ BlockMap screen_blocks_;
+ BlockMap suspend_blocks_;
+
+ // Next ID to be used by AddScreenBlock() or AddSuspendBlock().
+ int next_block_id_;
+
DISALLOW_COPY_AND_ASSIGN(PowerPolicyController);
};