Bug 1023969 - Part 6: Replace |AutoPushJSContext|s in bluetooth2 BluetoothAdapter::SetPropertyByValue. r=bholley

This commit is contained in:
Bob Owen 2014-06-21 18:42:28 +01:00
parent 79258189c7
commit 5daf8a17bc

View File

@ -5,7 +5,6 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "base/basictypes.h"
#include "nsCxPusher.h"
#include "nsDOMClassInfo.h"
#include "nsTArrayHelpers.h"
#include "DOMRequest.h"
@ -257,12 +256,13 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue)
mClass = value.get_uint32_t();
} else if (name.EqualsLiteral("UUIDs")) {
mUuids = value.get_ArrayOfnsString();
nsresult rv;
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
NS_ENSURE_SUCCESS_VOID(rv);
NS_ENSURE_TRUE_VOID(sc);
AutoPushJSContext cx(sc->GetNativeContext());
AutoJSAPI jsapi;
if (!jsapi.InitUsingWin(GetOwner())) {
BT_WARNING("Failed to initialise AutoJSAPI!");
return;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JSObject*> uuids(cx);
if (NS_FAILED(nsTArrayToJSArray(cx, mUuids, &uuids))) {
BT_WARNING("Cannot set JS UUIDs object!");
@ -273,12 +273,12 @@ BluetoothAdapter::SetPropertyByValue(const BluetoothNamedValue& aValue)
} else if (name.EqualsLiteral("Devices")) {
mDeviceAddresses = value.get_ArrayOfnsString();
nsresult rv;
nsIScriptContext* sc = GetContextForEventHandlers(&rv);
NS_ENSURE_SUCCESS_VOID(rv);
NS_ENSURE_TRUE_VOID(sc);
AutoPushJSContext cx(sc->GetNativeContext());
AutoJSAPI jsapi;
if (!jsapi.InitUsingWin(GetOwner())) {
BT_WARNING("Failed to initialise AutoJSAPI!");
return;
}
JSContext* cx = jsapi.cx();
JS::Rooted<JSObject*> deviceAddresses(cx);
if (NS_FAILED(nsTArrayToJSArray(cx, mDeviceAddresses, &deviceAddresses))) {
BT_WARNING("Cannot set JS Devices object!");