| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_ | 5 #ifndef CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_ |
| 6 #define CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_ | 6 #define CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // |*_screen_lock_delay_ms| are unset or set to higher values than what | 67 // |*_screen_lock_delay_ms| are unset or set to higher values than what |
| 68 // this constant would imply. | 68 // this constant would imply. |
| 69 static const int kScreenLockAfterOffDelayMs; | 69 static const int kScreenLockAfterOffDelayMs; |
| 70 | 70 |
| 71 PowerPolicyController(DBusThreadManager* manager, PowerManagerClient* client); | 71 PowerPolicyController(DBusThreadManager* manager, PowerManagerClient* client); |
| 72 virtual ~PowerPolicyController(); | 72 virtual ~PowerPolicyController(); |
| 73 | 73 |
| 74 // Updates |prefs_policy_| with |values| and sends an updated policy. | 74 // Updates |prefs_policy_| with |values| and sends an updated policy. |
| 75 void ApplyPrefs(const PrefValues& values); | 75 void ApplyPrefs(const PrefValues& values); |
| 76 | 76 |
| 77 // Resets |prefs_policy_| to its defaults and sends an updated policy. |
| 78 void ClearPrefs(); |
| 79 |
| 77 // Registers a request to temporarily prevent the screen from getting | 80 // Registers a request to temporarily prevent the screen from getting |
| 78 // dimmed or turned off or the system from suspending in response to user | 81 // dimmed or turned off or the system from suspending in response to user |
| 79 // inactivity and sends an updated policy. |reason| is a human-readable | 82 // inactivity and sends an updated policy. |reason| is a human-readable |
| 80 // description of the reason the lock was created. Returns a unique ID | 83 // description of the reason the lock was created. Returns a unique ID |
| 81 // that can be passed to RemoveWakeLock() later. | 84 // that can be passed to RemoveWakeLock() later. |
| 82 int AddScreenWakeLock(const std::string& reason); | 85 int AddScreenWakeLock(const std::string& reason); |
| 83 int AddSystemWakeLock(const std::string& reason); | 86 int AddSystemWakeLock(const std::string& reason); |
| 84 | 87 |
| 85 // Unregisters a request previously created via AddScreenWakeLock() or | 88 // Unregisters a request previously created via AddScreenWakeLock() or |
| 86 // AddSystemWakeLock() and sends an updated policy. | 89 // AddSystemWakeLock() and sends an updated policy. |
| 87 void RemoveWakeLock(int id); | 90 void RemoveWakeLock(int id); |
| 88 | 91 |
| 89 // DBusThreadManagerObserver implementation: | 92 // DBusThreadManagerObserver implementation: |
| 90 virtual void OnDBusThreadManagerDestroying(DBusThreadManager* manager) | 93 virtual void OnDBusThreadManagerDestroying(DBusThreadManager* manager) |
| 91 OVERRIDE; | 94 OVERRIDE; |
| 92 | 95 |
| 93 // PowerManagerClient::Observer implementation: | 96 // PowerManagerClient::Observer implementation: |
| 94 virtual void PowerManagerRestarted() OVERRIDE; | 97 virtual void PowerManagerRestarted() OVERRIDE; |
| 95 | 98 |
| 96 private: | 99 private: |
| 100 friend class PowerPrefsTest; |
| 101 |
| 97 typedef std::map<int, std::string> WakeLockMap; | 102 typedef std::map<int, std::string> WakeLockMap; |
| 98 | 103 |
| 99 // Sends a policy based on |prefs_policy_| to the power manager. | 104 // Sends a policy based on |prefs_policy_| to the power manager. |
| 100 void SendCurrentPolicy(); | 105 void SendCurrentPolicy(); |
| 101 | 106 |
| 102 // Sends an empty policy to the power manager to reset its configuration. | 107 // Sends an empty policy to the power manager to reset its configuration. |
| 103 void SendEmptyPolicy(); | 108 void SendEmptyPolicy(); |
| 104 | 109 |
| 105 DBusThreadManager* manager_; // not owned | 110 DBusThreadManager* manager_; // not owned |
| 106 PowerManagerClient* client_; // not owned | 111 PowerManagerClient* client_; // not owned |
| (...skipping 16 matching lines...) Expand all Loading... |
| 123 | 128 |
| 124 // Next ID to be used by AddScreenWakeLock() or AddSystemWakeLock(). | 129 // Next ID to be used by AddScreenWakeLock() or AddSystemWakeLock(). |
| 125 int next_wake_lock_id_; | 130 int next_wake_lock_id_; |
| 126 | 131 |
| 127 DISALLOW_COPY_AND_ASSIGN(PowerPolicyController); | 132 DISALLOW_COPY_AND_ASSIGN(PowerPolicyController); |
| 128 }; | 133 }; |
| 129 | 134 |
| 130 } // namespace chromeos | 135 } // namespace chromeos |
| 131 | 136 |
| 132 #endif // CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_ | 137 #endif // CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_ |
| OLD | NEW |