Index: chromeos/dbus/power_policy_controller.h |
diff --git a/chromeos/dbus/power_policy_controller.h b/chromeos/dbus/power_policy_controller.h |
index d0c0b46e912c04d9ef15c294055e3077a042aa83..3d45769b3e8384e90f2b00b829d835466481ea69 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); |
}; |