зеркало из https://github.com/mozilla/gecko-dev.git
Fix rooting API differences. will get review after the fact, taking care of bustage now.
This commit is contained in:
Родитель
6713f50b94
Коммит
514faf210c
|
@ -244,7 +244,7 @@ IDBCursorRequest::IDBCursorRequest()
|
|||
: mDirection(nsIIDBCursor::NEXT),
|
||||
mCachedValue(JSVAL_VOID),
|
||||
mHaveCachedValue(false),
|
||||
mJSRuntime(nsnull),
|
||||
mJSContext(nsnull),
|
||||
mContinueCalled(false),
|
||||
mDataIndex(0),
|
||||
mType(OBJECTSTORE)
|
||||
|
@ -256,8 +256,9 @@ IDBCursorRequest::~IDBCursorRequest()
|
|||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (mJSRuntime) {
|
||||
JS_RemoveRootRT(mJSRuntime, &mCachedValue);
|
||||
if (mJSContext) {
|
||||
JSAutoRequest ar(mJSContext);
|
||||
JS_RemoveValueRoot(mJSContext, &mCachedValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,14 +383,11 @@ IDBCursorRequest::GetValue(nsIVariant** aValue)
|
|||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
if (!mJSRuntime) {
|
||||
JSRuntime* rt = JS_GetRuntime(cx);
|
||||
|
||||
JSBool ok = JS_AddNamedRootRT(rt, &mCachedValue,
|
||||
"IDBCursorRequest::mCachedValue");
|
||||
if (!mJSContext) {
|
||||
JSBool ok = JS_AddValueRoot(cx, &mCachedValue);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
||||
|
||||
mJSRuntime = rt;
|
||||
mJSContext = cx;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIJSON> json(new nsJSON());
|
||||
|
|
|
@ -129,7 +129,7 @@ protected:
|
|||
nsCOMPtr<nsIVariant> mCachedKey;
|
||||
jsval mCachedValue;
|
||||
bool mHaveCachedValue;
|
||||
JSRuntime* mJSRuntime;
|
||||
JSContext* mJSContext;
|
||||
|
||||
bool mContinueCalled;
|
||||
PRUint32 mDataIndex;
|
||||
|
|
|
@ -399,7 +399,7 @@ GetSuccessEvent::GetResult(nsIVariant** /* aResult */)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!mJSRuntime) {
|
||||
if (!mJSContext) {
|
||||
nsString jsonValue = mValue;
|
||||
mValue.Truncate();
|
||||
|
||||
|
@ -409,13 +409,10 @@ GetSuccessEvent::GetResult(nsIVariant** /* aResult */)
|
|||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JSRuntime* rt = JS_GetRuntime(cx);
|
||||
|
||||
JSBool ok = JS_AddNamedRootRT(rt, &mCachedValue,
|
||||
"GetSuccessEvent::mCachedValue");
|
||||
JSBool ok = JS_AddValueRoot(cx, &mCachedValue);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
||||
|
||||
mJSRuntime = rt;
|
||||
mJSContext = cx;
|
||||
|
||||
nsCOMPtr<nsIJSON> json(new nsJSON());
|
||||
rv = json->DecodeToJSVal(jsonValue, cx, &mCachedValue);
|
||||
|
@ -451,20 +448,17 @@ GetAllSuccessEvent::GetResult(nsIVariant** /* aResult */)
|
|||
rv = cc->GetRetValPtr(&retval);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!mJSRuntime) {
|
||||
if (!mJSContext) {
|
||||
JSContext* cx;
|
||||
rv = cc->GetJSContext(&cx);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JSRuntime* rt = JS_GetRuntime(cx);
|
||||
|
||||
JSBool ok = JS_AddNamedRootRT(rt, &mCachedValue,
|
||||
"GetSuccessEvent::mCachedValue");
|
||||
JSBool ok = JS_AddValueRoot(cx, &mCachedValue);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
||||
|
||||
mJSRuntime = rt;
|
||||
mJSContext = cx;
|
||||
|
||||
// Swap into a stack array so that we don't hang on to the strings if
|
||||
// something fails.
|
||||
|
@ -538,21 +532,16 @@ GetAllKeySuccessEvent::GetResult(nsIVariant** /* aResult */)
|
|||
rv = cc->GetRetValPtr(&retval);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!mJSRuntime) {
|
||||
if (!mJSContext) {
|
||||
JSContext* cx;
|
||||
rv = cc->GetJSContext(&cx);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
JSRuntime* rt = JS_GetRuntime(cx);
|
||||
|
||||
JSBool ok = JS_AddNamedRootRT(rt, &mCachedValue,
|
||||
"GetSuccessEvent::mCachedValue");
|
||||
JSBool ok = JS_AddValueRoot(cx, &mCachedValue);
|
||||
NS_ENSURE_TRUE(ok, NS_ERROR_FAILURE);
|
||||
|
||||
mJSRuntime = rt;
|
||||
|
||||
// Swap into a stack array so that we don't hang on to the strings if
|
||||
// something fails.
|
||||
nsTArray<Key> keys;
|
||||
|
|
|
@ -145,13 +145,14 @@ public:
|
|||
GetSuccessEvent(const nsAString& aValue)
|
||||
: mValue(aValue),
|
||||
mCachedValue(JSVAL_VOID),
|
||||
mJSRuntime(nsnull)
|
||||
mJSContext(nsnull)
|
||||
{ }
|
||||
|
||||
~GetSuccessEvent()
|
||||
{
|
||||
if (mJSRuntime) {
|
||||
JS_RemoveRootRT(mJSRuntime, &mCachedValue);
|
||||
if (mJSContext) {
|
||||
JSAutoRequest ar(mJSContext);
|
||||
JS_RemoveValueRoot(mJSContext, &mCachedValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -165,7 +166,7 @@ private:
|
|||
|
||||
protected:
|
||||
jsval mCachedValue;
|
||||
JSRuntime* mJSRuntime;
|
||||
JSContext* mJSContext;
|
||||
};
|
||||
|
||||
class GetAllSuccessEvent : public GetSuccessEvent
|
||||
|
|
Загрузка…
Ссылка в новой задаче