Bug 1382955 (part 2) - Remove nsIPowerManagerService::{powerOff,reboot,restart} and related things. r=gsvelto.
authorNicholas Nethercote <nnethercote@mozilla.com>
Wed, 02 Aug 2017 10:09:26 +1000
changeset 421906 2345ddc27945fb93f71de800f0cf79184c3c1550
parent 421905 615e7773cd68625b1d8ce9c22df7186c7ae921ca
child 421907 df3915693fa3bec56bacc17a4f2588f99ab635b4
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgsvelto
bugs1382955
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1382955 (part 2) - Remove nsIPowerManagerService::{powerOff,reboot,restart} and related things. r=gsvelto.
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/ContentPrefs.cpp
dom/power/PowerManagerService.cpp
dom/power/PowerManagerService.h
dom/power/nsIPowerManagerService.idl
hal/Hal.cpp
hal/Hal.h
hal/HalTypes.h
hal/fallback/FallbackPower.cpp
hal/linux/LinuxPower.cpp
hal/moz.build
hal/sandbox/SandboxHal.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -554,17 +554,17 @@ nsTArray<ContentParent*>* ContentParent:
 StaticAutoPtr<LinkedList<ContentParent> > ContentParent::sContentParents;
 #if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
 UniquePtr<SandboxBrokerPolicyFactory> ContentParent::sSandboxBrokerPolicyFactory;
 #endif
 uint64_t ContentParent::sNextTabParentId = 0;
 nsDataHashtable<nsUint64HashKey, TabParent*> ContentParent::sNextTabParents;
 
 // This is true when subprocess launching is enabled.  This is the
-// case between StartUp() and ShutDown() or JoinAllSubprocesses().
+// case between StartUp() and ShutDown().
 static bool sCanLaunchSubprocesses;
 
 // Set to true if the DISABLE_UNSAFE_CPOW_WARNINGS environment variable is
 // set.
 static bool sDisableUnsafeCPOWWarnings = false;
 
 // The first content child has ID 1, so the chrome process can have ID 0.
 static uint64_t gContentChildID = 1;
@@ -641,63 +641,16 @@ ContentParent::ShutDown()
   // ClearOnShutdown() to clean up our state.
   sCanLaunchSubprocesses = false;
 
 #if defined(XP_LINUX) && defined(MOZ_CONTENT_SANDBOX)
   sSandboxBrokerPolicyFactory = nullptr;
 #endif
 }
 
