Bug 1023969 - Part 1: Replace AutoPushJSContext in BluetoothAdapter GetDevicesTask::ParseSuccessfulReply. r=bholley

This commit is contained in:
Bob Owen 2014-06-19 20:09:03 +01:00
parent 416668b7a1
commit a39259183d

View File

@ -17,6 +17,7 @@
#include "mozilla/dom/BluetoothDiscoveryStateChangedEvent.h"
#include "mozilla/dom/BluetoothStatusChangedEvent.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/LazyIdleThread.h"
#include "BluetoothAdapter.h"
@ -95,18 +96,15 @@ public:
devices.AppendElement(d);
}
nsresult rv;
nsIScriptContext* sc = mAdapterPtr->GetContextForEventHandlers(&rv);
if (!sc) {
BT_WARNING("Cannot create script context!");
SetError(NS_LITERAL_STRING("BluetoothScriptContextError"));
AutoJSAPI jsapi;
if (!jsapi.InitUsingWin(mAdapterPtr->GetOwner())) {
BT_WARNING("Failed to initialise AutoJSAPI!");
SetError(NS_LITERAL_STRING("BluetoothAutoJSAPIInitError"));
return false;
}
AutoPushJSContext cx(sc->GetNativeContext());
JSContext* cx = jsapi.cx();
JS::Rooted<JSObject*> JsDevices(cx);
rv = nsTArrayToJSArray(cx, devices, &JsDevices);
if (!JsDevices) {
if (NS_FAILED(nsTArrayToJSArray(cx, devices, &JsDevices))) {
BT_WARNING("Cannot create JS array!");
SetError(NS_LITERAL_STRING("BluetoothError"));
return false;