Backout Bug 811414 for breaking B2G
authorGregor Wagner <anygregor@gmail.com>
Wed, 14 Nov 2012 13:09:21 -0800
changeset 113285 b809cfffa5f77034f1ea911352a1815da79e37fd
parent 113284 da25394a8b5524956813c8831cd1e75a893d78f1
child 113286 e84da482e8abf30c3bfec0e3d8f8d9211a602eba
push id23864
push userryanvm@gmail.com
push dateThu, 15 Nov 2012 02:43:16 +0000
treeherdermozilla-central@7845cfa93e3f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs811414
milestone19.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
Backout Bug 811414 for breaking B2G
dom/bluetooth/BluetoothService.cpp
dom/interfaces/settings/nsISettingsService.idl
dom/src/geolocation/nsGeolocation.cpp
dom/system/gonk/AutoMounterSetting.cpp
dom/system/gonk/GonkGPSGeolocationProvider.cpp
dom/system/gonk/TimeZoneSettingObserver.cpp
xpcom/tests/TestSettingsAPI.cpp
--- a/dom/bluetooth/BluetoothService.cpp
+++ b/dom/bluetooth/BluetoothService.cpp
@@ -190,17 +190,17 @@ private:
   bool mEnabled;
 };
 
 class BluetoothService::StartupTask : public nsISettingsServiceCallback
 {
 public:
   NS_DECL_ISUPPORTS
 
-  NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult)
+  NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult, JSContext* aCx)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     if (!aResult.isBoolean()) {
       NS_WARNING("Setting for '" BLUETOOTH_ENABLED_SETTING "' is not a boolean!");
       return NS_OK;
     }
 
@@ -208,17 +208,17 @@ public:
     // has completed (though extremely unlikely).
     if (gBluetoothService) {
       return gBluetoothService->HandleStartupSettingsCheck(aResult.toBoolean());
     }
 
     return NS_OK;
   }
 
-  NS_IMETHOD HandleError(const nsAString& aName)
+  NS_IMETHOD HandleError(const nsAString& aName, JSContext* aCx)
   {
     NS_WARNING("Unable to get value for '" BLUETOOTH_ENABLED_SETTING "'");
     return NS_OK;
   }
 };
 
 NS_IMPL_ISUPPORTS1(BluetoothService::StartupTask, nsISettingsServiceCallback);
 