-/*static*/ void
-ContentParent::JoinProcessesIOThread(const nsTArray<ContentParent*>* aProcesses,
-                                     Monitor* aMonitor, bool* aDone)
-{
-  const nsTArray<ContentParent*>& processes = *aProcesses;
-  for (uint32_t i = 0; i < processes.Length(); ++i) {
-    if (GeckoChildProcessHost* process = processes[i]->mSubprocess) {
-      process->Join();
-    }
-  }
-  {
-    MonitorAutoLock lock(*aMonitor);
-    *aDone = true;
-    lock.Notify();
-  }
-  // Don't touch any arguments to this function from now on.
-}
-
-/*static*/ void
-ContentParent::JoinAllSubprocesses()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-
-  AutoTArray<ContentParent*, 8> processes;
-  GetAll(processes);
-  if (processes.IsEmpty()) {
-    printf_stderr("There are no live subprocesses.");
-    return;
-  }
-
-  printf_stderr("Subprocesses are still alive.  Doing emergency join.\n");
-
-  bool done = false;
-  Monitor monitor("mozilla.dom.ContentParent.JoinAllSubprocesses");
-  XRE_GetIOMessageLoop()->PostTask(NewRunnableFunction(
-                                     &ContentParent::JoinProcessesIOThread,
-                                     &processes, &monitor, &done));
-  {
-    MonitorAutoLock lock(monitor);
-    while (!done) {
-      lock.Wait();
-    }
-  }
-
-  sCanLaunchSubprocesses = false;
-}
-
 /*static*/ uint32_t
 ContentParent::GetPoolSize(const nsAString& aContentProcessType)
 {
   if (!sBrowserContentParents) {
     return 0;
   }
 
   nsTArray<ContentParent*>* parents =
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -135,24 +135,16 @@ public:
    * Start up the content-process machinery.  This might include
    * scheduling pre-launch tasks.
    */
   static void StartUp();
 
   /** Shut down the content-process machinery. */
   static void ShutDown();
 
-  /**
-   * Ensure that all subprocesses are terminated and their OS
-   * resources have been reaped.  This is synchronous and can be
-   * very expensive in general.  It also bypasses the normal
-   * shutdown process.
-   */
-  static void JoinAllSubprocesses();
-
   static uint32_t GetPoolSize(const nsAString& aContentProcessType);
 
   static uint32_t GetMaxProcessCount(const nsAString& aContentProcessType);
 
   static bool IsMaxProcessCountReached(const nsAString& aContentProcessType);
 
   static void ReleaseCachedProcesses();
 
@@ -666,19 +658,16 @@ private:
    * removed from this list, but will still be in the sContentParents list for
    * the GetAll/GetAllEvenIfDead APIs.
    */
   static nsClassHashtable<nsStringHashKey, nsTArray<ContentParent*>>* sBrowserContentParents;
   static nsTArray<ContentParent*>* sPrivateContent;
   static nsDataHashtable<nsUint32HashKey, ContentParent*> *sJSPluginContentParents;
   static StaticAutoPtr<LinkedList<ContentParent> > sContentParents;
 
-  static void JoinProcessesIOThread(const nsTArray<ContentParent*>* aProcesses,
-                                    Monitor* aMonitor, bool* aDone);
-
   static hal::ProcessPriority GetInitialProcessPriority(Element* aFrameElement);
 
   static ContentBridgeParent* CreateContentBridgeParent(const TabContext& aContext,
                                                         const hal::ProcessPriority& aPriority,
                                                         const TabId& aOpenerTabId,
                                                         const TabId& aTabId);
 
   // Hide the raw constructor methods since we don't want client code
--- a/dom/ipc/ContentPrefs.cpp
+++ b/dom/ipc/ContentPrefs.cpp
@@ -209,17 +209,16 @@ const char* mozilla::dom::ContentPrefs::
   "privacy.resistFingerprinting",
   "security.data_uri.unique_opaque_origin",
   "security.fileuri.strict_origin_policy",
   "security.sandbox.content.level",
   "security.sandbox.content.tempDirSuffix",
   "security.sandbox.logging.enabled",
   "security.sandbox.mac.track.violations",
   "security.sandbox.windows.log.stackTraceDepth",
-  "shutdown.watchdog.timeoutSecs",
   "signed.applets.codebase_principal_support",
   "svg.disabled",
   "svg.display-lists.hit-testing.enabled",
   "svg.display-lists.painting.enabled",
   "svg.new-getBBox.enabled",
   "svg.paint-order.enabled",
   "svg.path-caching.enabled",
   "svg.transform-box.enabled",
--- a/dom/power/PowerManagerService.cpp
+++ b/dom/power/PowerManagerService.cpp
@@ -19,34 +19,16 @@
 
 // For _exit().
 #ifdef XP_WIN
 #include <process.h>
 #else
 #include <unistd.h>
 #endif
 
-#ifdef ANDROID
-#include <android/log.h>
-extern "C" char* PrintJSStack();
-static void LogFunctionAndJSStack(const char* funcname) {
-  char *jsstack = PrintJSStack();
-  __android_log_print(ANDROID_LOG_INFO, "PowerManagerService", \
-                      "Call to %s. The JS stack is:\n%s\n",
-                      funcname,
-                      jsstack ? jsstack : "<no JS stack>");
-  js_free(jsstack);
-}
-// bug 839452
-#define LOG_FUNCTION_AND_JS_STACK() \
-  LogFunctionAndJSStack(__PRETTY_FUNCTION__);
-#else
-#define LOG_FUNCTION_AND_JS_STACK()
-#endif
-
 namespace mozilla {
 namespace dom {
 namespace power {
 
 using namespace hal;
 
 NS_IMPL_ISUPPORTS(PowerManagerService, nsIPowerManagerService)
 
@@ -64,22 +46,16 @@ PowerManagerService::GetInstance()
   RefPtr<PowerManagerService> service = sSingleton.get();
   return service.forget();
 }
 
 void
 PowerManagerService::Init()
 {
   RegisterWakeLockObserver(this);
-
-  // NB: default to *enabling* the watchdog even when the pref is
-  // absent, in case the profile might be damaged and we need to
-  // restart to repair it.
-  mWatchdogTimeoutSecs =
-    Preferences::GetInt("shutdown.watchdog.timeoutSecs", 10);
 }
 
 PowerManagerService::~PowerManagerService()
 {
   UnregisterWakeLockObserver(this);
 }
 
 void
@@ -114,78 +90,16 @@ PowerManagerService::Notify(const WakeLo
    */
   AutoTArray<nsCOMPtr<nsIDOMMozWakeLockListener>, 2> listeners(mWakeLockListeners);
 
   for (uint32_t i = 0; i < listeners.Length(); ++i) {
     listeners[i]->Callback(aWakeLockInfo.topic(), state);
   }
 }
 
-void
-PowerManagerService::SyncProfile()
-{
-  nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService();
-  if (obsServ) {
-    const char16_t* context = u"shutdown-persist";
-    obsServ->NotifyObservers(nullptr, "profile-change-net-teardown", context);
-    obsServ->NotifyObservers(nullptr, "profile-change-teardown", context);
-    obsServ->NotifyObservers(nullptr, "profile-before-change", context);
-    obsServ->NotifyObservers(nullptr, "profile-before-change-qm", context);
-    obsServ->NotifyObservers(nullptr, "profile-before-change-telemetry", context);
-  }
-}
-
-NS_IMETHODIMP
-PowerManagerService::Reboot()
-{
-  LOG_FUNCTION_AND_JS_STACK() // bug 839452
-
-  StartForceQuitWatchdog(eHalShutdownMode_Reboot, mWatchdogTimeoutSecs);
-  // To synchronize any unsaved user data before rebooting.
-  SyncProfile();
-  hal::Reboot();
-  MOZ_CRASH("hal::Reboot() shouldn't return");
-}
-
-NS_IMETHODIMP
-PowerManagerService::PowerOff()
-{
-  LOG_FUNCTION_AND_JS_STACK() // bug 839452
-
-  StartForceQuitWatchdog(eHalShutdownMode_PowerOff, mWatchdogTimeoutSecs);
-  // To synchronize any unsaved user data before powering off.
-  SyncProfile();
-  hal::PowerOff();
-  MOZ_CRASH("hal::PowerOff() shouldn't return");
-}
-
-NS_IMETHODIMP
-PowerManagerService::Restart()
-{
-  LOG_FUNCTION_AND_JS_STACK() // bug 839452
-
-  // FIXME/bug 796826 this implementation is currently gonk-specific,
-  // because it relies on the Gonk to initialize the Gecko processes to
-  // restart B2G. It's better to do it here to have a real "restart".
-  StartForceQuitWatchdog(eHalShutdownMode_Restart, mWatchdogTimeoutSecs);
-  // Ensure all content processes are dead before we continue
-  // restarting.  This code is used to restart to apply updates, and
-  // if we don't join all the subprocesses, race conditions can cause
-  // them to see an inconsistent view of the application directory.
-  ContentParent::JoinAllSubprocesses();
-
-  // To synchronize any unsaved user data before restarting.
-  SyncProfile();
-#ifdef XP_UNIX
-  sync();
-#endif
-  _exit(0);
-  MOZ_CRASH("_exit() shouldn't return");
-}
-
 NS_IMETHODIMP
 PowerManagerService::AddWakeLockListener(nsIDOMMozWakeLockListener *aListener)
 {
   if (mWakeLockListeners.Contains(aListener))
     return NS_OK;
 
   mWakeLockListeners.AppendElement(aListener);
   return NS_OK;
--- a/dom/power/PowerManagerService.h
+++ b/dom/power/PowerManagerService.h
@@ -27,19 +27,17 @@ namespace power {
 class PowerManagerService
   : public nsIPowerManagerService
   , public WakeLockObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIPOWERMANAGERSERVICE
 
-  PowerManagerService()
-    : mWatchdogTimeoutSecs(0)
-  {}
+  PowerManagerService() {}
 
   static already_AddRefed<PowerManagerService> GetInstance();
 
   void Init();
 
   // Implement WakeLockObserver
   void Notify(const hal::WakeLockInformation& aWakeLockInfo) override;
 
@@ -65,22 +63,18 @@ public:
 
 private:
 
   ~PowerManagerService();
 
   void ComputeWakeLockState(const hal::WakeLockInformation& aWakeLockInfo,
                             nsAString &aState);
 
-  void SyncProfile();
-
   static StaticRefPtr<PowerManagerService> sSingleton;
 
   nsTArray<nsCOMPtr<nsIDOMMozWakeLockListener>> mWakeLockListeners;
-
-  int32_t mWatchdogTimeoutSecs;
 };
 
 } // namespace power
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_power_PowerManagerService_h
--- a/dom/power/nsIPowerManagerService.idl
+++ b/dom/power/nsIPowerManagerService.idl
@@ -14,31 +14,16 @@ interface nsIDOMMozWakeLockListener;
 interface mozIDOMWindow;
 
 /**
  * For use with non-content code.
  */
 [scriptable, builtinclass, uuid(ba7ca4c1-9d92-4425-a83b-85dd7fa953f7)]
 interface nsIPowerManagerService : nsISupports
 {
-  /**
-   * This API will power off the machine.
-   */
-  void              powerOff();
-
-  /**
-   * This API will completely shut down and boot the machine.
-   */
-  void              reboot();
-
-  /**
-   * This API will restart the Gecko processes without powering off the machine.
-   */
-  void              restart();
-
   void              addWakeLockListener(in nsIDOMMozWakeLockListener aListener);
   void              removeWakeLockListener(in nsIDOMMozWakeLockListener aListener);
   DOMString         getWakeLockState(in DOMString aTopic);
 
   /**
    * Return a wake lock (MozWakeLock) object of aTopic associated with aWindow.
    * A wake lock without associated window, e.g. used in chrome, is
    * always considered invisible.
--- a/hal/Hal.cpp
+++ b/hal/Hal.cpp
@@ -641,37 +641,16 @@ GetCurrentNetworkInformation(NetworkInfo
 
 void
 NotifyNetworkChange(const NetworkInformation& aInfo)
 {
   NetworkObservers().CacheInformation(aInfo);
   NetworkObservers().BroadcastCachedInformation();
 }
 
-void Reboot()
-{
-  AssertMainProcess();
-  AssertMainThread();
-  PROXY_IF_SANDBOXED(Reboot());
-}
-
-void PowerOff()
-{
-  AssertMainProcess();
-  AssertMainThread();
-  PROXY_IF_SANDBOXED(PowerOff());
-}
-
-void StartForceQuitWatchdog(ShutdownMode aMode, int32_t aTimeoutSecs)
-{
-  AssertMainProcess();
-  AssertMainThread();
-  PROXY_IF_SANDBOXED(StartForceQuitWatchdog(aMode, aTimeoutSecs));
-}
-
 void
 RegisterWakeLockObserver(WakeLockObserver* aObserver)
 {
   AssertMainThread();
   WakeLockObservers().AddObserver(aObserver);
 }
 
 void
--- a/hal/Hal.h
+++ b/hal/Hal.h
@@ -286,30 +286,16 @@ void UnregisterSystemTimezoneChangeObser
 /**
  * Notify of a change in the system timezone.
  * @param aSystemTimezoneChangeInfo
  */
 void NotifySystemTimezoneChange(
   const hal::SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo);
 
 /**
- * Reboot the device.
- *
- * This API is currently only allowed to be used from the main process.
- */
-void Reboot();
-
-/**
- * Power off the device.
- *
- * This API is currently only allowed to be used from the main process.
- */
-void PowerOff();
-
-/**
  * Enable wake lock notifications from the backend.
  *
  * This method is only used by WakeLockObserversManager.
  */
 void EnableWakeLockNotifications();
 
 /**
  * Disable wake lock notifications from the backend.
@@ -456,25 +442,16 @@ void SetCurrentThreadPriority(hal::Threa
  * Set a thread priority to appropriate platform-specific value for
  * given functionality. Instead of providing arbitrary priority numbers you
  * must specify a type of function like THREAD_PRIORITY_COMPOSITOR.
  */
 void SetThreadPriority(PlatformThreadId aThreadId,
                        hal::ThreadPriority aThreadPriority);
 
 /**
- * Start a watchdog to compulsively shutdown the system if it hangs.
- * @param aMode Specify how to shutdown the system.
- * @param aTimeoutSecs Specify the delayed seconds to shutdown the system.
- *
- * This API is currently only allowed to be used from the main process.
- */
-void StartForceQuitWatchdog(hal::ShutdownMode aMode, int32_t aTimeoutSecs);
-
-/**
  * Start monitoring disk space for low space situations.
  *
  * This API is currently only allowed to be used from the main process.
  */
 void StartDiskSpaceWatcher();
 
 /**
  * Stop monitoring disk space for low space situations.
--- a/hal/HalTypes.h
+++ b/hal/HalTypes.h
@@ -15,29 +15,16 @@ namespace hal {
 /**
  * These constants specify special values for content process IDs.  You can get
  * a content process ID by calling ContentChild::GetID() or
  * ContentParent::GetChildID().
  */
 const uint64_t CONTENT_PROCESS_ID_UNKNOWN = uint64_t(-1);
 const uint64_t CONTENT_PROCESS_ID_MAIN = 0;
 
-/**
- * These are defined by libhardware, specifically, hardware/libhardware/include/hardware/lights.h
- * in the gonk subsystem.
- * If these change and are exposed to JS, make sure nsIHal.idl is updated as well.
- */
-enum ShutdownMode {
-  eHalShutdownMode_Unknown  = -1,
-  eHalShutdownMode_PowerOff = 0,
-  eHalShutdownMode_Reboot   = 1,
-  eHalShutdownMode_Restart  = 2,
-  eHalShutdownMode_Count    = 3
-};
-
 class SwitchEvent;
 
 enum SwitchDevice {
   SWITCH_DEVICE_UNKNOWN = -1,
   SWITCH_HEADPHONES,
   SWITCH_USB,
   NUM_SWITCH_DEVICE
 };
@@ -115,27 +102,16 @@ enum WakeLockControl {
 };
 
 } // namespace hal
 } // namespace mozilla
 
 namespace IPC {
 
 /**
- * Serializer for ShutdownMode.
- */
-template <>
-struct ParamTraits<mozilla::hal::ShutdownMode>
-  : public ContiguousEnumSerializer<
-             mozilla::hal::ShutdownMode,
-             mozilla::hal::eHalShutdownMode_Unknown,
-             mozilla::hal::eHalShutdownMode_Count>
-{};
-
-/**
  * WakeLockControl serializer.
  */
 template <>
 struct ParamTraits<mozilla::hal::WakeLockControl>
   : public ContiguousEnumSerializer<
              mozilla::hal::WakeLockControl,
              mozilla::hal::WAKE_LOCK_REMOVE_ONE,
              mozilla::hal::NUM_WAKE_LOCK>
deleted file mode 100644
--- a/hal/fallback/FallbackPower.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set sw=2 ts=8 et ft=cpp : */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "Hal.h"
-
-namespace mozilla {
-namespace hal_impl {
-
-void
-Reboot()
-{}
-
-void
-PowerOff()
-{}
-
-void
-StartForceQuitWatchdog(hal::ShutdownMode aMode, int32_t aTimeoutSecs)
-{}
-
-} // namespace hal_impl
-} // namespace mozilla
deleted file mode 100644
--- a/hal/linux/LinuxPower.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "Hal.h"
-#include "HalLog.h"
-
-#include <unistd.h>
-#include <sys/reboot.h>
-#include "nsIObserverService.h"
-#include "mozilla/Services.h"
-#include "MainThreadUtils.h"
-
-namespace mozilla {
-namespace hal_impl {
-
-void
-Reboot()
-{
-  if (NS_IsMainThread()) {
-    nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService();
-    if (obsServ) {
-      obsServ->NotifyObservers(nullptr, "system-reboot", nullptr);
-    }
-  }
-
-  sync();
-  reboot(RB_AUTOBOOT);
-}
-
-void
-PowerOff()
-{
-  if (NS_IsMainThread()) {
-    nsCOMPtr<nsIObserverService> obsServ = services::GetObserverService();
-    if (obsServ) {
-      obsServ->NotifyObservers(nullptr, "system-power-off", nullptr);
-    }
-  }
-
-  sync();
-  reboot(RB_POWER_OFF);
-}
-
-// Structure to specify how watchdog pthread is going to work.
-typedef struct watchdogParam
-{
-  hal::ShutdownMode mode; // Specify how to shutdown the system.
-  int32_t timeoutSecs;    // Specify the delayed seconds to shutdown the system.
-
-  watchdogParam(hal::ShutdownMode aMode, int32_t aTimeoutSecs)
-    : mode(aMode), timeoutSecs(aTimeoutSecs) {}
-} watchdogParam_t;
-
-// Function to complusively shut down the system with a given mode.
-static void
-QuitHard(hal::ShutdownMode aMode)
-{
-  switch (aMode)
-  {
-    case hal::eHalShutdownMode_PowerOff:
-      PowerOff();
-      break;
-    case hal::eHalShutdownMode_Reboot:
-      Reboot();
-      break;
-    case hal::eHalShutdownMode_Restart:
-      // Don't let signal handlers affect forced shutdown.
-      kill(0, SIGKILL);
-      // If we can't SIGKILL our process group, something is badly
-      // wrong.  Trying to deliver a catch-able signal to ourselves can
-      // invoke signal handlers and might cause problems.  So try
-      // _exit() and hope we go away.
-      _exit(1);
-      break;
-    default:
-      MOZ_CRASH();
-  }
-}
-
-// Function to complusively shut down the system with a given mode when timeout.
-static void*
-ForceQuitWatchdog(void* aParamPtr)
-{
-  watchdogParam_t* paramPtr = reinterpret_cast<watchdogParam_t*>(aParamPtr);
-  if (paramPtr->timeoutSecs > 0 && paramPtr->timeoutSecs <= 30) {
-    // If we shut down normally before the timeout, this thread will
-    // be harmlessly reaped by the OS.
-    TimeStamp deadline =
-      (TimeStamp::Now() + TimeDuration::FromSeconds(paramPtr->timeoutSecs));
-    while (true) {
-      TimeDuration remaining = (deadline - TimeStamp::Now());
-      int sleepSeconds = int(remaining.ToSeconds());
-      if (sleepSeconds <= 0) {
-        break;
-      }
-      sleep(sleepSeconds);
-    }
-  }
-  hal::ShutdownMode mode = paramPtr->mode;
-  delete paramPtr;
-  QuitHard(mode);
-  return nullptr;
-}
-
-void
-StartForceQuitWatchdog(hal::ShutdownMode aMode, int32_t aTimeoutSecs)
-{
-  // Force-quits are intepreted a little more ferociously on Gonk,
-  // because while Gecko is in the process of shutting down, the user
-  // can't call 911, for example.  And if we hang on shutdown, bad
-  // things happen.  So, make sure that doesn't happen.
-  if (aTimeoutSecs <= 0) {
-    return;
-  }
-
-  // Use a raw pthread here to insulate ourselves from bugs in other
-  // Gecko code that we're trying to protect!
-  //
-  // Note that we let the watchdog in charge of releasing |paramPtr|
-  // if the pthread is successfully created.
-  watchdogParam_t* paramPtr = new watchdogParam_t(aMode, aTimeoutSecs);
-  pthread_t watchdog;
-  if (pthread_create(&watchdog, nullptr,
-                     ForceQuitWatchdog,
-                     reinterpret_cast<void*>(paramPtr))) {
-    // Better safe than sorry.
-    delete paramPtr;
-    QuitHard(aMode);
-  }
-  // The watchdog thread is off and running now.
-}
-
-} // hal_impl
-} // mozilla
--- a/hal/moz.build
+++ b/hal/moz.build
@@ -33,80 +33,74 @@ SOURCES += [
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     LOCAL_INCLUDES += [
         '/widget/android',
     ]
     UNIFIED_SOURCES += [
         'android/AndroidSensor.cpp',
-        'fallback/FallbackPower.cpp',
         'linux/LinuxMemory.cpp',
     ]
     # AndroidHal.cpp cannot be built in unified mode because it relies on HalImpl.h.
     SOURCES += [
         'android/AndroidHal.cpp',
     ]
 elif CONFIG['OS_TARGET'] == 'Linux':
     UNIFIED_SOURCES += [
         'fallback/FallbackScreenConfiguration.cpp',
         'fallback/FallbackSensor.cpp',
         'fallback/FallbackVibration.cpp',
         'linux/LinuxMemory.cpp',
-        'linux/LinuxPower.cpp',
     ]
     if CONFIG['MOZ_ENABLE_DBUS']:
         UNIFIED_SOURCES += [
             'linux/UPowerClient.cpp',
         ]
     else:
         UNIFIED_SOURCES += [
             'fallback/FallbackBattery.cpp',
         ]
 elif CONFIG['OS_TARGET'] == 'WINNT':
     UNIFIED_SOURCES += [
         'fallback/FallbackMemory.cpp',
-        'fallback/FallbackPower.cpp',
         'fallback/FallbackScreenConfiguration.cpp',
         'fallback/FallbackVibration.cpp',
         'windows/WindowsSensor.cpp',
     ]
     # WindowsBattery.cpp cannot be built in unified mode because it relies on HalImpl.h.
     SOURCES += [
         'windows/WindowsBattery.cpp',
     ]
 elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     UNIFIED_SOURCES += [
         'cocoa/CocoaBattery.cpp',
         'fallback/FallbackMemory.cpp',
-        'fallback/FallbackPower.cpp',
         'fallback/FallbackScreenConfiguration.cpp',
         'fallback/FallbackVibration.cpp',
     ]
 elif CONFIG['OS_TARGET'] in ('OpenBSD', 'NetBSD', 'FreeBSD', 'DragonFly'):
     UNIFIED_SOURCES += [
         'fallback/FallbackMemory.cpp',
-        'fallback/FallbackPower.cpp',
         'fallback/FallbackScreenConfiguration.cpp',
         'fallback/FallbackSensor.cpp',
         'fallback/FallbackVibration.cpp',
     ]
     if CONFIG['MOZ_ENABLE_DBUS']:
         UNIFIED_SOURCES += [
             'linux/UPowerClient.cpp',
         ]
     else:
         UNIFIED_SOURCES += [
             'fallback/FallbackBattery.cpp',
         ]
 else:
     UNIFIED_SOURCES += [
         'fallback/FallbackBattery.cpp',
         'fallback/FallbackMemory.cpp',
-        'fallback/FallbackPower.cpp',
         'fallback/FallbackScreenConfiguration.cpp',
         'fallback/FallbackSensor.cpp',
         'fallback/FallbackVibration.cpp',
     ]
 
 # Fallbacks for backends implemented on Gonk only.
 UNIFIED_SOURCES += [
     'fallback/FallbackDiskSpaceWatcher.cpp',
--- a/hal/sandbox/SandboxHal.cpp
+++ b/hal/sandbox/SandboxHal.cpp
@@ -240,34 +240,16 @@ EnableSystemTimezoneChangeNotifications(
 
 void
 DisableSystemTimezoneChangeNotifications()
 {
   Hal()->SendDisableSystemTimezoneChangeNotifications();
 }
 
 void
-Reboot()
-{
-  MOZ_CRASH("Reboot() can't be called from sandboxed contexts.");
-}
-
-void
-PowerOff()
-{
-  MOZ_CRASH("PowerOff() can't be called from sandboxed contexts.");
-}
-
-void
-StartForceQuitWatchdog(ShutdownMode aMode, int32_t aTimeoutSecs)
-{
-  MOZ_CRASH("StartForceQuitWatchdog() can't be called from sandboxed contexts.");
-}
-
-void
 EnableSensorNotifications(SensorType aSensor) {
   Hal()->SendEnableSensorNotifications(aSensor);
 }
 
 void
 DisableSensorNotifications(SensorType aSensor) {
   Hal()->SendDisableSensorNotifications(aSensor);
 }