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

Side by Side Diff: chromeos/dbus/power_policy_controller.h

Issue 12775019: chromeos: Remove PowerStateOverride. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unneeded dependency Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
9 #include <string>
10
8 #include "base/basictypes.h" 11 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
10 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
11 #include "chromeos/chromeos_export.h" 14 #include "chromeos/chromeos_export.h"
12 #include "chromeos/dbus/dbus_thread_manager_observer.h" 15 #include "chromeos/dbus/dbus_thread_manager_observer.h"
13 #include "chromeos/dbus/power_manager/policy.pb.h" 16 #include "chromeos/dbus/power_manager/policy.pb.h"
14 #include "chromeos/dbus/power_manager_client.h" 17 #include "chromeos/dbus/power_manager_client.h"
15 18
16 namespace chromeos { 19 namespace chromeos {
17 20
(...skipping 28 matching lines...) Expand all
46 const PrefService::Preference& battery_screen_off_delay_ms_pref, 49 const PrefService::Preference& battery_screen_off_delay_ms_pref,
47 const PrefService::Preference& battery_screen_lock_delay_ms_pref, 50 const PrefService::Preference& battery_screen_lock_delay_ms_pref,
48 const PrefService::Preference& battery_idle_warning_delay_ms_pref, 51 const PrefService::Preference& battery_idle_warning_delay_ms_pref,
49 const PrefService::Preference& battery_idle_delay_ms_pref, 52 const PrefService::Preference& battery_idle_delay_ms_pref,
50 const PrefService::Preference& idle_action_pref, 53 const PrefService::Preference& idle_action_pref,
51 const PrefService::Preference& lid_closed_action_pref, 54 const PrefService::Preference& lid_closed_action_pref,
52 const PrefService::Preference& use_audio_activity_pref, 55 const PrefService::Preference& use_audio_activity_pref,
53 const PrefService::Preference& use_video_activity_pref, 56 const PrefService::Preference& use_video_activity_pref,
54 const PrefService::Preference& presentation_idle_delay_factor_pref); 57 const PrefService::Preference& presentation_idle_delay_factor_pref);
55 58
59 // Registers a request to temporarily prevent the screen from getting
60 // dimmed or turned off or the system from suspending in response to user
61 // inactivity. Returns a unique ID that can be passed to RemoveBlock()
62 // later.
63 int AddScreenBlock(const std::string& reason);
64 int AddSuspendBlock(const std::string& reason);
65
66 // Unregisters a request previously created via AddScreenBlock() or
67 // AddSuspendBlock().
68 void RemoveBlock(int id);
69
56 // DBusThreadManagerObserver implementation: 70 // DBusThreadManagerObserver implementation:
57 virtual void OnDBusThreadManagerDestroying(DBusThreadManager* manager) 71 virtual void OnDBusThreadManagerDestroying(DBusThreadManager* manager)
58 OVERRIDE; 72 OVERRIDE;
59 73
60 // PowerManagerClient::Observer implementation: 74 // PowerManagerClient::Observer implementation:
61 virtual void PowerManagerRestarted() OVERRIDE; 75 virtual void PowerManagerRestarted() OVERRIDE;
62 76
63 private: 77 private:
78 typedef std::map<int, std::string> BlockMap;
79
64 // Sends a policy based on |prefs_policy_| to the power manager. 80 // Sends a policy based on |prefs_policy_| to the power manager.
65 void SendCurrentPolicy(); 81 void SendCurrentPolicy();
66 82
67 // Sends an empty policy to the power manager to reset its configuration. 83 // Sends an empty policy to the power manager to reset its configuration.
68 void SendEmptyPolicy(); 84 void SendEmptyPolicy();
69 85
70 DBusThreadManager* manager_; // not owned 86 DBusThreadManager* manager_; // not owned
71 PowerManagerClient* client_; // not owned 87 PowerManagerClient* client_; // not owned
72 88
73 // Policy specified by the prefs that were last passed to 89 // Policy specified by the prefs that were last passed to
74 // UpdatePolicyFromPrefs(). 90 // UpdatePolicyFromPrefs().
75 power_manager::PowerManagementPolicy prefs_policy_; 91 power_manager::PowerManagementPolicy prefs_policy_;
76 92
93 // Are one or more fields set in |prefs_policy_|?
94 bool prefs_were_set_;
95
96 // Maps from an ID representing a request to prevent the screen from
97 // getting dimmed or turned off or to prevent the system from suspending
98 // to the reason for the request.
99 BlockMap screen_blocks_;
100 BlockMap suspend_blocks_;
101
102 // Next ID to be used by AddScreenBlock() or AddSuspendBlock().
103 int next_block_id_;
104
77 DISALLOW_COPY_AND_ASSIGN(PowerPolicyController); 105 DISALLOW_COPY_AND_ASSIGN(PowerPolicyController);
78 }; 106 };
79 107
80 } // namespace chromeos 108 } // namespace chromeos
81 109
82 #endif // CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_ 110 #endif // CHROMEOS_DBUS_POWER_POLICY_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698