Bug 1023969 - Part 3: Replace AutoPushJSContext in BluetoothManager GetAdapterTask::ParseSuccessfulReply. r=bholley

This commit is contained in:
Bob Owen 2014-06-19 20:17:59 +01:00
Родитель 872cb50d73
Коммит 480df31e2f
1 изменённых файлов: 7 добавлений и 12 удалений

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

@ -18,6 +18,7 @@
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "mozilla/dom/bluetooth/BluetoothTypes.h" #include "mozilla/dom/bluetooth/BluetoothTypes.h"
#include "mozilla/dom/BluetoothManagerBinding.h" #include "mozilla/dom/BluetoothManagerBinding.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/Services.h" #include "mozilla/Services.h"
using namespace mozilla; using namespace mozilla;
@ -67,20 +68,14 @@ public:
nsRefPtr<BluetoothAdapter> adapter = nsRefPtr<BluetoothAdapter> adapter =
BluetoothAdapter::Create(mManagerPtr->GetOwner(), values); BluetoothAdapter::Create(mManagerPtr->GetOwner(), values);
nsresult rv; dom::AutoJSAPI jsapi;
nsIScriptContext* sc = mManagerPtr->GetContextForEventHandlers(&rv); if (!jsapi.InitUsingWin(mManagerPtr->GetOwner())) {
if (!sc) { BT_WARNING("Failed to initialise AutoJSAPI!");
BT_WARNING("Cannot create script context!"); SetError(NS_LITERAL_STRING("BluetoothAutoJSAPIInitError"));
SetError(NS_LITERAL_STRING("BluetoothScriptContextError"));
return false; return false;
} }
JSContext* cx = jsapi.cx();
AutoPushJSContext cx(sc->GetNativeContext()); if (NS_FAILED(nsContentUtils::WrapNative(cx, adapter, aValue))) {
JS::Rooted<JSObject*> scope(cx, sc->GetWindowProxy());
JSAutoCompartment ac(cx, scope);
rv = nsContentUtils::WrapNative(cx, adapter, aValue);
if (NS_FAILED(rv)) {
BT_WARNING("Cannot create native object!"); BT_WARNING("Cannot create native object!");
SetError(NS_LITERAL_STRING("BluetoothNativeObjectError")); SetError(NS_LITERAL_STRING("BluetoothNativeObjectError"));
return false; return false;