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 bb5efcdd68f83f69368496f00f3305434035073a..c744f99378f5ae096f8cda9664b8809334346dc9 100644 |
| --- a/chrome/browser/chromeos/cros/power_library.cc |
| +++ b/chrome/browser/chromeos/cros/power_library.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/string_util.h" |
| #include "chrome/browser/browser_thread.h" |
| #include "chrome/browser/chromeos/cros/cros_library.h" |
| +#include "third_party/cros/chromeos_resume.h" |
| namespace chromeos { |
| @@ -25,6 +26,10 @@ class PowerLibraryImpl : public PowerLibrary { |
| if (power_status_connection_) { |
| chromeos::DisconnectPowerStatus(power_status_connection_); |
|
Nikita (slow)
2011/02/15 15:23:20
set power_status_connection_ to NULL?
glotov
2011/02/15 15:35:49
Done.
|
| } |
| + if (resume_status_connection_) { |
| + chromeos::DisconnectResume(resume_status_connection_); |
| + resume_status_connection_ = NULL; |
| + } |
| } |
| void AddObserver(Observer* observer) { |
| @@ -94,9 +99,16 @@ class PowerLibraryImpl : public PowerLibrary { |
| power->UpdatePowerStatus(status); |
| } |
| + static void SystemResumedHandler(void* object) { |
| + PowerLibraryImpl* power = static_cast<PowerLibraryImpl*>(object); |
| + power->SystemResumed(); |
| + } |
| + |
| void Init() { |
| power_status_connection_ = chromeos::MonitorPowerStatus( |
| &PowerStatusChangedHandler, this); |
| + resume_status_connection_ = |
| + chromeos::MonitorResume(&SystemResumedHandler, this); |
| } |
| void UpdatePowerStatus(const chromeos::PowerStatus& status) { |
| @@ -118,12 +130,27 @@ class PowerLibraryImpl : public PowerLibrary { |
| FOR_EACH_OBSERVER(Observer, observers_, PowerChanged(this)); |
| } |
| + void SystemResumed() { |
| + // Make sure we run on the UI thread. |
| + if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, FROM_HERE, |
| + NewRunnableMethod(this, &PowerLibraryImpl::SystemResumed)); |
| + return; |
| + } |
| + |
| + FOR_EACH_OBSERVER(Observer, observers_, SystemResumed()); |
| + } |
| + |
| ObserverList<Observer> observers_; |
| // A reference to the battery power api, to allow callbacks when the battery |
| // status changes. |
| chromeos::PowerStatusConnection power_status_connection_; |
| + // A reference to the resume alerts. |
| + chromeos::ResumeConnection resume_status_connection_; |
| + |
| // The latest power status. |
| chromeos::PowerStatus status_; |