mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1107681 - fix up the dom uses of WrapptedJSToDictionary to use the cx-less interface. r=bholley
This commit is contained in:
parent
d0a4b621f0
commit
83a6796724
@ -15,6 +15,7 @@
|
||||
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsISupportsPrimitives.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "nsHashPropertyBag.h"
|
||||
@ -828,11 +829,8 @@ AudioChannelService::Observe(nsISupports* aSubject, const char* aTopic, const ch
|
||||
// To process the volume control on each audio channel according to
|
||||
// change of settings
|
||||
else if (!strcmp(aTopic, "mozsettings-changed")) {
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCxForThread());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return NS_OK;
|
||||
}
|
||||
if (!StringBeginsWith(setting.mKey, NS_LITERAL_STRING("audio.volume."))) {
|
||||
|
@ -1576,6 +1576,8 @@ public:
|
||||
static JSContext *GetSafeJSContext();
|
||||
static JSContext *GetCurrentJSContextForThread();
|
||||
static JSContext *GetDefaultJSContextForThread();
|
||||
inline static JSContext *RootingCx() { return GetSafeJSContext(); }
|
||||
inline static JSContext *RootingCxForThread() { return GetDefaultJSContextForThread(); }
|
||||
|
||||
/**
|
||||
* Case insensitive comparison between two strings. However it only ignores
|
||||
|
@ -545,11 +545,8 @@ BluetoothService::HandleSettingsChanged(nsISupports* aSubject)
|
||||
// The string that we're interested in will be a JSON string that looks like:
|
||||
// {"key":"bluetooth.enabled","value":true}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCx());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return NS_OK;
|
||||
}
|
||||
if (setting.mKey.EqualsASCII(BLUETOOTH_DEBUGGING_SETTING)) {
|
||||
|
@ -616,11 +616,8 @@ BluetoothHfpManager::HandleVolumeChanged(nsISupports* aSubject)
|
||||
// The string that we're interested in will be a JSON string that looks like:
|
||||
// {"key":"volumeup", "value":10}
|
||||
// {"key":"volumedown", "value":2}
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<dom::SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<dom::SettingChangeNotification> setting(nsContentUtils::RootingCx());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return;
|
||||
}
|
||||
if (!setting.mKey.EqualsASCII(AUDIO_VOLUME_BT_SCO_ID)) {
|
||||
@ -683,9 +680,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
||||
HFP_NETWORK_STATE_NOT_AVAILABLE;
|
||||
|
||||
// Signal
|
||||
JSContext* cx = nsContentUtils::GetSafeJSContext();
|
||||
NS_ENSURE_TRUE_VOID(cx);
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
|
||||
voiceInfo->GetRelSignalStrength(&value);
|
||||
NS_ENSURE_TRUE_VOID(value.isNumber());
|
||||
mSignal = (int)ceil(value.toNumber() / 20.0);
|
||||
|
@ -565,11 +565,8 @@ BluetoothHfpManager::HandleVolumeChanged(nsISupports* aSubject)
|
||||
// {"key":"volumeup", "value":10}
|
||||
// {"key":"volumedown", "value":2}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCx());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return;
|
||||
}
|
||||
if (!setting.mKey.EqualsASCII(AUDIO_VOLUME_BT_SCO_ID)) {
|
||||
@ -626,9 +623,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
||||
}
|
||||
UpdateCIND(CINDType::SERVICE, service);
|
||||
|
||||
JSContext* cx = nsContentUtils::GetSafeJSContext();
|
||||
NS_ENSURE_TRUE_VOID(cx);
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
|
||||
voiceInfo->GetRelSignalStrength(&value);
|
||||
NS_ENSURE_TRUE_VOID(value.isNumber());
|
||||
uint8_t signal = ceil(value.toNumber() / 20.0);
|
||||
|
@ -499,11 +499,8 @@ BluetoothService::HandleSettingsChanged(nsISupports* aSubject)
|
||||
// The string that we're interested in will be a JSON string that looks like:
|
||||
// {"key":"bluetooth.enabled","value":true}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCx());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return NS_OK;
|
||||
}
|
||||
if (!setting.mKey.EqualsASCII(BLUETOOTH_DEBUGGING_SETTING)) {
|
||||
|
@ -610,11 +610,8 @@ BluetoothHfpManager::HandleVolumeChanged(nsISupports* aSubject)
|
||||
// {"key":"volumeup", "value":10}
|
||||
// {"key":"volumedown", "value":2}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<dom::SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<dom::SettingChangeNotification> setting(nsContentUtils::RootingCx());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return;
|
||||
}
|
||||
if (!setting.mKey.EqualsASCII(AUDIO_VOLUME_BT_SCO_ID)) {
|
||||
@ -678,9 +675,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
||||
mService = service;
|
||||
|
||||
// Signal
|
||||
JSContext* cx = nsContentUtils::GetSafeJSContext();
|
||||
NS_ENSURE_TRUE_VOID(cx);
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
|
||||
voiceInfo->GetRelSignalStrength(&value);
|
||||
NS_ENSURE_TRUE_VOID(value.isNumber());
|
||||
mSignal = (int)ceil(value.toNumber() / 20.0);
|
||||
|
@ -567,11 +567,8 @@ BluetoothHfpManager::HandleVolumeChanged(nsISupports* aSubject)
|
||||
// {"key":"volumeup", "value":10}
|
||||
// {"key":"volumedown", "value":2}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<dom::SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<dom::SettingChangeNotification> setting(nsContentUtils::RootingCx());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return;
|
||||
}
|
||||
if (!setting.mKey.EqualsASCII(AUDIO_VOLUME_BT_SCO_ID)) {
|
||||
@ -628,9 +625,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId)
|
||||
}
|
||||
UpdateCIND(CINDType::SERVICE, service);
|
||||
|
||||
JSContext* cx = nsContentUtils::GetSafeJSContext();
|
||||
NS_ENSURE_TRUE_VOID(cx);
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
JS::Rooted<JS::Value> value(nsContentUtils::RootingCxForThread());
|
||||
voiceInfo->GetRelSignalStrength(&value);
|
||||
NS_ENSURE_TRUE_VOID(value.isNumber());
|
||||
uint8_t signal = ceil(value.toNumber() / 20.0);
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "nsIAudioManager.h"
|
||||
#include "AudioManager.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "mozilla/LazyIdleThread.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/FMRadioChild.h"
|
||||
@ -839,11 +840,8 @@ FMRadioService::Observe(nsISupports* aSubject,
|
||||
|
||||
// The string that we're interested in will be a JSON string looks like:
|
||||
// {"key":"airplaneMode.enabled","value":true}
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<dom::SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<dom::SettingChangeNotification> setting(nsContentUtils::RootingCx());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return NS_OK;
|
||||
}
|
||||
if (!setting.mKey.EqualsASCII(SETTING_KEY_AIRPLANEMODE_ENABLED)) {
|
||||
|
@ -841,11 +841,8 @@ nsGeolocationService::HandleMozsettingChanged(nsISupports* aSubject)
|
||||
// The string that we're interested in will be a JSON string that looks like:
|
||||
// {"key":"gelocation.enabled","value":true}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCxForThread());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return;
|
||||
}
|
||||
if (!setting.mKey.EqualsASCII(GEO_SETTINGS_ENABLED)) {
|
||||
|
@ -149,11 +149,8 @@ nsGeolocationSettings::HandleMozsettingsChanged(nsISupports* aSubject)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCx());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -380,11 +380,8 @@ AudioManager::Observe(nsISupports* aSubject,
|
||||
// To process the volume control on each audio channel according to
|
||||
// change of settings
|
||||
else if (!strcmp(aTopic, MOZ_SETTINGS_CHANGE_ID)) {
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<dom::SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<dom::SettingChangeNotification> setting(nsContentUtils::RootingCxForThread());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return NS_OK;
|
||||
}
|
||||
if (!setting.mKey.EqualsASCII("audio.volume.bt_sco")) {
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDebug.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsISettingsService.h"
|
||||
@ -124,8 +125,7 @@ AutoMounterSetting::AutoMounterSetting()
|
||||
nsCOMPtr<nsISettingsServiceLock> lock;
|
||||
settingsService->CreateLock(nullptr, getter_AddRefs(lock));
|
||||
nsCOMPtr<nsISettingsServiceCallback> callback = new SettingsServiceCallback();
|
||||
mozilla::AutoSafeJSContext cx;
|
||||
JS::Rooted<JS::Value> value(cx);
|
||||
JS::Rooted<JS::Value> value(nsContentUtils::RootingCx());
|
||||
value.setInt32(AUTOMOUNTER_DISABLE);
|
||||
lock->Set(UMS_MODE, value, callback, nullptr);
|
||||
value.setInt32(mStatus);
|
||||
@ -240,11 +240,8 @@ AutoMounterSetting::Observe(nsISupports* aSubject,
|
||||
// The string that we're interested in will be a JSON string that looks like:
|
||||
// {"key":"ums.autoMount","value":true}
|
||||
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCxForThread());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1024,11 +1024,8 @@ GonkGPSGeolocationProvider::Observe(nsISupports* aSubject,
|
||||
|
||||
if (!strcmp(aTopic, kMozSettingsChangedTopic)) {
|
||||
// Read changed setting value
|
||||
AutoJSAPI jsapi;
|
||||
jsapi.Init();
|
||||
JSContext* cx = jsapi.cx();
|
||||
RootedDictionary<SettingChangeNotification> setting(cx);
|
||||
if (!WrappedJSToDictionary(cx, aSubject, setting)) {
|
||||
RootedDictionary<SettingChangeNotification> setting(nsContentUtils::RootingCx());
|
||||
if (!WrappedJSToDictionary(aSubject, setting)) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user