Bug 993737 - Only fire shutdown notifications on main thread. r=gsvelto

This commit is contained in:
Dave Hylands 2014-04-30 17:20:30 -07:00
parent 601a8e8e4e
commit b4f7791261

View File

@ -9,6 +9,7 @@
#include <sys/reboot.h>
#include "nsIObserverService.h"
#include "mozilla/Services.h"
#include "MainThreadUtils.h"
namespace mozilla {
namespace hal_impl {
@ -16,9 +17,11 @@ namespace hal_impl {
void
Reboot()
{
nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService();
if (obsServ) {
obsServ->NotifyObservers(nullptr, "system-reboot", nullptr);
if (NS_IsMainThread()) {
nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService();
if (obsServ) {
obsServ->NotifyObservers(nullptr, "system-reboot", nullptr);
}
}
sync();
reboot(RB_AUTOBOOT);
@ -27,9 +30,11 @@ Reboot()
void
PowerOff()
{
nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService();
if (obsServ) {
obsServ->NotifyObservers(nullptr, "system-power-off", nullptr);
if (NS_IsMainThread()) {
nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService();
if (obsServ) {
obsServ->NotifyObservers(nullptr, "system-power-off", nullptr);
}
}
sync();
reboot(RB_POWER_OFF);