summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-29 19:54:24 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-29 19:54:24 +0000
commiteb5614468cee0ca2f6db9bf69dfa97bf942a0a64 (patch)
treee32860f5a3b204051e2ce85ee261ee298393700c /chromeos
parent4859d067e10a262569b41a4558cb38f04d0bef54 (diff)
downloadchromium_src-eb5614468cee0ca2f6db9bf69dfa97bf942a0a64.zip
chromium_src-eb5614468cee0ca2f6db9bf69dfa97bf942a0a64.tar.gz
chromium_src-eb5614468cee0ca2f6db9bf69dfa97bf942a0a64.tar.bz2
chromeos: Fix lock-before-suspend regression.
This fixes an uninitialized member variable in ash::internal::PowerEventObserver that could result in the screen not getting locked before the system goes to sleep. BUG=312210 Review URL: https://codereview.chromium.org/49743004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231622 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/fake_power_manager_client.cc4
-rw-r--r--chromeos/dbus/fake_power_manager_client.h1
-rw-r--r--chromeos/dbus/power_manager_client.cc26
-rw-r--r--chromeos/dbus/power_manager_client.h4
4 files changed, 33 insertions, 2 deletions
diff --git a/chromeos/dbus/fake_power_manager_client.cc b/chromeos/dbus/fake_power_manager_client.cc
index 3c70a6f..81ca360 100644
--- a/chromeos/dbus/fake_power_manager_client.cc
+++ b/chromeos/dbus/fake_power_manager_client.cc
@@ -51,6 +51,10 @@ base::Closure FakePowerManagerClient::GetSuspendReadinessCallback() {
return base::Closure();
}
+int FakePowerManagerClient::GetNumPendingSuspendReadinessCallbacks() {
+ return 0;
+}
+
bool FakePowerManagerClient::HasObserver(Observer* observer) {
return false;
}
diff --git a/chromeos/dbus/fake_power_manager_client.h b/chromeos/dbus/fake_power_manager_client.h
index d89bb51..ae1adc5 100644
--- a/chromeos/dbus/fake_power_manager_client.h
+++ b/chromeos/dbus/fake_power_manager_client.h
@@ -47,6 +47,7 @@ class FakePowerManagerClient : public PowerManagerClient {
const power_manager::PowerManagementPolicy& policy) OVERRIDE;
virtual void SetIsProjecting(bool is_projecting) OVERRIDE;
virtual base::Closure GetSuspendReadinessCallback() OVERRIDE;
+ virtual int GetNumPendingSuspendReadinessCallbacks() OVERRIDE;
power_manager::PowerManagementPolicy& get_policy() { return policy_; }
diff --git a/chromeos/dbus/power_manager_client.cc b/chromeos/dbus/power_manager_client.cc
index 82b934a..c065c09 100644
--- a/chromeos/dbus/power_manager_client.cc
+++ b/chromeos/dbus/power_manager_client.cc
@@ -211,6 +211,10 @@ class PowerManagerClientImpl : public PowerManagerClient {
weak_ptr_factory_.GetWeakPtr(), pending_suspend_id_);
}
+ virtual int GetNumPendingSuspendReadinessCallbacks() OVERRIDE {
+ return num_pending_suspend_readiness_callbacks_;
+ }
+
protected:
virtual void Init(dbus::Bus* bus) OVERRIDE {
power_manager_proxy_ = bus->GetObjectProxy(
@@ -641,11 +645,16 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
brightness_(50.0),
pause_count_(2),
cycle_count_(0),
+ num_pending_suspend_readiness_callbacks_(0),
weak_ptr_factory_(this) {}
virtual ~PowerManagerClientStubImpl() {}
- // PowerManagerClient overrides
+ int num_pending_suspend_readiness_callbacks() const {
+ return num_pending_suspend_readiness_callbacks_;
+ }
+
+ // PowerManagerClient overrides:
virtual void Init(dbus::Bus* bus) OVERRIDE {
if (CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kEnableStubInteractive)) {
@@ -714,10 +723,19 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
const power_manager::PowerManagementPolicy& policy) OVERRIDE {}
virtual void SetIsProjecting(bool is_projecting) OVERRIDE {}
virtual base::Closure GetSuspendReadinessCallback() OVERRIDE {
- return base::Closure();
+ num_pending_suspend_readiness_callbacks_++;
+ return base::Bind(&PowerManagerClientStubImpl::HandleSuspendReadiness,
+ weak_ptr_factory_.GetWeakPtr());
+ }
+ virtual int GetNumPendingSuspendReadinessCallbacks() OVERRIDE {
+ return num_pending_suspend_readiness_callbacks_;
}
private:
+ void HandleSuspendReadiness() {
+ num_pending_suspend_readiness_callbacks_--;
+ }
+
void UpdateStatus() {
if (pause_count_ > 0) {
pause_count_--;
@@ -802,6 +820,10 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
base::RepeatingTimer<PowerManagerClientStubImpl> update_timer_;
power_manager::PowerSupplyProperties props_;
+ // Number of callbacks returned by GetSuspendReadinessCallback() but not yet
+ // invoked.
+ int num_pending_suspend_readiness_callbacks_;
+
// Note: This should remain the last member so it'll be destroyed and
// invalidate its weak pointers before any other members are destroyed.
base::WeakPtrFactory<PowerManagerClientStubImpl> weak_ptr_factory_;
diff --git a/chromeos/dbus/power_manager_client.h b/chromeos/dbus/power_manager_client.h
index a24312b..5c957f4 100644
--- a/chromeos/dbus/power_manager_client.h
+++ b/chromeos/dbus/power_manager_client.h
@@ -143,6 +143,10 @@ class CHROMEOS_EXPORT PowerManagerClient : public DBusClient {
// readiness for suspend. See Observer::SuspendImminent().
virtual base::Closure GetSuspendReadinessCallback() = 0;
+ // Returns the number of callbacks returned by GetSuspendReadinessCallback()
+ // for the current suspend attempt but not yet called. Used by tests.
+ virtual int GetNumPendingSuspendReadinessCallbacks() = 0;
+
// Creates the instance.
static PowerManagerClient* Create(DBusClientImplementationType type);