fixup! Implement powerMonitor 'shutdown' event for Linux

This commit is contained in:
Thiago de Arruda 2017-12-14 08:39:00 -03:00 committed by Cheng Zhao
parent df6328e5d7
commit 45763c0afb

View file

@ -122,12 +122,12 @@ void PowerObserverLinux::OnInhibitResponse(base::ScopedFD* scoped_fd,
void PowerObserverLinux::OnPrepareForSleep(dbus::Signal* signal) { void PowerObserverLinux::OnPrepareForSleep(dbus::Signal* signal) {
dbus::MessageReader reader(signal); dbus::MessageReader reader(signal);
bool status; bool suspending;
if (!reader.PopBool(&status)) { if (!reader.PopBool(&suspending)) {
LOG(ERROR) << "Invalid signal: " << signal->ToString(); LOG(ERROR) << "Invalid signal: " << signal->ToString();
return; return;
} }
if (status) { if (suspending) {
OnSuspend(); OnSuspend();
sleep_lock_.reset(); sleep_lock_.reset();
} else { } else {
@ -138,12 +138,12 @@ void PowerObserverLinux::OnPrepareForSleep(dbus::Signal* signal) {
void PowerObserverLinux::OnPrepareForShutdown(dbus::Signal* signal) { void PowerObserverLinux::OnPrepareForShutdown(dbus::Signal* signal) {
dbus::MessageReader reader(signal); dbus::MessageReader reader(signal);
bool status; bool shutting_down;
if (!reader.PopBool(&status)) { if (!reader.PopBool(&shutting_down)) {
LOG(ERROR) << "Invalid signal: " << signal->ToString(); LOG(ERROR) << "Invalid signal: " << signal->ToString();
return; return;
} }
if (status) { if (shutting_down) {
if (!OnShutdown()) { if (!OnShutdown()) {
// The user didn't try to prevent shutdown. Release the lock and allow the // The user didn't try to prevent shutdown. Release the lock and allow the
// shutdown to continue normally. // shutdown to continue normally.