--- a/dom/interfaces/settings/nsISettingsService.idl
+++ b/dom/interfaces/settings/nsISettingsService.idl
@@ -1,18 +1,20 @@
 /* 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 "domstubs.idl"
 
-[scriptable, uuid(aad47850-2e87-11e2-81c1-0800200c9a66)]
+[scriptable, uuid(83d67430-8516-11e1-b0c4-0800200c9a66)]
 interface nsISettingsServiceCallback : nsISupports
 {
+  [implicit_jscontext]
   void handle(in DOMString aName, in jsval aResult);
+  [implicit_jscontext]
   void handleError(in DOMString aErrorMessage);
 };
 
 [scriptable, uuid(d7a395a0-e292-11e1-834e-1761d57f5f99)]
 interface nsISettingsServiceLock : nsISupports
 {
   void set(in string aName,
            in jsval aValue,
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -84,31 +84,31 @@ public:
   GeolocationSettingsCallback() {
     MOZ_COUNT_CTOR(GeolocationSettingsCallback);
   }
 
   virtual ~GeolocationSettingsCallback() {
     MOZ_COUNT_DTOR(GeolocationSettingsCallback);
   }
 
-  NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult)
+  NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult, JSContext* aCx)
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     // The geolocation is enabled by default:
     bool value = true;
     if (aResult.isBoolean()) {
       value = aResult.toBoolean();
     }
 
     MozSettingValue(value);
     return NS_OK;
   }
 
-  NS_IMETHOD HandleError(const nsAString& aName)
+  NS_IMETHOD HandleError(const nsAString& aName, JSContext* aCx)
   {
     NS_WARNING("Unable to get value for '" GEO_SETINGS_ENABLED "'");
 
     // Default it's enabled:
     MozSettingValue(true);
     return NS_OK;
   }
 
--- a/dom/system/gonk/AutoMounterSetting.cpp
+++ b/dom/system/gonk/AutoMounterSetting.cpp
@@ -30,25 +30,25 @@ namespace system {
 
 class SettingsServiceCallback MOZ_FINAL : public nsISettingsServiceCallback
 {
 public:
   NS_DECL_ISUPPORTS
 
   SettingsServiceCallback() {}
 
-  NS_IMETHOD Handle(const nsAString &aName, const JS::Value &aResult) {
+  NS_IMETHOD Handle(const nsAString &aName, const JS::Value &aResult, JSContext *aContext) {
     if (JSVAL_IS_INT(aResult)) {
       int32_t mode = JSVAL_TO_INT(aResult);
       SetAutoMounterMode(mode);
     }
     return NS_OK;
   }
 
-  NS_IMETHOD HandleError(const nsAString &aName) {
+  NS_IMETHOD HandleError(const nsAString &aName, JSContext *aContext) {
     ERR("SettingsCallback::HandleError: %s\n", NS_LossyConvertUTF16toASCII(aName).get());
     return NS_OK;
   }
 };
 
 NS_IMPL_THREADSAFE_ISUPPORTS1(SettingsServiceCallback, nsISettingsServiceCallback)
 
 AutoMounterSetting::AutoMounterSetting()
--- a/dom/system/gonk/GonkGPSGeolocationProvider.cpp
+++ b/dom/system/gonk/GonkGPSGeolocationProvider.cpp
@@ -23,17 +23,16 @@
 #include "nsGeoPosition.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsINetworkManager.h"
 #include "nsIRadioInterfaceLayer.h"
 #include "nsIDOMMobileConnection.h"
 #include "nsJSUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
-#include "nsContentUtils.h"
 
 #ifdef AGPS_TYPE_INVALID
 #define AGPS_HAVE_DUAL_APN
 #endif
 
 #define DEBUG_GPS 0
 
 using namespace mozilla;
@@ -655,32 +654,30 @@ GonkGPSGeolocationProvider::ReceiveDataC
 {
   return NS_OK;
 }
 
 /** nsISettingsServiceCallback **/
 
 NS_IMETHODIMP
 GonkGPSGeolocationProvider::Handle(const nsAString& aName,
-                                   const JS::Value& aResult)
+                                   const JS::Value& aResult,
+                                   JSContext* cx)
 {
   if (aName.EqualsLiteral("ril.supl.apn")) {
-    JSContext *cx = nsContentUtils::GetSafeJSContext();
-    NS_ENSURE_TRUE(cx, NS_OK);
-    JSAutoRequest ar(cx);
-    JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(aResult));
     // When we get the APN, we attempt to call data_call_open of AGPS.
     if (aResult.isString()) {
       nsDependentJSString apn;
       apn.init(cx, aResult.toString());
       if (!apn.IsEmpty()) {
         SetAGpsDataConn(apn);
       }
     }
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
-GonkGPSGeolocationProvider::HandleError(const nsAString& aErrorMessage)
+GonkGPSGeolocationProvider::HandleError(const nsAString& aErrorMessage,
+                                        JSContext* cx)
 {
   return NS_OK;
 }
--- a/dom/system/gonk/TimeZoneSettingObserver.cpp
+++ b/dom/system/gonk/TimeZoneSettingObserver.cpp
@@ -15,17 +15,16 @@
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 #include "nsISettingsService.h"
 #include "nsJSUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsString.h"
 #include "TimeZoneSettingObserver.h"
 #include "xpcpublic.h"
-#include "nsContentUtils.h"
 
 #undef LOG
 #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Time Zone Setting" , ## args)
 #define ERR(args...)  __android_log_print(ANDROID_LOG_ERROR, "Time Zone Setting" , ## args)
 
 #define TIME_TIMEZONE       "time.timezone"
 #define MOZSETTINGS_CHANGED "mozsettings-changed"
 
@@ -46,55 +45,49 @@ public:
 
 class TimeZoneSettingCb MOZ_FINAL : public nsISettingsServiceCallback
 {
 public:
   NS_DECL_ISUPPORTS
 
   TimeZoneSettingCb() {}
 
-  NS_IMETHOD Handle(const nsAString &aName, const JS::Value &aResult) {
-
-    JSContext *cx = nsContentUtils::GetSafeJSContext();
-    NS_ENSURE_TRUE(cx, NS_OK);
-    JSAutoRequest ar(cx);
-    JSAutoCompartment ac(cx, JSVAL_TO_OBJECT(aResult));
-
+  NS_IMETHOD Handle(const nsAString &aName, const JS::Value &aResult, JSContext *aContext) {
     // If we don't have time.timezone value in the settings, we need
     // to initialize the settings based on the current system timezone
     // to make settings consistent with system. This usually happens
     // at the very first boot. After that, settings must have a value.
     if (aResult.isNull()) {
       // Get the current system timezone and convert it to a JS string.
       nsCString curTimezone = hal::GetTimezone();
       NS_ConvertUTF8toUTF16 utf16Str(curTimezone);
-      JSString *jsStr = JS_NewUCStringCopyN(cx, utf16Str.get(), utf16Str.Length());
+      JSString *jsStr = JS_NewUCStringCopyN(aContext, utf16Str.get(), utf16Str.Length());
 
       // Set the settings based on the current system timezone.
       nsCOMPtr<nsISettingsServiceLock> lock;
       nsCOMPtr<nsISettingsService> settingsService =
         do_GetService("@mozilla.org/settingsService;1");
       if (!settingsService) {
         ERR("Failed to get settingsLock service!");
         return NS_OK;
       }
       settingsService->CreateLock(getter_AddRefs(lock));
       lock->Set(TIME_TIMEZONE, STRING_TO_JSVAL(jsStr), nullptr, nullptr);
       return NS_OK;
     }
 
     // Set the system timezone based on the current settings.
     if (aResult.isString()) {
-      return TimeZoneSettingObserver::SetTimeZone(aResult, cx);
+      return TimeZoneSettingObserver::SetTimeZone(aResult, aContext);
     }
 
     return NS_OK;
   }
 
-  NS_IMETHOD HandleError(const nsAString &aName) {
+  NS_IMETHOD HandleError(const nsAString &aName, JSContext *aContext) {
     ERR("TimeZoneSettingCb::HandleError: %s\n", NS_LossyConvertUTF16toASCII(aName).get());
     return NS_OK;
   }
 };
 
 NS_IMPL_ISUPPORTS1(TimeZoneSettingCb, nsISettingsServiceCallback)
 
 TimeZoneSettingObserver::TimeZoneSettingObserver()
--- a/xpcom/tests/TestSettingsAPI.cpp
+++ b/xpcom/tests/TestSettingsAPI.cpp
@@ -53,17 +53,17 @@ typedef nsresult(*TestFuncPtr)();
 
 class SettingsServiceCallback MOZ_FINAL : public nsISettingsServiceCallback
 {
 public:
   NS_DECL_ISUPPORTS
 
   SettingsServiceCallback() { }
 
-  NS_IMETHOD Handle(const nsAString &name, const JS::Value &result) {
+  NS_IMETHOD Handle(const nsAString &name, const JS::Value &result, JSContext *cx) {
     if (callbackCount == 9) {
       CHECK(JSVAL_IS_BOOLEAN(result));
       CHECK(JSVAL_TO_BOOLEAN(result) == true);
       passed("boolean");
     } else if (callbackCount == 7) {
       CHECK(JSVAL_IS_BOOLEAN(result));
       CHECK(JSVAL_TO_BOOLEAN(result) == false);
       passed("Lock order");
@@ -82,17 +82,17 @@ public:
     } else if (callbackCount == 1) {
       CHECK(JSVAL_IS_NULL(result));
       passed("null");
     }
     callbackCount--;
     return NS_OK;
   };
 
-  NS_IMETHOD HandleError(const nsAString &name) {
+  NS_IMETHOD HandleError(const nsAString &name, JSContext *cx) {
     fprintf(stderr, "HANDLE Error! %s\n", NS_LossyConvertUTF16toASCII(name).get());
     errors++;
     return NS_OK;
   };
 };
 
 NS_IMPL_THREADSAFE_ISUPPORTS1(SettingsServiceCallback, nsISettingsServiceCallback)