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

Unified Diff: chromeos/dbus/power_policy_controller.h

Issue 12186010: chromeos: Add power management policy prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix observer registration and bool prefs Created 7 years, 10 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/power_manager_client.cc ('k') | chromeos/dbus/power_policy_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/power_policy_controller.h
diff --git a/chromeos/dbus/power_policy_controller.h b/chromeos/dbus/power_policy_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..5bdc413344ffa0791617f484aa71dbe07c25d5bf
--- /dev/null
+++ b/chromeos/dbus/power_policy_controller.h
@@ -0,0 +1,79 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_
+#define CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/prefs/public/pref_service_base.h"
+#include "chromeos/chromeos_export.h"
+#include "chromeos/dbus/dbus_thread_manager_observer.h"
+#include "chromeos/dbus/power_manager/policy.pb.h"
+#include "chromeos/dbus/power_manager_client.h"
+
+namespace chromeos {
+
+class DBusThreadManager;
+
+// PowerPolicyController is responsible for sending Chrome's assorted power
+// management preferences to the Chrome OS power manager.
+class CHROMEOS_EXPORT PowerPolicyController
+ : public DBusThreadManagerObserver,
+ public PowerManagerClient::Observer {
+ public:
+ // Note: Do not change these values; they are used by preferences.
+ enum Action {
+ ACTION_SUSPEND = 0,
+ ACTION_STOP_SESSION = 1,
+ ACTION_SHUT_DOWN = 2,
+ ACTION_DO_NOTHING = 3,
+ };
+
+ PowerPolicyController(DBusThreadManager* manager, PowerManagerClient* client);
+ ~PowerPolicyController();
+
+ // Sends an updated policy to the power manager based on the current
+ // values of the passed-in prefs.
+ void UpdatePolicyFromPrefs(
+ const PrefServiceBase::Preference& ac_screen_dim_delay_ms_pref,
+ const PrefServiceBase::Preference& ac_screen_off_delay_ms_pref,
+ const PrefServiceBase::Preference& ac_screen_lock_delay_ms_pref,
+ const PrefServiceBase::Preference& ac_idle_delay_ms_pref,
+ const PrefServiceBase::Preference& battery_screen_dim_delay_ms_pref,
+ const PrefServiceBase::Preference& battery_screen_off_delay_ms_pref,
+ const PrefServiceBase::Preference& battery_screen_lock_delay_ms_pref,
+ const PrefServiceBase::Preference& battery_idle_delay_ms_pref,
+ const PrefServiceBase::Preference& idle_action_pref,
+ const PrefServiceBase::Preference& lid_closed_action_pref,
+ const PrefServiceBase::Preference& use_audio_activity_pref,
+ const PrefServiceBase::Preference& use_video_activity_pref,
+ const PrefServiceBase::Preference& presentation_idle_delay_factor_pref);
+
+ // DBusThreadManagerObserver implementation:
+ virtual void OnDBusThreadManagerDestroying(DBusThreadManager* manager);
+
+ // PowerManagerClient::Observer implementation:
+ virtual void PowerManagerRestarted() OVERRIDE;
+
+ private:
+ // Sends a policy based on |prefs_policy_| to the power manager.
+ void SendCurrentPolicy();
+
+ // Sends an empty policy to the power manager to reset its configuration.
+ void SendEmptyPolicy();
+
+ DBusThreadManager* manager_; // not owned
+ PowerManagerClient* client_; // not owned
+
+ // Policy specified by the prefs that were last passed to
+ // UpdatePolicyFromPrefs().
+ power_manager::PowerManagementPolicy prefs_policy_;
+
+ DISALLOW_COPY_AND_ASSIGN(PowerPolicyController);
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_
« no previous file with comments | « chromeos/dbus/power_manager_client.cc ('k') | chromeos/dbus/power_policy_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698