Bug 839452 - Add helpful logging of DOM calls resulting in reboot/poweroff - r=sicking

This commit is contained in:
Benoit Jacob 2013-09-04 08:14:54 -04:00
parent 94f74c705d
commit 662162b9a6

View File

@ -22,6 +22,23 @@
#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>");
}
// 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 {
@ -115,6 +132,8 @@ PowerManagerService::SyncProfile()
NS_IMETHODIMP
PowerManagerService::Reboot()
{
LOG_FUNCTION_AND_JS_STACK() // bug 839452
StartForceQuitWatchdog(eHalShutdownMode_Reboot, mWatchdogTimeoutSecs);
// To synchronize any unsaved user data before rebooting.
SyncProfile();
@ -125,6 +144,8 @@ PowerManagerService::Reboot()
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();
@ -135,6 +156,8 @@ PowerManagerService::PowerOff()
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".