summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-25 01:59:45 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-09-25 01:59:45 +0000
commit845260ab832a2f719972be9acc97f73bfce522ce (patch)
tree481b8f42ae54b818372ab10d96217d7c7bb3ed41 /chromeos
parent42690ee3a5ce7670411656c1d4afdd595cec943c (diff)
downloadchromium_src-845260ab832a2f719972be9acc97f73bfce522ce.zip
chromium_src-845260ab832a2f719972be9acc97f73bfce522ce.tar.gz
chromium_src-845260ab832a2f719972be9acc97f73bfce522ce.tar.bz2
chromeos: Fix power override masks.
PowerManagerClient::RequestPowerStateOverrides() takes a bitmap of OR-ed together PowerStateOverrideType values, but the values from that enum were 1, 2, 3, and 4 instead of using distinct bits. I'm also switching the 'duration' parameter to be a base::TimeDelta so people don't need to read the power manager source code to figure out what to pass. BUG=114128 Review URL: https://chromiumcodereview.appspot.com/10991006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@158494 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/mock_power_manager_client.h2
-rw-r--r--chromeos/dbus/power_manager_client.cc6
-rw-r--r--chromeos/dbus/power_manager_client.h27
-rw-r--r--chromeos/power/power_state_override.cc3
4 files changed, 18 insertions, 20 deletions
diff --git a/chromeos/dbus/mock_power_manager_client.h b/chromeos/dbus/mock_power_manager_client.h
index 30fb716..b9129cc 100644
--- a/chromeos/dbus/mock_power_manager_client.h
+++ b/chromeos/dbus/mock_power_manager_client.h
@@ -37,7 +37,7 @@ class MockPowerManagerClient : public PowerManagerClient {
MOCK_METHOD2(NotifyVideoActivity, void(const base::TimeTicks&, bool));
MOCK_METHOD4(RequestPowerStateOverrides,
void(uint32,
- uint32,
+ base::TimeDelta,
int,
const PowerStateRequestIdCallback&));
MOCK_METHOD1(CancelPowerStateOverrides, void(uint32));
diff --git a/chromeos/dbus/power_manager_client.cc b/chromeos/dbus/power_manager_client.cc
index 7e20bf5..198b137 100644
--- a/chromeos/dbus/power_manager_client.cc
+++ b/chromeos/dbus/power_manager_client.cc
@@ -250,7 +250,7 @@ class PowerManagerClientImpl : public PowerManagerClient {
virtual void RequestPowerStateOverrides(
uint32 request_id,
- uint32 duration,
+ base::TimeDelta duration,
int overrides,
const PowerStateRequestIdCallback& callback) OVERRIDE {
dbus::MethodCall method_call(power_manager::kPowerManagerInterface,
@@ -259,7 +259,7 @@ class PowerManagerClientImpl : public PowerManagerClient {
PowerStateControl protobuf;
protobuf.set_request_id(request_id);
- protobuf.set_duration(duration);
+ protobuf.set_duration(duration.InSeconds());
protobuf.set_disable_idle_dim(overrides & DISABLE_IDLE_DIM);
protobuf.set_disable_idle_blank(overrides & DISABLE_IDLE_BLANK);
protobuf.set_disable_idle_suspend(overrides & DISABLE_IDLE_SUSPEND);
@@ -621,7 +621,7 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
bool is_fullscreen) OVERRIDE {}
virtual void RequestPowerStateOverrides(
uint32 request_id,
- uint32 duration,
+ base::TimeDelta duration,
int overrides,
const PowerStateRequestIdCallback& callback) OVERRIDE {
// Mimic the behavior of power manager w.r.t. the request_id.
diff --git a/chromeos/dbus/power_manager_client.h b/chromeos/dbus/power_manager_client.h
index f6461b3..76edbce 100644
--- a/chromeos/dbus/power_manager_client.h
+++ b/chromeos/dbus/power_manager_client.h
@@ -15,9 +15,6 @@
#include "chromeos/dbus/power_supply_status.h"
-namespace base {
-class TimeTicks;
-}
namespace dbus {
class Bus;
}
@@ -89,10 +86,10 @@ class CHROMEOS_EXPORT PowerManagerClient {
};
enum PowerStateOverrideType {
- DISABLE_IDLE_DIM = 1, // Disable screen dimming on idle.
- DISABLE_IDLE_BLANK = 2, // Disable screen blanking on idle.
- DISABLE_IDLE_SUSPEND = 3, // Disable suspend on idle.
- DISABLE_IDLE_LID_SUSPEND = 4, // Disable suspend on lid closed.
+ DISABLE_IDLE_DIM = 1 << 0, // Disable screen dimming on idle.
+ DISABLE_IDLE_BLANK = 1 << 1, // Disable screen blanking on idle.
+ DISABLE_IDLE_SUSPEND = 1 << 2, // Disable suspend on idle.
+ DISABLE_IDLE_LID_SUSPEND = 1 << 3, // Disable suspend on lid closed.
};
// Adds and removes the observer.
@@ -157,16 +154,16 @@ class CHROMEOS_EXPORT PowerManagerClient {
bool is_fullscreen) = 0;
// Override the current power state on the machine. The overrides will be
- // applied to the request ID specified. To specify a new request; use 0 as
- // the request id and the method will call the provided callback with the
- // new request ID for use with further calls.
- // The overrides parameter will & out the PowerStateOverrideType types to
- // allow specific selection of overrides. For example, to override just dim
- // and suspending but leaving blanking in, set overrides to,
- // DISABLE_IDLE_DIM | DISABLE_IDLE_SUSPEND.
+ // applied to the request ID specified. To specify a new request; use 0 as the
+ // request id and the method will call the provided callback with the new
+ // request ID for use with further calls. |duration| will be rounded down to
+ // the nearest second. The overrides parameter will & out the
+ // PowerStateOverrideType types to allow specific selection of overrides. For
+ // example, to override just dim and suspending but leaving blanking in, set
+ // overrides to, DISABLE_IDLE_DIM | DISABLE_IDLE_SUSPEND.
virtual void RequestPowerStateOverrides(
uint32 request_id,
- uint32 duration,
+ base::TimeDelta duration,
int overrides,
const PowerStateRequestIdCallback& callback) = 0;
diff --git a/chromeos/power/power_state_override.cc b/chromeos/power/power_state_override.cc
index 20582ca..2383f80 100644
--- a/chromeos/power/power_state_override.cc
+++ b/chromeos/power/power_state_override.cc
@@ -70,7 +70,8 @@ void PowerStateOverride::CallRequestPowerStateOverrides() {
if (power_manager) {
power_manager->RequestPowerStateOverrides(
request_id_,
- kHeartbeatTimeInSecs + kRequestSlackInSecs,
+ base::TimeDelta::FromSeconds(
+ kHeartbeatTimeInSecs + kRequestSlackInSecs),
override_types_,
base::Bind(&PowerStateOverride::SetRequestId,
weak_ptr_factory_.GetWeakPtr()));