Bug 709585 - Part 6/6, Connect DOM and hal. r=sicking
☠☠ backed out by 15ca5d162a81 ☠ ☠
authorKan-Ru Chen <kanru@kanru.info>
Mon, 30 Jan 2012 17:02:53 -0600
changeset 88589 10b455909e944bad69d160653477d77e02a3b44f
parent 88588 6a4c4cb828a8f45133fb6a1c0dcb2c545ffd2b0d
child 88590 c52ce509a5c3a6ad9081f1b5ddff2aa397ca5ff3
push id129
push userffxbld
push dateFri, 20 Apr 2012 19:40:49 +0000
treeherdermozilla-release@5bcfa0da3be9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs709585
milestone12.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 709585 - Part 6/6, Connect DOM and hal. r=sicking
dom/power/Makefile.in
dom/power/PowerManager.cpp
dom/power/PowerManagerService.cpp
--- a/dom/power/Makefile.in
+++ b/dom/power/Makefile.in
@@ -63,9 +63,11 @@ XPIDLSRCS = \
   nsIDOMPowerManager.idl \
   nsIPowerManagerService.idl \
   $(NULL)
 
 ifdef ENABLE_TESTS
 DIRS += test
 endif
 
+include $(topsrcdir)/config/config.mk
+include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
--- a/dom/power/PowerManager.cpp
+++ b/dom/power/PowerManager.cpp
@@ -30,19 +30,21 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "PowerManager.h"
+#include "nsContentUtils.h"
 #include "nsDOMClassInfoID.h"
-
-#include "PowerManager.h"
+#include "nsIPowerManagerService.h"
+#include "nsServiceManagerUtils.h"
 
 DOMCI_DATA(MozPowerManager, mozilla::dom::power::PowerManager)
 
 namespace mozilla {
 namespace dom {
 namespace power {
 
 NS_INTERFACE_MAP_BEGIN(PowerManager)
@@ -52,20 +54,36 @@ NS_INTERFACE_MAP_BEGIN(PowerManager)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(PowerManager)
 NS_IMPL_RELEASE(PowerManager)
 
 NS_IMETHODIMP
 PowerManager::Reboot()
 {
-  return NS_ERROR_NOT_IMPLEMENTED;
+  NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_DOM_SECURITY_ERR);
+
+  nsCOMPtr<nsIPowerManagerService> pmService =
+    do_GetService(POWERMANAGERSERVICE_CONTRACTID);
+  NS_ENSURE_TRUE(pmService, NS_OK);
+
+  pmService->Reboot();
+
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 PowerManager::PowerOff()
 {
-  return NS_ERROR_NOT_IMPLEMENTED;
+  NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_DOM_SECURITY_ERR);
+
+  nsCOMPtr<nsIPowerManagerService> pmService =
+    do_GetService(POWERMANAGERSERVICE_CONTRACTID);
+  NS_ENSURE_TRUE(pmService, NS_OK);
+
+  pmService->PowerOff();
+
+  return NS_OK;
 }
 
 } // power
 } // dom
 } // mozilla
--- a/dom/power/PowerManagerService.cpp
+++ b/dom/power/PowerManagerService.cpp
@@ -30,16 +30,17 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#include "mozilla/Hal.h"
 #include "PowerManagerService.h"
 
 namespace mozilla {
 namespace dom {
 namespace power {
 
 NS_IMPL_ISUPPORTS1(PowerManagerService, nsIPowerManagerService)
 
@@ -51,20 +52,22 @@ PowerManagerService::GetInstance()
   pmService = new PowerManagerService();
 
   return pmService.forget();
 }
 
 NS_IMETHODIMP
 PowerManagerService::Reboot()
 {
-  return NS_ERROR_NOT_IMPLEMENTED;
+  hal::Reboot();
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 PowerManagerService::PowerOff()
 {
-  return NS_ERROR_NOT_IMPLEMENTED;
+  hal::PowerOff();
+  return NS_OK;
 }
 
 } // power
 } // dom
 } // mozilla