Bug 1036232 - Remove redundant code of entering compartment in BT manager and adapter. r=btian

This commit is contained in:
Jocelyn Liu 2014-07-25 03:24:00 +02:00
parent 1d79be8a88
commit eeed6bee33
2 changed files with 6 additions and 23 deletions

View File

@ -911,21 +911,11 @@ BluetoothAdapter::DispatchAttributeEvent(const nsTArray<nsString>& aTypes)
NS_ENSURE_TRUE_VOID(aTypes.Length());
AutoJSAPI jsapi;
if (!jsapi.Init(GetOwner())) {
BT_WARNING("Failed to initialise AutoJSAPI!");
return;
}
NS_ENSURE_TRUE_VOID(jsapi.Init(GetOwner()));
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> value(cx);
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(GetOwner());
NS_ENSURE_TRUE_VOID(global);
JS::Rooted<JSObject*> scope(cx, global->GetGlobalJSObject());
NS_ENSURE_TRUE_VOID(scope);
JSAutoCompartment ac(cx, scope);
if(!ToJSValue(cx, aTypes, &value)) {
if (!ToJSValue(cx, aTypes, &value)) {
JS_ClearPendingException(cx);
return;
}

View File

@ -246,17 +246,10 @@ BluetoothManager::DispatchAttributeEvent()
MOZ_ASSERT(NS_IsMainThread());
BT_API2_LOGR();
AutoJSContext cx;
JS::Rooted<JS::Value> value(cx, JS::NullValue());
nsCOMPtr<nsIGlobalObject> global =
do_QueryInterface(GetOwner());
NS_ENSURE_TRUE_VOID(global);
JS::Rooted<JSObject*> scope(cx, global->GetGlobalJSObject());
NS_ENSURE_TRUE_VOID(scope);
JSAutoCompartment ac(cx, scope);
AutoJSAPI jsapi;
NS_ENSURE_TRUE_VOID(jsapi.Init(GetOwner()));
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> value(cx);
nsTArray<nsString> types;
BT_APPEND_ENUM_STRING(types,