Chromium Code Reviews| Index: chrome/browser/chromeos/cros/power_library.cc |
| diff --git a/chrome/browser/chromeos/cros/power_library.cc b/chrome/browser/chromeos/cros/power_library.cc |
| index dbedff9286f14b6ab54f04a70cbce470124a69d9..a804f7cbc52d96839378901d285f649a2a89e5ef 100644 |
| --- a/chrome/browser/chromeos/cros/power_library.cc |
| +++ b/chrome/browser/chromeos/cros/power_library.cc |
| @@ -38,12 +38,11 @@ class PowerLibraryImpl : public PowerLibrary { |
| // Begin PowerLibrary implementation. |
| virtual void Init() OVERRIDE { |
| - if (CrosLibrary::Get()->EnsureLoaded()) { |
| - power_status_connection_ = |
| - chromeos::MonitorPowerStatus(&PowerStatusChangedHandler, this); |
| - resume_status_connection_ = |
| - chromeos::MonitorResume(&SystemResumedHandler, this); |
| - } |
| + DCHECK(CrosLibrary::Get()->libcros_loaded()); |
| + power_status_connection_ = |
| + chromeos::MonitorPowerStatus(&PowerStatusChangedHandler, this); |
| + resume_status_connection_ = |
| + chromeos::MonitorResume(&SystemResumedHandler, this); |
| } |
| virtual void AddObserver(Observer* observer) OVERRIDE { |
| @@ -85,9 +84,6 @@ class PowerLibraryImpl : public PowerLibrary { |
| } |
| virtual void EnableScreenLock(bool enable) OVERRIDE { |
| - if (!CrosLibrary::Get()->EnsureLoaded()) |
| - return; |
| - |
| // Make sure we run on FILE thread becuase chromeos::EnableScreenLock |
| // would write power manager config file to disk. |
| if (!BrowserThread::CurrentlyOn(BrowserThread::FILE)) { |
| @@ -101,14 +97,19 @@ class PowerLibraryImpl : public PowerLibrary { |
| } |
| virtual void RequestRestart() OVERRIDE { |
| - if (CrosLibrary::Get()->EnsureLoaded()) |
| - chromeos::RequestRestart(); |
| + chromeos::RequestRestart(); |
| } |
| virtual void RequestShutdown() OVERRIDE { |
| - if (CrosLibrary::Get()->EnsureLoaded()) |
| - chromeos::RequestShutdown(); |
| + chromeos::RequestShutdown(); |
| } |
| + |
| + virtual void RequestStatusUpdate() OVERRIDE { |
| + PowerInformation information; |
| + chromeos::RetrievePowerInformation(&information); |
| + UpdatePowerStatus(information.power_status); |
| + } |
| + |
| // End PowerLibrary implementation. |
| private: |
| @@ -190,13 +191,8 @@ class PowerLibraryStubImpl : public PowerLibrary { |
| public: |
| PowerLibraryStubImpl() |
| : discharging_(true), |
| - battery_percentage_(20), |
| + battery_percentage_(80), |
|
satorux1
2011/09/16 20:05:55
This seems to be unrelated to the refactoring. Wha
stevenjb
2011/09/16 21:44:24
Will do.
|
| pause_count_(0) { |
| - timer_.Start( |
| - FROM_HERE, |
| - base::TimeDelta::FromMilliseconds(100), |
| - this, |
| - &PowerLibraryStubImpl::Update); |
| } |
| virtual ~PowerLibraryStubImpl() {} |
| @@ -245,9 +241,25 @@ class PowerLibraryStubImpl : public PowerLibrary { |
| callback->Run(0); |
| delete callback; |
| } |
| + |
| virtual void EnableScreenLock(bool enable) OVERRIDE {} |
| + |
| virtual void RequestRestart() OVERRIDE {} |
| + |
| virtual void RequestShutdown() OVERRIDE {} |
| + |
| + virtual void RequestStatusUpdate() OVERRIDE { |
| + if (!timer_.IsRunning()) { |
| + timer_.Start( |
| + FROM_HERE, |
| + base::TimeDelta::FromMilliseconds(100), |
| + this, |
| + &PowerLibraryStubImpl::Update); |
| + } else { |
| + timer_.Stop(); |
| + } |
| + } |
| + |
| // End PowerLibrary implementation. |
| private: |