Bug 1257422 part 1. Add a way to do IDBObjectStore::OpenCursor without a JSContext if we are not passing a keyrange. r=khuey

This commit is contained in:
Boris Zbarsky 2016-03-17 23:23:55 -04:00
parent 60d3ad7ce0
commit 547ab7b66c
5 changed files with 17 additions and 3 deletions

View File

@ -410,9 +410,7 @@ public:
return;
}
AutoSafeJSContext cx;
mRequest = store->OpenCursor(cx, JS::UndefinedHandleValue,
IDBCursorDirection::Prev, error);
mRequest = store->OpenCursor(IDBCursorDirection::Prev, error);
if (NS_WARN_IF(error.Failed())) {
return;
}

View File

@ -99,6 +99,8 @@ IDBKeyRange::FromJSVal(JSContext* aCx,
JS::Handle<JS::Value> aVal,
IDBKeyRange** aKeyRange)
{
MOZ_ASSERT_IF(!aCx, aVal.isUndefined());
RefPtr<IDBKeyRange> keyRange;
if (aVal.isNullOrUndefined()) {

View File

@ -57,6 +57,7 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBKeyRange)
// aCx is allowed to be null, but only if aVal.isUndefined().
static nsresult
FromJSVal(JSContext* aCx,
JS::Handle<JS::Value> aVal,

View File

@ -2089,6 +2089,7 @@ IDBObjectStore::OpenCursorInternal(bool aKeysOnly,
ErrorResult& aRv)
{
AssertIsOnOwningThread();
MOZ_ASSERT_IF(!aCx, aRange.isUndefined());
if (mDeletedSpec) {
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);

View File

@ -261,6 +261,16 @@ public:
aRv);
}
already_AddRefed<IDBRequest>
OpenCursor(IDBCursorDirection aDirection,
ErrorResult& aRv)
{
AssertIsOnOwningThread();
return OpenCursorInternal(/* aKeysOnly */ false, nullptr,
JS::UndefinedHandleValue, aDirection, aRv);
}
already_AddRefed<IDBRequest>
OpenKeyCursor(JSContext* aCx,
JS::Handle<JS::Value> aRange,
@ -337,6 +347,8 @@ private:
const IDBIndexParameters& aOptionalParameters,
ErrorResult& aRv);
// aCx is allowed to be null but only if aRange.isUndefined(). In that case,
// we don't actually use aCx for anything, so it's OK.
already_AddRefed<IDBRequest>
OpenCursorInternal(bool aKeysOnly,
JSContext* aCx,