Bug 811414 - nsISettingsServiceCallback shouldn't use [implicit_jscontext]. r=bholley

This commit is contained in:
Gregor Wagner 2012-11-14 13:00:51 -08:00
Родитель bdac5bc9bf
Коммит c88b6950ec
7 изменённых файлов: 27 добавлений и 19 удалений

Просмотреть файл

@ -195,7 +195,7 @@ class BluetoothService::StartupTask : public nsISettingsServiceCallback
public:
NS_DECL_ISUPPORTS
NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult, JSContext* aCx)
NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult)
{
MOZ_ASSERT(NS_IsMainThread());
@ -213,7 +213,7 @@ public:
return NS_OK;
}
NS_IMETHOD HandleError(const nsAString& aName, JSContext* aCx)
NS_IMETHOD HandleError(const nsAString& aName)
{
NS_WARNING("Unable to get value for '" BLUETOOTH_ENABLED_SETTING "'");
return NS_OK;

Просмотреть файл

@ -4,12 +4,10 @@
#include "domstubs.idl"
[scriptable, uuid(83d67430-8516-11e1-b0c4-0800200c9a66)]
[scriptable, uuid(aad47850-2e87-11e2-81c1-0800200c9a66)]
interface nsISettingsServiceCallback : nsISupports
{
[implicit_jscontext]
void handle(in DOMString aName, in jsval aResult);
[implicit_jscontext]
void handleError(in DOMString aErrorMessage);
};

Просмотреть файл

@ -89,7 +89,7 @@ public:
MOZ_COUNT_DTOR(GeolocationSettingsCallback);
}
NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult, JSContext* aCx)
NS_IMETHOD Handle(const nsAString& aName, const jsval& aResult)
{
MOZ_ASSERT(NS_IsMainThread());
@ -103,7 +103,7 @@ public:
return NS_OK;
}
NS_IMETHOD HandleError(const nsAString& aName, JSContext* aCx)
NS_IMETHOD HandleError(const nsAString& aName)
{
NS_WARNING("Unable to get value for '" GEO_SETINGS_ENABLED "'");

Просмотреть файл

@ -35,7 +35,7 @@ public:
SettingsServiceCallback() {}
NS_IMETHOD Handle(const nsAString &aName, const JS::Value &aResult, JSContext *aContext) {
NS_IMETHOD Handle(const nsAString &aName, const JS::Value &aResult) {
if (JSVAL_IS_INT(aResult)) {
int32_t mode = JSVAL_TO_INT(aResult);
SetAutoMounterMode(mode);
@ -43,7 +43,7 @@ public:
return NS_OK;
}
NS_IMETHOD HandleError(const nsAString &aName, JSContext *aContext) {
NS_IMETHOD HandleError(const nsAString &aName) {
ERR("SettingsCallback::HandleError: %s\n", NS_LossyConvertUTF16toASCII(aName).get());
return NS_OK;
}

Просмотреть файл

@ -28,6 +28,7 @@
#include "nsJSUtils.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#include "nsContentUtils.h"
#ifdef AGPS_TYPE_INVALID
#define AGPS_HAVE_DUAL_APN
@ -659,10 +660,13 @@ GonkGPSGeolocationProvider::ReceiveDataCallList(nsIRILDataCallInfo** aDataCalls,
NS_IMETHODIMP
GonkGPSGeolocationProvider::Handle(const nsAString& aName,
const JS::Value& aResult,
JSContext* cx)
const JS::Value& aResult)
{
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;
@ -676,8 +680,7 @@ GonkGPSGeolocationProvider::Handle(const nsAString& aName,
}
NS_IMETHODIMP
GonkGPSGeolocationProvider::HandleError(const nsAString& aErrorMessage,
JSContext* cx)
GonkGPSGeolocationProvider::HandleError(const nsAString& aErrorMessage)
{
return NS_OK;
}

Просмотреть файл

@ -20,6 +20,7 @@
#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)
@ -50,7 +51,13 @@ public:
TimeZoneSettingCb() {}
NS_IMETHOD Handle(const nsAString &aName, const JS::Value &aResult, JSContext *aContext) {
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));
// 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
@ -59,7 +66,7 @@ public:
// Get the current system timezone and convert it to a JS string.
nsCString curTimezone = hal::GetTimezone();
NS_ConvertUTF8toUTF16 utf16Str(curTimezone);
JSString *jsStr = JS_NewUCStringCopyN(aContext, utf16Str.get(), utf16Str.Length());
JSString *jsStr = JS_NewUCStringCopyN(cx, utf16Str.get(), utf16Str.Length());
// Set the settings based on the current system timezone.
nsCOMPtr<nsISettingsServiceLock> lock;
@ -76,13 +83,13 @@ public:
// Set the system timezone based on the current settings.
if (aResult.isString()) {
return TimeZoneSettingObserver::SetTimeZone(aResult, aContext);
return TimeZoneSettingObserver::SetTimeZone(aResult, cx);
}
return NS_OK;
}
NS_IMETHOD HandleError(const nsAString &aName, JSContext *aContext) {
NS_IMETHOD HandleError(const nsAString &aName) {
ERR("TimeZoneSettingCb::HandleError: %s\n", NS_LossyConvertUTF16toASCII(aName).get());
return NS_OK;
}

Просмотреть файл

@ -58,7 +58,7 @@ public:
SettingsServiceCallback() { }
NS_IMETHOD Handle(const nsAString &name, const JS::Value &result, JSContext *cx) {
NS_IMETHOD Handle(const nsAString &name, const JS::Value &result) {
if (callbackCount == 9) {
CHECK(JSVAL_IS_BOOLEAN(result));
CHECK(JSVAL_TO_BOOLEAN(result) == true);
@ -87,7 +87,7 @@ public:
return NS_OK;
};
NS_IMETHOD HandleError(const nsAString &name, JSContext *cx) {
NS_IMETHOD HandleError(const nsAString &name) {
fprintf(stderr, "HANDLE Error! %s\n", NS_LossyConvertUTF16toASCII(name).get());
errors++;
return NS_OK;