зеркало из https://github.com/electron/electron.git
fixup! Implement powerMonitor 'shutdown' event for Linux
This commit is contained in:
Родитель
45763c0afb
Коммит
f0e210360f
|
@ -70,10 +70,10 @@ void PowerObserverLinux::OnLoginServiceAvailable(bool service_available) {
|
|||
base::Bind(&PowerObserverLinux::OnSignalConnected,
|
||||
weak_ptr_factory_.GetWeakPtr()));
|
||||
// Take sleep inhibit lock
|
||||
TakeSleepLock();
|
||||
BlockSleep();
|
||||
}
|
||||
|
||||
void PowerObserverLinux::TakeSleepLock() {
|
||||
void PowerObserverLinux::BlockSleep() {
|
||||
dbus::MethodCall sleep_inhibit_call(kLogindManagerInterface, "Inhibit");
|
||||
dbus::MessageWriter inhibit_writer(&sleep_inhibit_call);
|
||||
inhibit_writer.AppendString("sleep"); // what
|
||||
|
@ -88,6 +88,10 @@ void PowerObserverLinux::TakeSleepLock() {
|
|||
weak_ptr_factory_.GetWeakPtr(), &sleep_lock_));
|
||||
}
|
||||
|
||||
void PowerObserverLinux::UnblockSleep() {
|
||||
sleep_lock_.reset();
|
||||
}
|
||||
|
||||
void PowerObserverLinux::BlockShutdown() {
|
||||
if (shutdown_lock.is_valid()) {
|
||||
LOG(WARNING) << "Trying to subscribe to shutdown multiple times";
|
||||
|
@ -129,9 +133,9 @@ void PowerObserverLinux::OnPrepareForSleep(dbus::Signal* signal) {
|
|||
}
|
||||
if (suspending) {
|
||||
OnSuspend();
|
||||
sleep_lock_.reset();
|
||||
UnblockSleep();
|
||||
} else {
|
||||
TakeSleepLock();
|
||||
BlockSleep();
|
||||
OnResume();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,12 +20,13 @@ class PowerObserverLinux : public base::PowerObserver {
|
|||
public:
|
||||
PowerObserverLinux();
|
||||
|
||||
void BlockSleep();
|
||||
void UnblockSleep();
|
||||
void BlockShutdown();
|
||||
void UnblockShutdown();
|
||||
virtual bool OnShutdown() { return false; }
|
||||
|
||||
private:
|
||||
void TakeSleepLock();
|
||||
void OnLoginServiceAvailable(bool available);
|
||||
void OnInhibitResponse(base::ScopedFD* scoped_fd, dbus::Response* response);
|
||||
void OnPrepareForSleep(dbus::Signal* signal);
|
||||
|
|
Загрузка…
Ссылка в новой задаче