mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out 3 changesets (bug 920179, bug 920633, bug 920800) for Windows |make package| crashes on a CLOSED TREE.
Backed out changeset bb0041643a0f (bug 920800) Backed out changeset 24818d9b7470 (bug 920633) Backed out changeset d49b0f47b05a (bug 920179)
This commit is contained in:
parent
12170df49b
commit
85b2edc046
@ -36,7 +36,8 @@ using mozilla::dom::OwningIDBObjectStoreOrIDBIndex;
|
||||
using mozilla::ErrorResult;
|
||||
|
||||
static_assert(sizeof(size_t) >= sizeof(IDBCursor::Direction),
|
||||
"Relying on conversion between size_t and IDBCursor::Direction");
|
||||
"Relying on conversion between size_t and "
|
||||
"IDBCursor::Direction");
|
||||
|
||||
namespace {
|
||||
|
||||
@ -61,9 +62,6 @@ public:
|
||||
UnpackResponseFromParentProcess(const ResponseValue& aResponseValue) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~CursorHelper()
|
||||
{ }
|
||||
|
||||
nsRefPtr<IDBCursor> mCursor;
|
||||
|
||||
private:
|
||||
@ -81,17 +79,19 @@ public:
|
||||
int32_t aCount)
|
||||
: CursorHelper(aCursor), mCount(aCount)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aCursor);
|
||||
MOZ_ASSERT(aCount > 0);
|
||||
NS_ASSERTION(aCount > 0, "Must have a count!");
|
||||
}
|
||||
|
||||
~ContinueHelper()
|
||||
{
|
||||
IDBObjectStore::ClearCloneReadInfo(mCloneReadInfo);
|
||||
}
|
||||
|
||||
virtual nsresult DoDatabaseWork(mozIStorageConnection* aConnection)
|
||||
MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult GetSuccessResult(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aVal)
|
||||
MOZ_OVERRIDE;
|
||||
JS::MutableHandle<JS::Value> aVal) MOZ_OVERRIDE;
|
||||
|
||||
virtual void ReleaseMainThreadObjects() MOZ_OVERRIDE;
|
||||
|
||||
@ -106,11 +106,6 @@ public:
|
||||
MOZ_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual ~ContinueHelper()
|
||||
{
|
||||
IDBObjectStore::ClearCloneReadInfo(mCloneReadInfo);
|
||||
}
|
||||
|
||||
virtual nsresult
|
||||
BindArgumentsToStatement(mozIStorageStatement* aStatement) = 0;
|
||||
|
||||
@ -129,10 +124,10 @@ protected:
|
||||
|
||||
if (mKey.IsUnset()) {
|
||||
mCursor->mHaveValue = false;
|
||||
} else {
|
||||
MOZ_ASSERT(mCursor->mType == IDBCursor::OBJECTSTORE ||
|
||||
mCursor->mType == IDBCursor::OBJECTSTOREKEY ||
|
||||
!mObjectKey.IsUnset());
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(mCursor->mType == IDBCursor::OBJECTSTORE ||
|
||||
!mObjectKey.IsUnset(), "Bad key!");
|
||||
|
||||
// Set new values.
|
||||
mCursor->mKey = mKey;
|
||||
@ -158,31 +153,11 @@ public:
|
||||
: ContinueHelper(aCursor, aCount)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
virtual ~ContinueObjectStoreHelper()
|
||||
{ }
|
||||
|
||||
private:
|
||||
nsresult BindArgumentsToStatement(mozIStorageStatement* aStatement);
|
||||
nsresult GatherResultsFromStatement(mozIStorageStatement* aStatement);
|
||||
};
|
||||
|
||||
class ContinueObjectStoreKeyHelper : public ContinueObjectStoreHelper
|
||||
{
|
||||
public:
|
||||
ContinueObjectStoreKeyHelper(IDBCursor* aCursor,
|
||||
uint32_t aCount)
|
||||
: ContinueObjectStoreHelper(aCursor, aCount)
|
||||
{ }
|
||||
|
||||
private:
|
||||
virtual ~ContinueObjectStoreKeyHelper()
|
||||
{ }
|
||||
|
||||
virtual nsresult
|
||||
GatherResultsFromStatement(mozIStorageStatement* aStatement) MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
class ContinueIndexHelper : public ContinueHelper
|
||||
{
|
||||
public:
|
||||
@ -191,10 +166,6 @@ public:
|
||||
: ContinueHelper(aCursor, aCount)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
virtual ~ContinueIndexHelper()
|
||||
{ }
|
||||
|
||||
private:
|
||||
nsresult BindArgumentsToStatement(mozIStorageStatement* aStatement);
|
||||
nsresult GatherResultsFromStatement(mozIStorageStatement* aStatement);
|
||||
@ -209,9 +180,6 @@ public:
|
||||
{ }
|
||||
|
||||
private:
|
||||
virtual ~ContinueIndexObjectHelper()
|
||||
{ }
|
||||
|
||||
nsresult GatherResultsFromStatement(mozIStorageStatement* aStatement);
|
||||
};
|
||||
|
||||
@ -245,32 +213,6 @@ IDBCursor::Create(IDBRequest* aRequest,
|
||||
return cursor.forget();
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<IDBCursor>
|
||||
IDBCursor::Create(IDBRequest* aRequest,
|
||||
IDBTransaction* aTransaction,
|
||||
IDBObjectStore* aObjectStore,
|
||||
Direction aDirection,
|
||||
const Key& aRangeKey,
|
||||
const nsACString& aContinueQuery,
|
||||
const nsACString& aContinueToQuery,
|
||||
const Key& aKey)
|
||||
{
|
||||
MOZ_ASSERT(aObjectStore);
|
||||
MOZ_ASSERT(!aKey.IsUnset());
|
||||
|
||||
nsRefPtr<IDBCursor> cursor =
|
||||
IDBCursor::CreateCommon(aRequest, aTransaction, aObjectStore, aDirection,
|
||||
aRangeKey, aContinueQuery, aContinueToQuery);
|
||||
NS_ASSERTION(cursor, "This shouldn't fail!");
|
||||
|
||||
cursor->mObjectStore = aObjectStore;
|
||||
cursor->mType = OBJECTSTOREKEY;
|
||||
cursor->mKey = aKey;
|
||||
|
||||
return cursor.forget();
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<IDBCursor>
|
||||
IDBCursor::Create(IDBRequest* aRequest,
|
||||
@ -351,7 +293,7 @@ IDBCursor::ConvertDirection(mozilla::dom::IDBCursorDirection aDirection)
|
||||
return PREV_UNIQUE;
|
||||
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("Unknown direction!");
|
||||
MOZ_CRASH("Unknown direction!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,8 +396,8 @@ IDBCursor::DropJSObjects()
|
||||
void
|
||||
IDBCursor::ContinueInternal(const Key& aKey, int32_t aCount, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aCount > 0);
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(aCount > 0, "Must have a count!");
|
||||
|
||||
if (!mTransaction->IsOpen()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
||||
@ -469,7 +411,10 @@ IDBCursor::ContinueInternal(const Key& aKey, int32_t aCount, ErrorResult& aRv)
|
||||
|
||||
mContinueToKey = aKey;
|
||||
|
||||
MOZ_ASSERT(mRequest->ReadyState() == IDBRequestReadyState::Done);
|
||||
#ifdef DEBUG
|
||||
NS_ASSERTION(mRequest->ReadyState() == IDBRequestReadyState::Done,
|
||||
"Should be DONE!");
|
||||
#endif
|
||||
|
||||
mRequest->Reset();
|
||||
|
||||
@ -479,10 +424,6 @@ IDBCursor::ContinueInternal(const Key& aKey, int32_t aCount, ErrorResult& aRv)
|
||||
helper = new ContinueObjectStoreHelper(this, aCount);
|
||||
break;
|
||||
|
||||
case OBJECTSTOREKEY:
|
||||
helper = new ContinueObjectStoreKeyHelper(this, aCount);
|
||||
break;
|
||||
|
||||
case INDEXKEY:
|
||||
helper = new ContinueIndexHelper(this, aCount);
|
||||
break;
|
||||
@ -492,7 +433,7 @@ IDBCursor::ContinueInternal(const Key& aKey, int32_t aCount, ErrorResult& aRv)
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("Unknown cursor type!");
|
||||
NS_NOTREACHED("Unknown cursor type!");
|
||||
}
|
||||
|
||||
nsresult rv = helper->DispatchToTransactionPool();
|
||||
@ -548,26 +489,15 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBCursor)
|
||||
JSObject*
|
||||
IDBCursor::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
switch (mType) {
|
||||
case OBJECTSTORE:
|
||||
case INDEXOBJECT:
|
||||
return IDBCursorWithValueBinding::Wrap(aCx, aScope, this);
|
||||
|
||||
case OBJECTSTOREKEY:
|
||||
case INDEXKEY:
|
||||
return IDBCursorBinding::Wrap(aCx, aScope, this);
|
||||
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("Bad type!");
|
||||
}
|
||||
return mType != INDEXKEY
|
||||
? IDBCursorWithValueBinding::Wrap(aCx, aScope, this)
|
||||
: IDBCursorBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
mozilla::dom::IDBCursorDirection
|
||||
IDBCursor::GetDirection() const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
switch (mDirection) {
|
||||
case NEXT:
|
||||
@ -582,39 +512,33 @@ IDBCursor::GetDirection() const
|
||||
case PREV_UNIQUE:
|
||||
return mozilla::dom::IDBCursorDirection::Prevunique;
|
||||
|
||||
case DIRECTION_INVALID:
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("Bad direction!");
|
||||
MOZ_CRASH("Unknown direction!");
|
||||
return mozilla::dom::IDBCursorDirection::Next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
IDBCursor::GetSource(OwningIDBObjectStoreOrIDBIndex& aSource) const
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
switch (mType) {
|
||||
case OBJECTSTORE:
|
||||
case OBJECTSTOREKEY:
|
||||
MOZ_ASSERT(mObjectStore);
|
||||
aSource.SetAsIDBObjectStore() = mObjectStore;
|
||||
break;
|
||||
|
||||
case INDEXKEY:
|
||||
case INDEXOBJECT:
|
||||
MOZ_ASSERT(mIndex);
|
||||
aSource.SetAsIDBIndex() = mIndex;
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("Bad type!");
|
||||
if (mType == OBJECTSTORE) {
|
||||
aSource.SetAsIDBObjectStore() = mObjectStore;
|
||||
}
|
||||
else {
|
||||
aSource.SetAsIDBIndex() = mIndex;
|
||||
}
|
||||
}
|
||||
|
||||
JS::Value
|
||||
IDBCursor::GetKey(JSContext* aCx, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!mKey.IsUnset() || !mHaveValue);
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
NS_ASSERTION(!mKey.IsUnset() || !mHaveValue, "Bad key!");
|
||||
|
||||
if (!mHaveValue) {
|
||||
return JSVAL_VOID;
|
||||
@ -638,7 +562,7 @@ IDBCursor::GetKey(JSContext* aCx, ErrorResult& aRv)
|
||||
JS::Value
|
||||
IDBCursor::GetPrimaryKey(JSContext* aCx, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (!mHaveValue) {
|
||||
return JSVAL_VOID;
|
||||
@ -650,9 +574,12 @@ IDBCursor::GetPrimaryKey(JSContext* aCx, ErrorResult& aRv)
|
||||
mRooted = true;
|
||||
}
|
||||
|
||||
const Key& key =
|
||||
(mType == OBJECTSTORE || mType == OBJECTSTOREKEY) ? mKey : mObjectKey;
|
||||
MOZ_ASSERT(!key.IsUnset());
|
||||
JSAutoRequest ar(aCx);
|
||||
|
||||
NS_ASSERTION(mType == OBJECTSTORE ? !mKey.IsUnset() :
|
||||
!mObjectKey.IsUnset(), "Bad key!");
|
||||
|
||||
const Key& key = mType == OBJECTSTORE ? mKey : mObjectKey;
|
||||
|
||||
aRv = key.ToJSVal(aCx, mCachedPrimaryKey);
|
||||
ENSURE_SUCCESS(aRv, JSVAL_VOID);
|
||||
@ -666,8 +593,8 @@ IDBCursor::GetPrimaryKey(JSContext* aCx, ErrorResult& aRv)
|
||||
JS::Value
|
||||
IDBCursor::GetValue(JSContext* aCx, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mType == OBJECTSTORE || mType == INDEXOBJECT);
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(mType != INDEXKEY, "GetValue shouldn't exist on index keys");
|
||||
|
||||
if (!mHaveValue) {
|
||||
return JSVAL_VOID;
|
||||
@ -699,7 +626,7 @@ IDBCursor::Continue(JSContext* aCx,
|
||||
const Optional<JS::Handle<JS::Value> >& aKey,
|
||||
ErrorResult &aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
Key key;
|
||||
if (aKey.WasPassed()) {
|
||||
@ -726,7 +653,7 @@ IDBCursor::Continue(JSContext* aCx,
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("Unknown direction type!");
|
||||
NS_NOTREACHED("Unknown direction type!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -736,7 +663,7 @@ IDBCursor::Continue(JSContext* aCx,
|
||||
}
|
||||
|
||||
#ifdef IDB_PROFILER_USE_MARKS
|
||||
if (mType == OBJECTSTORE || mType == OBJECTSTOREKEY) {
|
||||
if (mType == OBJECTSTORE) {
|
||||
IDB_PROFILER_MARK("IndexedDB Request %llu: "
|
||||
"database(%s).transaction(%s).objectStore(%s).cursor(%s)."
|
||||
"continue(%s)",
|
||||
@ -768,7 +695,7 @@ already_AddRefed<IDBRequest>
|
||||
IDBCursor::Update(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (!mTransaction->IsOpen()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
||||
@ -780,17 +707,18 @@ IDBCursor::Update(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!mHaveValue || mType == OBJECTSTOREKEY || mType == INDEXKEY) {
|
||||
if (!mHaveValue || mType == INDEXKEY) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mObjectStore);
|
||||
MOZ_ASSERT(!mKey.IsUnset());
|
||||
MOZ_ASSERT(mType == OBJECTSTORE || mType == INDEXOBJECT);
|
||||
MOZ_ASSERT_IF(mType == INDEXOBJECT, !mObjectKey.IsUnset());
|
||||
NS_ASSERTION(mObjectStore, "This cannot be null!");
|
||||
NS_ASSERTION(!mKey.IsUnset() , "Bad key!");
|
||||
NS_ASSERTION(mType != INDEXOBJECT || !mObjectKey.IsUnset(), "Bad key!");
|
||||
|
||||
const Key& objectKey = (mType == OBJECTSTORE) ? mKey : mObjectKey;
|
||||
JSAutoRequest ar(aCx);
|
||||
|
||||
Key& objectKey = (mType == OBJECTSTORE) ? mKey : mObjectKey;
|
||||
|
||||
nsRefPtr<IDBRequest> request;
|
||||
if (mObjectStore->HasValidKeyPath()) {
|
||||
@ -868,7 +796,7 @@ IDBCursor::Update(JSContext* aCx, JS::Handle<JS::Value> aValue,
|
||||
already_AddRefed<IDBRequest>
|
||||
IDBCursor::Delete(JSContext* aCx, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (!mTransaction->IsOpen()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
||||
@ -880,23 +808,24 @@ IDBCursor::Delete(JSContext* aCx, ErrorResult& aRv)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!mHaveValue || mType == OBJECTSTOREKEY || mType == INDEXKEY) {
|
||||
if (!mHaveValue || mType == INDEXKEY) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mObjectStore);
|
||||
MOZ_ASSERT(mType == OBJECTSTORE || mType == INDEXOBJECT);
|
||||
MOZ_ASSERT(!mKey.IsUnset());
|
||||
NS_ASSERTION(mObjectStore, "This cannot be null!");
|
||||
NS_ASSERTION(!mKey.IsUnset() , "Bad key!");
|
||||
|
||||
const Key& objectKey = (mType == OBJECTSTORE) ? mKey : mObjectKey;
|
||||
Key& objectKey = (mType == OBJECTSTORE) ? mKey : mObjectKey;
|
||||
|
||||
JS::Rooted<JS::Value> key(aCx);
|
||||
aRv = objectKey.ToJSVal(aCx, &key);
|
||||
ENSURE_SUCCESS(aRv, nullptr);
|
||||
|
||||
nsRefPtr<IDBRequest> request = mObjectStore->Delete(aCx, key, aRv);
|
||||
ENSURE_SUCCESS(aRv, nullptr);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef IDB_PROFILER_USE_MARKS
|
||||
{
|
||||
@ -937,7 +866,7 @@ IDBCursor::Delete(JSContext* aCx, ErrorResult& aRv)
|
||||
void
|
||||
IDBCursor::Advance(uint32_t aCount, ErrorResult &aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (aCount < 1) {
|
||||
aRv.ThrowTypeError(MSG_INVALID_ADVANCE_COUNT);
|
||||
@ -950,7 +879,7 @@ IDBCursor::Advance(uint32_t aCount, ErrorResult &aRv)
|
||||
|
||||
#ifdef IDB_PROFILER_USE_MARKS
|
||||
{
|
||||
if (mType == OBJECTSTORE || mType == OBJECTSTOREKEY) {
|
||||
if (mType == OBJECTSTORE) {
|
||||
IDB_PROFILER_MARK("IndexedDB Request %llu: "
|
||||
"database(%s).transaction(%s).objectStore(%s)."
|
||||
"cursor(%s).advance(%ld)",
|
||||
@ -1206,9 +1135,6 @@ nsresult
|
||||
ContinueObjectStoreHelper::BindArgumentsToStatement(
|
||||
mozIStorageStatement* aStatement)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(aStatement);
|
||||
|
||||
// Bind object store id.
|
||||
nsresult rv = aStatement->BindInt64ByName(NS_LITERAL_CSTRING("id"),
|
||||
mCursor->mObjectStore->Id());
|
||||
@ -1240,29 +1166,12 @@ nsresult
|
||||
ContinueObjectStoreHelper::GatherResultsFromStatement(
|
||||
mozIStorageStatement* aStatement)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(aStatement);
|
||||
|
||||
// Figure out what kind of key we have next.
|
||||
nsresult rv = mKey.SetFromStatement(aStatement, 0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = IDBObjectStore::GetStructuredCloneReadInfoFromStatement(aStatement, 1, 2,
|
||||
mDatabase,
|
||||
mCloneReadInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
ContinueObjectStoreKeyHelper::GatherResultsFromStatement(
|
||||
mozIStorageStatement* aStatement)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(aStatement);
|
||||
|
||||
nsresult rv = mKey.SetFromStatement(aStatement, 0);
|
||||
mDatabase, mCloneReadInfo);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -55,7 +55,6 @@ public:
|
||||
enum Type
|
||||
{
|
||||
OBJECTSTORE = 0,
|
||||
OBJECTSTOREKEY,
|
||||
INDEXKEY,
|
||||
INDEXOBJECT
|
||||
};
|
||||
@ -84,18 +83,6 @@ public:
|
||||
const Key& aKey,
|
||||
StructuredCloneReadInfo& aCloneReadInfo);
|
||||
|
||||
// For OBJECTSTOREKEY cursors.
|
||||
static
|
||||
already_AddRefed<IDBCursor>
|
||||
Create(IDBRequest* aRequest,
|
||||
IDBTransaction* aTransaction,
|
||||
IDBObjectStore* aObjectStore,
|
||||
Direction aDirection,
|
||||
const Key& aRangeKey,
|
||||
const nsACString& aContinueQuery,
|
||||
const nsACString& aContinueToQuery,
|
||||
const Key& aKey);
|
||||
|
||||
// For INDEXKEY cursors.
|
||||
static
|
||||
already_AddRefed<IDBCursor>
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "nsIIDBKeyRange.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/ipc/Blob.h"
|
||||
@ -564,7 +563,6 @@ IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit,
|
||||
IDBTransaction* transaction = mObjectStore->Transaction();
|
||||
if (!transaction->IsOpen()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<IDBRequest> request = GenerateRequest(this);
|
||||
@ -1369,11 +1367,10 @@ GetHelper::UnpackResponseFromParentProcess(const ResponseValue& aResponseValue)
|
||||
nsresult
|
||||
GetAllKeysHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(IndexedDatabaseManager::IsMainProcess());
|
||||
NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
|
||||
|
||||
PROFILER_LABEL("IndexedDB",
|
||||
"GetAllKeysHelper::DoDatabaseWork [IDBIndex.cpp]");
|
||||
PROFILER_LABEL("IndexedDB", "GetAllKeysHelper::DoDatabaseWork");
|
||||
|
||||
nsCString tableName;
|
||||
if (mIndex->IsUnique()) {
|
||||
@ -1413,7 +1410,7 @@ GetAllKeysHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
mKeys.SetCapacity(std::min<uint32_t>(50, mLimit));
|
||||
mKeys.SetCapacity(50);
|
||||
|
||||
bool hasResult;
|
||||
while(NS_SUCCEEDED((rv = stmt->ExecuteStep(&hasResult))) && hasResult) {
|
||||
@ -1436,12 +1433,7 @@ nsresult
|
||||
GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
|
||||
JS::MutableHandle<JS::Value> aVal)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mKeys.Length() <= mLimit);
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("IndexedDB",
|
||||
"GetAllKeysHelper::GetSuccessResult "
|
||||
"[IDBIndex.cpp]");
|
||||
NS_ASSERTION(mKeys.Length() <= mLimit, "Too many results!");
|
||||
|
||||
nsTArray<Key> keys;
|
||||
mKeys.SwapElements(keys);
|
||||
@ -1483,12 +1475,11 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
|
||||
nsresult
|
||||
GetAllKeysHelper::PackArgumentsForParentProcess(IndexRequestParams& aParams)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!IndexedDatabaseManager::IsMainProcess());
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("IndexedDB",
|
||||
"GetAllKeysHelper::PackArgumentsForParentProcess "
|
||||
"[IDBIndex.cpp]");
|
||||
"GetAllKeysHelper::PackArgumentsForParentProcess");
|
||||
|
||||
GetAllKeysParams params;
|
||||
|
||||
@ -1510,12 +1501,11 @@ GetAllKeysHelper::PackArgumentsForParentProcess(IndexRequestParams& aParams)
|
||||
AsyncConnectionHelper::ChildProcessSendResult
|
||||
GetAllKeysHelper::SendResponseToChildProcess(nsresult aResultCode)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(IndexedDatabaseManager::IsMainProcess());
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(IndexedDatabaseManager::IsMainProcess(), "Wrong process!");
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("IndexedDB",
|
||||
"GetAllKeysHelper::SendResponseToChildProcess "
|
||||
"[IDBIndex.cpp]");
|
||||
"GetAllKeysHelper::SendResponseToChildProcess");
|
||||
|
||||
IndexedDBRequestParentBase* actor = mRequest->GetActorParent();
|
||||
NS_ASSERTION(actor, "How did we get this far without an actor?");
|
||||
@ -1541,9 +1531,8 @@ nsresult
|
||||
GetAllKeysHelper::UnpackResponseFromParentProcess(
|
||||
const ResponseValue& aResponseValue)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!IndexedDatabaseManager::IsMainProcess());
|
||||
MOZ_ASSERT(aResponseValue.type() == ResponseValue::TGetAllKeysResponse);
|
||||
NS_ASSERTION(aResponseValue.type() == ResponseValue::TGetAllKeysResponse,
|
||||
"Bad response type!");
|
||||
|
||||
mKeys.AppendElements(aResponseValue.get_GetAllKeysResponse().keys());
|
||||
return NS_OK;
|
||||
@ -1991,7 +1980,7 @@ OpenKeyCursorHelper::PackArgumentsForParentProcess(IndexRequestParams& aParams)
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("IndexedDB",
|
||||
"OpenKeyCursorHelper::"
|
||||
"PackArgumentsForParentProcess [IDBIndex.cpp]");
|
||||
"PackArgumentsForParentProcess");
|
||||
|
||||
OpenKeyCursorParams params;
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "mozilla/dom/ipc/nsIRemoteBlob.h"
|
||||
#include "nsIOutputStream.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include "jsfriendapi.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
@ -345,57 +344,6 @@ private:
|
||||
SerializedStructuredCloneReadInfo mSerializedCloneReadInfo;
|
||||
};
|
||||
|
||||
class OpenKeyCursorHelper MOZ_FINAL : public ObjectStoreHelper
|
||||
{
|
||||
public:
|
||||
OpenKeyCursorHelper(IDBTransaction* aTransaction,
|
||||
IDBRequest* aRequest,
|
||||
IDBObjectStore* aObjectStore,
|
||||
IDBKeyRange* aKeyRange,
|
||||
IDBCursor::Direction aDirection)
|
||||
: ObjectStoreHelper(aTransaction, aRequest, aObjectStore),
|
||||
mKeyRange(aKeyRange), mDirection(aDirection)
|
||||
{ }
|
||||
|
||||
virtual nsresult
|
||||
DoDatabaseWork(mozIStorageConnection* aConnection) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
GetSuccessResult(JSContext* aCx, JS::MutableHandleValue aVal) MOZ_OVERRIDE;
|
||||
|
||||
virtual void
|
||||
ReleaseMainThreadObjects() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
|
||||
|
||||
virtual ChildProcessSendResult
|
||||
SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
UnpackResponseFromParentProcess(const ResponseValue& aResponseValue)
|
||||
MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
~OpenKeyCursorHelper()
|
||||
{ }
|
||||
|
||||
nsresult EnsureCursor();
|
||||
|
||||
// In-params.
|
||||
nsRefPtr<IDBKeyRange> mKeyRange;
|
||||
const IDBCursor::Direction mDirection;
|
||||
|
||||
// Out-params.
|
||||
Key mKey;
|
||||
nsCString mContinueQuery;
|
||||
nsCString mContinueToQuery;
|
||||
Key mRangeKey;
|
||||
|
||||
// Only used in the parent process.
|
||||
nsRefPtr<IDBCursor> mCursor;
|
||||
};
|
||||
|
||||
class CreateIndexHelper : public NoRequestObjectStoreHelper
|
||||
{
|
||||
public:
|
||||
@ -493,46 +441,6 @@ private:
|
||||
nsTArray<StructuredCloneReadInfo> mCloneReadInfos;
|
||||
};
|
||||
|
||||
class GetAllKeysHelper MOZ_FINAL : public ObjectStoreHelper
|
||||
{
|
||||
public:
|
||||
GetAllKeysHelper(IDBTransaction* aTransaction,
|
||||
IDBRequest* aRequest,
|
||||
IDBObjectStore* aObjectStore,
|
||||
IDBKeyRange* aKeyRange,
|
||||
const uint32_t aLimit)
|
||||
: ObjectStoreHelper(aTransaction, aRequest, aObjectStore),
|
||||
mKeyRange(aKeyRange), mLimit(aLimit)
|
||||
{ }
|
||||
|
||||
virtual nsresult
|
||||
DoDatabaseWork(mozIStorageConnection* aConnection) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
GetSuccessResult(JSContext* aCx, JS::MutableHandleValue aVal) MOZ_OVERRIDE;
|
||||
|
||||
virtual void
|
||||
ReleaseMainThreadObjects() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
|
||||
|
||||
virtual ChildProcessSendResult
|
||||
SendResponseToChildProcess(nsresult aResultCode) MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult
|
||||
UnpackResponseFromParentProcess(const ResponseValue& aResponseValue)
|
||||
MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
~GetAllKeysHelper()
|
||||
{ }
|
||||
|
||||
nsRefPtr<IDBKeyRange> mKeyRange;
|
||||
const uint32_t mLimit;
|
||||
nsTArray<Key> mKeys;
|
||||
};
|
||||
|
||||
class CountHelper : public ObjectStoreHelper
|
||||
{
|
||||
public:
|
||||
@ -2173,47 +2081,6 @@ IDBObjectStore::GetAllInternal(IDBKeyRange* aKeyRange,
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<IDBRequest>
|
||||
IDBObjectStore::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!mTransaction->IsOpen()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<IDBRequest> request = GenerateRequest(this);
|
||||
if (!request) {
|
||||
NS_WARNING("Failed to generate request!");
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<GetAllKeysHelper> helper =
|
||||
new GetAllKeysHelper(mTransaction, request, this, aKeyRange, aLimit);
|
||||
|
||||
nsresult rv = helper->DispatchToTransactionPool();
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to dispatch!");
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IDB_PROFILER_MARK("IndexedDB Request %llu: "
|
||||
"database(%s).transaction(%s).objectStore(%s)."
|
||||
"getAllKeys(%s, %lu)",
|
||||
"IDBRequest[%llu] MT IDBObjectStore.getAllKeys()",
|
||||
request->GetSerialNumber(),
|
||||
IDB_PROFILER_STRING(Transaction()->Database()),
|
||||
IDB_PROFILER_STRING(Transaction()),
|
||||
IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange),
|
||||
aLimit);
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<IDBRequest>
|
||||
IDBObjectStore::DeleteInternal(IDBKeyRange* aKeyRange,
|
||||
ErrorResult& aRv)
|
||||
@ -2419,69 +2286,6 @@ IDBObjectStore::OpenCursorFromChildProcess(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
IDBObjectStore::OpenCursorFromChildProcess(IDBRequest* aRequest,
|
||||
size_t aDirection,
|
||||
const Key& aKey,
|
||||
IDBCursor** _retval)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aRequest);
|
||||
|
||||
auto direction = static_cast<IDBCursor::Direction>(aDirection);
|
||||
|
||||
nsRefPtr<IDBCursor> cursor =
|
||||
IDBCursor::Create(aRequest, mTransaction, this, direction, Key(),
|
||||
EmptyCString(), EmptyCString(), aKey);
|
||||
NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
cursor.forget(_retval);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
already_AddRefed<IDBRequest>
|
||||
IDBObjectStore::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!mTransaction->IsOpen()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<IDBRequest> request = GenerateRequest(this);
|
||||
if (!request) {
|
||||
NS_WARNING("Failed to generate request!");
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto direction = static_cast<IDBCursor::Direction>(aDirection);
|
||||
|
||||
nsRefPtr<OpenKeyCursorHelper> helper =
|
||||
new OpenKeyCursorHelper(mTransaction, request, this, aKeyRange, direction);
|
||||
|
||||
nsresult rv = helper->DispatchToTransactionPool();
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to dispatch!");
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IDB_PROFILER_MARK("IndexedDB Request %llu: "
|
||||
"database(%s).transaction(%s).objectStore(%s)."
|
||||
"openKeyCursor(%s, %s)",
|
||||
"IDBRequest[%llu] MT IDBObjectStore.openKeyCursor()",
|
||||
request->GetSerialNumber(),
|
||||
IDB_PROFILER_STRING(Transaction()->Database()),
|
||||
IDB_PROFILER_STRING(Transaction()),
|
||||
IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange),
|
||||
IDB_PROFILER_STRING(direction));
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
||||
void
|
||||
IDBObjectStore::SetInfo(ObjectStoreInfo* aInfo)
|
||||
{
|
||||
@ -2963,55 +2767,6 @@ IDBObjectStore::Count(JSContext* aCx,
|
||||
return CountInternal(keyRange, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<IDBRequest>
|
||||
IDBObjectStore::GetAllKeys(JSContext* aCx,
|
||||
const Optional<JS::HandleValue>& aKey,
|
||||
const Optional<uint32_t>& aLimit, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!mTransaction->IsOpen()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<IDBKeyRange> keyRange;
|
||||
if (aKey.WasPassed()) {
|
||||
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
|
||||
ENSURE_SUCCESS(aRv, nullptr);
|
||||
}
|
||||
|
||||
uint32_t limit = UINT32_MAX;
|
||||
if (aLimit.WasPassed() && aLimit.Value() != 0) {
|
||||
limit = aLimit.Value();
|
||||
}
|
||||
|
||||
return GetAllKeysInternal(keyRange, limit, aRv);
|
||||
}
|
||||
|
||||
already_AddRefed<IDBRequest>
|
||||
IDBObjectStore::OpenKeyCursor(JSContext* aCx,
|
||||
const Optional<JS::HandleValue>& aRange,
|
||||
IDBCursorDirection aDirection, ErrorResult& aRv)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
if (!mTransaction->IsOpen()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<IDBKeyRange> keyRange;
|
||||
if (aRange.WasPassed()) {
|
||||
aRv = IDBKeyRange::FromJSVal(aCx, aRange.Value(), getter_AddRefs(keyRange));
|
||||
ENSURE_SUCCESS(aRv, nullptr);
|
||||
}
|
||||
|
||||
IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection);
|
||||
|
||||
return OpenKeyCursorInternal(keyRange, static_cast<size_t>(direction), aRv);
|
||||
}
|
||||
|
||||
inline nsresult
|
||||
CopyData(nsIInputStream* aInputStream, nsIOutputStream* aOutputStream)
|
||||
{
|
||||
@ -4049,7 +3804,7 @@ OpenCursorHelper::SendResponseToChildProcess(nsresult aResultCode)
|
||||
params.requestParent() = requestActor;
|
||||
params.direction() = mDirection;
|
||||
params.key() = mKey;
|
||||
params.optionalCloneInfo() = mSerializedCloneReadInfo;
|
||||
params.cloneInfo() = mSerializedCloneReadInfo;
|
||||
params.blobsParent().SwapElements(blobsParent);
|
||||
|
||||
if (!objectStoreActor->OpenCursor(mCursor, params, openCursorResponse)) {
|
||||
@ -4105,311 +3860,6 @@ OpenCursorHelper::UnpackResponseFromParentProcess(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(IndexedDatabaseManager::IsMainProcess());
|
||||
|
||||
PROFILER_LABEL("IndexedDB",
|
||||
"OpenKeyCursorHelper::DoDatabaseWork [IDBObjectStore.cpp]");
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(keyValue, "key_value");
|
||||
NS_NAMED_LITERAL_CSTRING(id, "id");
|
||||
NS_NAMED_LITERAL_CSTRING(openLimit, " LIMIT ");
|
||||
|
||||
// Don't actually allocate space for this string yet.
|
||||
const nsCSubstringTuple queryStart =
|
||||
NS_LITERAL_CSTRING("SELECT ") + keyValue +
|
||||
NS_LITERAL_CSTRING(" FROM object_data WHERE object_store_id = :") + id;
|
||||
|
||||
nsAutoCString keyRangeClause;
|
||||
if (mKeyRange) {
|
||||
mKeyRange->GetBindingClause(keyValue, keyRangeClause);
|
||||
}
|
||||
|
||||
nsAutoCString directionClause = NS_LITERAL_CSTRING(" ORDER BY ") + keyValue;
|
||||
switch (mDirection) {
|
||||
case IDBCursor::NEXT:
|
||||
case IDBCursor::NEXT_UNIQUE:
|
||||
directionClause.AppendLiteral(" ASC");
|
||||
break;
|
||||
|
||||
case IDBCursor::PREV:
|
||||
case IDBCursor::PREV_UNIQUE:
|
||||
directionClause.AppendLiteral(" DESC");
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("Unknown direction type!");
|
||||
}
|
||||
|
||||
nsCString firstQuery = queryStart + keyRangeClause + directionClause +
|
||||
openLimit + NS_LITERAL_CSTRING("1");
|
||||
|
||||
nsCOMPtr<mozIStorageStatement> stmt =
|
||||
mTransaction->GetCachedStatement(firstQuery);
|
||||
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
mozStorageStatementScoper scoper(stmt);
|
||||
|
||||
nsresult rv = stmt->BindInt64ByName(id, mObjectStore->Id());
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
if (mKeyRange) {
|
||||
rv = mKeyRange->BindToStatement(stmt);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
bool hasResult;
|
||||
rv = stmt->ExecuteStep(&hasResult);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
if (!hasResult) {
|
||||
mKey.Unset();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
rv = mKey.SetFromStatement(stmt, 0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Now we need to make the query to get the next match.
|
||||
keyRangeClause.Truncate();
|
||||
nsAutoCString continueToKeyRangeClause;
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(currentKey, "current_key");
|
||||
NS_NAMED_LITERAL_CSTRING(rangeKey, "range_key");
|
||||
|
||||
switch (mDirection) {
|
||||
case IDBCursor::NEXT:
|
||||
case IDBCursor::NEXT_UNIQUE:
|
||||
AppendConditionClause(keyValue, currentKey, false, false,
|
||||
keyRangeClause);
|
||||
AppendConditionClause(keyValue, currentKey, false, true,
|
||||
continueToKeyRangeClause);
|
||||
if (mKeyRange && !mKeyRange->Upper().IsUnset()) {
|
||||
AppendConditionClause(keyValue, rangeKey, true,
|
||||
!mKeyRange->IsUpperOpen(), keyRangeClause);
|
||||
AppendConditionClause(keyValue, rangeKey, true,
|
||||
!mKeyRange->IsUpperOpen(),
|
||||
continueToKeyRangeClause);
|
||||
mRangeKey = mKeyRange->Upper();
|
||||
}
|
||||
break;
|
||||
|
||||
case IDBCursor::PREV:
|
||||
case IDBCursor::PREV_UNIQUE:
|
||||
AppendConditionClause(keyValue, currentKey, true, false, keyRangeClause);
|
||||
AppendConditionClause(keyValue, currentKey, true, true,
|
||||
continueToKeyRangeClause);
|
||||
if (mKeyRange && !mKeyRange->Lower().IsUnset()) {
|
||||
AppendConditionClause(keyValue, rangeKey, false,
|
||||
!mKeyRange->IsLowerOpen(), keyRangeClause);
|
||||
AppendConditionClause(keyValue, rangeKey, false,
|
||||
!mKeyRange->IsLowerOpen(),
|
||||
continueToKeyRangeClause);
|
||||
mRangeKey = mKeyRange->Lower();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_ASSUME_UNREACHABLE("Unknown direction type!");
|
||||
}
|
||||
|
||||
mContinueQuery = queryStart + keyRangeClause + directionClause + openLimit;
|
||||
mContinueToQuery = queryStart + continueToKeyRangeClause + directionClause +
|
||||
openLimit;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
OpenKeyCursorHelper::EnsureCursor()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("IndexedDB",
|
||||
"OpenKeyCursorHelper::EnsureCursor "
|
||||
"[IDBObjectStore.cpp]");
|
||||
|
||||
if (mCursor || mKey.IsUnset()) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
mCursor = IDBCursor::Create(mRequest, mTransaction, mObjectStore, mDirection,
|
||||
mRangeKey, mContinueQuery, mContinueToQuery,
|
||||
mKey);
|
||||
NS_ENSURE_TRUE(mCursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
OpenKeyCursorHelper::GetSuccessResult(JSContext* aCx,
|
||||
JS::MutableHandleValue aVal)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("IndexedDB",
|
||||
"OpenKeyCursorHelper::GetSuccessResult "
|
||||
"[IDBObjectStore.cpp]");
|
||||
|
||||
nsresult rv = EnsureCursor();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (mCursor) {
|
||||
rv = WrapNative(aCx, mCursor, aVal);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
}
|
||||
else {
|
||||
aVal.setUndefined();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
OpenKeyCursorHelper::ReleaseMainThreadObjects()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
mKeyRange = nullptr;
|
||||
mCursor = nullptr;
|
||||
|
||||
ObjectStoreHelper::ReleaseMainThreadObjects();
|
||||
}
|
||||
|
||||
nsresult
|
||||
OpenKeyCursorHelper::PackArgumentsForParentProcess(
|
||||
ObjectStoreRequestParams& aParams)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!IndexedDatabaseManager::IsMainProcess());
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("IndexedDB",
|
||||
"OpenKeyCursorHelper::"
|
||||
"PackArgumentsForParentProcess "
|
||||
"[IDBObjectStore.cpp]");
|
||||
|
||||
OpenKeyCursorParams params;
|
||||
|
||||
if (mKeyRange) {
|
||||
KeyRange keyRange;
|
||||
mKeyRange->ToSerializedKeyRange(keyRange);
|
||||
params.optionalKeyRange() = keyRange;
|
||||
}
|
||||
else {
|
||||
params.optionalKeyRange() = mozilla::void_t();
|
||||
}
|
||||
|
||||
params.direction() = mDirection;
|
||||
|
||||
aParams = params;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
AsyncConnectionHelper::ChildProcessSendResult
|
||||
OpenKeyCursorHelper::SendResponseToChildProcess(nsresult aResultCode)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(IndexedDatabaseManager::IsMainProcess());
|
||||
MOZ_ASSERT(!mCursor);
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("IndexedDB",
|
||||
"OpenKeyCursorHelper::SendResponseToChildProcess "
|
||||
"[IDBObjectStore.cpp]");
|
||||
|
||||
IndexedDBRequestParentBase* actor = mRequest->GetActorParent();
|
||||
MOZ_ASSERT(actor);
|
||||
|
||||
if (NS_SUCCEEDED(aResultCode)) {
|
||||
nsresult rv = EnsureCursor();
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("EnsureCursor failed!");
|
||||
aResultCode = rv;
|
||||
}
|
||||
}
|
||||
|
||||
ResponseValue response;
|
||||
if (NS_FAILED(aResultCode)) {
|
||||
response = aResultCode;
|
||||
} else {
|
||||
OpenCursorResponse openCursorResponse;
|
||||
|
||||
if (!mCursor) {
|
||||
openCursorResponse = mozilla::void_t();
|
||||
}
|
||||
else {
|
||||
IndexedDBObjectStoreParent* objectStoreActor =
|
||||
mObjectStore->GetActorParent();
|
||||
MOZ_ASSERT(objectStoreActor);
|
||||
|
||||
IndexedDBRequestParentBase* requestActor = mRequest->GetActorParent();
|
||||
MOZ_ASSERT(requestActor);
|
||||
|
||||
ObjectStoreCursorConstructorParams params;
|
||||
params.requestParent() = requestActor;
|
||||
params.direction() = mDirection;
|
||||
params.key() = mKey;
|
||||
params.optionalCloneInfo() = mozilla::void_t();
|
||||
|
||||
if (!objectStoreActor->OpenCursor(mCursor, params, openCursorResponse)) {
|
||||
return Error;
|
||||
}
|
||||
}
|
||||
|
||||
response = openCursorResponse;
|
||||
}
|
||||
|
||||
if (!actor->SendResponse(response)) {
|
||||
return Error;
|
||||
}
|
||||
|
||||
return Success_Sent;
|
||||
}
|
||||
|
||||
nsresult
|
||||
OpenKeyCursorHelper::UnpackResponseFromParentProcess(
|
||||
const ResponseValue& aResponseValue)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!IndexedDatabaseManager::IsMainProcess());
|
||||
MOZ_ASSERT(aResponseValue.type() == ResponseValue::TOpenCursorResponse);
|
||||
MOZ_ASSERT(aResponseValue.get_OpenCursorResponse().type() ==
|
||||
OpenCursorResponse::Tvoid_t ||
|
||||
aResponseValue.get_OpenCursorResponse().type() ==
|
||||
OpenCursorResponse::TPIndexedDBCursorChild);
|
||||
MOZ_ASSERT(!mCursor);
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("IndexedDB",
|
||||
"OpenKeyCursorHelper::"
|
||||
"UnpackResponseFromParentProcess "
|
||||
"[IDBObjectStore.cpp]");
|
||||
|
||||
const OpenCursorResponse& response =
|
||||
aResponseValue.get_OpenCursorResponse();
|
||||
|
||||
switch (response.type()) {
|
||||
case OpenCursorResponse::Tvoid_t:
|
||||
break;
|
||||
|
||||
case OpenCursorResponse::TPIndexedDBCursorChild: {
|
||||
IndexedDBCursorChild* actor =
|
||||
static_cast<IndexedDBCursorChild*>(
|
||||
response.get_PIndexedDBCursorChild());
|
||||
|
||||
mCursor = actor->ForgetStrongCursor();
|
||||
NS_ASSERTION(mCursor, "This should never be null!");
|
||||
|
||||
} break;
|
||||
|
||||
default:
|
||||
MOZ_CRASH("Unknown response union type!");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
CreateIndexHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
||||
{
|
||||
@ -4847,195 +4297,6 @@ GetAllHelper::UnpackResponseFromParentProcess(
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetAllKeysHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
|
||||
{
|
||||
MOZ_ASSERT(!NS_IsMainThread());
|
||||
MOZ_ASSERT(IndexedDatabaseManager::IsMainProcess());
|
||||
|
||||
PROFILER_LABEL("IndexedDB",
|
||||
"GetAllKeysHelper::DoDatabaseWork [IDObjectStore.cpp]");
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(keyValue, "key_value");
|
||||
|
||||
nsAutoCString keyRangeClause;
|
||||
if (mKeyRange) {
|
||||
mKeyRange->GetBindingClause(keyValue, keyRangeClause);
|
||||
}
|
||||
|
||||
nsAutoCString limitClause;
|
||||
if (mLimit != UINT32_MAX) {
|
||||
limitClause = NS_LITERAL_CSTRING(" LIMIT ");
|
||||
limitClause.AppendInt(mLimit);
|
||||
}
|
||||
|
||||
NS_NAMED_LITERAL_CSTRING(osid, "osid");
|
||||
|
||||
nsCString query = NS_LITERAL_CSTRING("SELECT ") + keyValue +
|
||||
NS_LITERAL_CSTRING(" FROM object_data WHERE "
|
||||
"object_store_id = :") +
|
||||
osid + keyRangeClause +
|
||||
NS_LITERAL_CSTRING(" ORDER BY key_value ASC") +
|
||||
limitClause;
|
||||
|
||||
nsCOMPtr<mozIStorageStatement> stmt = mTransaction->GetCachedStatement(query);
|
||||
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
mozStorageStatementScoper scoper(stmt);
|
||||
|
||||
nsresult rv = stmt->BindInt64ByName(osid, mObjectStore->Id());
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
if (mKeyRange) {
|
||||
rv = mKeyRange->BindToStatement(stmt);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
mKeys.SetCapacity(std::min<uint32_t>(50, mLimit));
|
||||
|
||||
bool hasResult;
|
||||
while(NS_SUCCEEDED((rv = stmt->ExecuteStep(&hasResult))) && hasResult) {
|
||||
if (mKeys.Capacity() == mKeys.Length()) {
|
||||
mKeys.SetCapacity(mKeys.Capacity() * 2);
|
||||
}
|
||||
|
||||
Key* key = mKeys.AppendElement();
|
||||
NS_ASSERTION(key, "This shouldn't fail!");
|
||||
|
||||
rv = key->SetFromStatement(stmt, 0);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetAllKeysHelper::GetSuccessResult(JSContext* aCx, JS::MutableHandleValue aVal)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(mKeys.Length() <= mLimit);
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("IndexedDB",
|
||||
"GetAllKeysHelper::GetSuccessResult "
|
||||
"[IDBObjectStore.cpp]");
|
||||
|
||||
nsTArray<Key> keys;
|
||||
mKeys.SwapElements(keys);
|
||||
|
||||
JS::RootedObject array(aCx, JS_NewArrayObject(aCx, 0, NULL));
|
||||
if (!array) {
|
||||
NS_WARNING("Failed to make array!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
if (!keys.IsEmpty()) {
|
||||
if (!JS_SetArrayLength(aCx, array, keys.Length())) {
|
||||
NS_WARNING("Failed to set array length!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
for (uint32_t index = 0, count = keys.Length(); index < count; index++) {
|
||||
const Key& key = keys[index];
|
||||
MOZ_ASSERT(!key.IsUnset());
|
||||
|
||||
JS::RootedValue value(aCx);
|
||||
nsresult rv = key.ToJSVal(aCx, &value);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("Failed to get jsval for key!");
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (!JS_SetElement(aCx, array, index, &value)) {
|
||||
NS_WARNING("Failed to set array element!");
|
||||
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aVal.setObject(*array);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
GetAllKeysHelper::ReleaseMainThreadObjects()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
mKeyRange = nullptr;
|
||||
|
||||
ObjectStoreHelper::ReleaseMainThreadObjects();
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetAllKeysHelper::PackArgumentsForParentProcess(
|
||||
ObjectStoreRequestParams& aParams)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!IndexedDatabaseManager::IsMainProcess());
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("IndexedDB",
|
||||
"GetAllKeysHelper::PackArgumentsForParentProcess "
|
||||
"[IDBObjectStore.cpp]");
|
||||
|
||||
GetAllKeysParams params;
|
||||
|
||||
if (mKeyRange) {
|
||||
KeyRange keyRange;
|
||||
mKeyRange->ToSerializedKeyRange(keyRange);
|
||||
params.optionalKeyRange() = keyRange;
|
||||
} else {
|
||||
params.optionalKeyRange() = mozilla::void_t();
|
||||
}
|
||||
|
||||
params.limit() = mLimit;
|
||||
|
||||
aParams = params;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
AsyncConnectionHelper::ChildProcessSendResult
|
||||
GetAllKeysHelper::SendResponseToChildProcess(nsresult aResultCode)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(IndexedDatabaseManager::IsMainProcess());
|
||||
|
||||
PROFILER_MAIN_THREAD_LABEL("IndexedDB",
|
||||
"GetAllKeysHelper::SendResponseToChildProcess "
|
||||
"[IDBObjectStore.cpp]");
|
||||
|
||||
IndexedDBRequestParentBase* actor = mRequest->GetActorParent();
|
||||
MOZ_ASSERT(actor);
|
||||
|
||||
ResponseValue response;
|
||||
if (NS_FAILED(aResultCode)) {
|
||||
response = aResultCode;
|
||||
}
|
||||
else {
|
||||
GetAllKeysResponse getAllKeysResponse;
|
||||
getAllKeysResponse.keys().AppendElements(mKeys);
|
||||
response = getAllKeysResponse;
|
||||
}
|
||||
|
||||
if (!actor->SendResponse(response)) {
|
||||
return Error;
|
||||
}
|
||||
|
||||
return Success_Sent;
|
||||
}
|
||||
|
||||
nsresult
|
||||
GetAllKeysHelper::UnpackResponseFromParentProcess(
|
||||
const ResponseValue& aResponseValue)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!IndexedDatabaseManager::IsMainProcess());
|
||||
MOZ_ASSERT(aResponseValue.type() == ResponseValue::TGetAllKeysResponse);
|
||||
|
||||
mKeys.AppendElements(aResponseValue.get_GetAllKeysResponse().keys());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
CountHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
||||
{
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
||||
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/dom/IDBCursorBinding.h"
|
||||
#include "mozilla/dom/IDBIndexBinding.h"
|
||||
#include "mozilla/dom/IDBObjectStoreBinding.h"
|
||||
@ -221,11 +220,6 @@ public:
|
||||
uint32_t aLimit,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<IDBRequest>
|
||||
GetAllKeysInternal(IDBKeyRange* aKeyRange,
|
||||
uint32_t aLimit,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<IDBRequest>
|
||||
DeleteInternal(IDBKeyRange* aKeyRange,
|
||||
ErrorResult& aRv);
|
||||
@ -239,13 +233,7 @@ public:
|
||||
size_t aDirection,
|
||||
ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<IDBRequest>
|
||||
OpenKeyCursorInternal(IDBKeyRange* aKeyRange,
|
||||
size_t aDirection,
|
||||
ErrorResult& aRv);
|
||||
|
||||
nsresult
|
||||
OpenCursorFromChildProcess(
|
||||
nsresult OpenCursorFromChildProcess(
|
||||
IDBRequest* aRequest,
|
||||
size_t aDirection,
|
||||
const Key& aKey,
|
||||
@ -253,12 +241,6 @@ public:
|
||||
nsTArray<StructuredCloneFile>& aBlobs,
|
||||
IDBCursor** _retval);
|
||||
|
||||
nsresult
|
||||
OpenCursorFromChildProcess(IDBRequest* aRequest,
|
||||
size_t aDirection,
|
||||
const Key& aKey,
|
||||
IDBCursor** _retval);
|
||||
|
||||
void
|
||||
SetInfo(ObjectStoreInfo* aInfo);
|
||||
|
||||
@ -337,7 +319,7 @@ public:
|
||||
|
||||
already_AddRefed<IDBIndex>
|
||||
CreateIndex(JSContext* aCx, const nsAString& aName,
|
||||
const Sequence<nsString>& aKeyPath,
|
||||
const Sequence<nsString >& aKeyPath,
|
||||
const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<IDBIndex>
|
||||
@ -352,15 +334,7 @@ public:
|
||||
|
||||
already_AddRefed<IDBRequest>
|
||||
GetAll(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
|
||||
const Optional<uint32_t>& aLimit, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<IDBRequest>
|
||||
GetAllKeys(JSContext* aCx, const Optional<JS::HandleValue>& aKey,
|
||||
const Optional<uint32_t>& aLimit, ErrorResult& aRv);
|
||||
|
||||
already_AddRefed<IDBRequest>
|
||||
OpenKeyCursor(JSContext* aCx, const Optional<JS::HandleValue>& aRange,
|
||||
IDBCursorDirection aDirection, ErrorResult& aRv);
|
||||
const Optional<uint32_t >& aLimit, ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
IDBObjectStore();
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIScriptError.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/CondVar.h"
|
||||
#include "mozilla/ContentEvents.h"
|
||||
@ -23,7 +22,6 @@
|
||||
#include "mozilla/dom/TabContext.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/storage.h"
|
||||
#include "mozilla/Util.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
#include "nsThreadUtils.h"
|
||||
@ -33,17 +31,6 @@
|
||||
#include "IDBKeyRange.h"
|
||||
#include "IDBRequest.h"
|
||||
|
||||
// Bindings for ResolveConstructors
|
||||
#include "mozilla/dom/IDBCursorBinding.h"
|
||||
#include "mozilla/dom/IDBDatabaseBinding.h"
|
||||
#include "mozilla/dom/IDBFactoryBinding.h"
|
||||
#include "mozilla/dom/IDBIndexBinding.h"
|
||||
#include "mozilla/dom/IDBObjectStoreBinding.h"
|
||||
#include "mozilla/dom/IDBOpenDBRequestBinding.h"
|
||||
#include "mozilla/dom/IDBRequestBinding.h"
|
||||
#include "mozilla/dom/IDBTransactionBinding.h"
|
||||
#include "mozilla/dom/IDBVersionChangeEventBinding.h"
|
||||
|
||||
// The two possible values for the data argument when receiving the disk space
|
||||
// observer notification.
|
||||
#define LOW_DISK_SPACE_DATA_FULL "full"
|
||||
@ -107,33 +94,6 @@ mozilla::StaticRefPtr<IndexedDatabaseManager> gInstance;
|
||||
mozilla::Atomic<int32_t> gInitialized(0);
|
||||
mozilla::Atomic<int32_t> gClosed(0);
|
||||
|
||||
// See ResolveConstructors below.
|
||||
struct ConstructorInfo {
|
||||
const char* name;
|
||||
JS::Handle<JSObject*> (*resolve)(JSContext*, JS::Handle<JSObject*>, bool);
|
||||
mutable jsid id;
|
||||
};
|
||||
|
||||
const ConstructorInfo gConstructorInfo[] = {
|
||||
|
||||
#define BINDING_ENTRY(_name) \
|
||||
{ #_name, _name##Binding::GetConstructorObject, JSID_VOID },
|
||||
|
||||
BINDING_ENTRY(IDBFactory)
|
||||
BINDING_ENTRY(IDBDatabase)
|
||||
BINDING_ENTRY(IDBTransaction)
|
||||
BINDING_ENTRY(IDBObjectStore)
|
||||
BINDING_ENTRY(IDBIndex)
|
||||
BINDING_ENTRY(IDBCursor)
|
||||
BINDING_ENTRY(IDBRequest)
|
||||
BINDING_ENTRY(IDBOpenDBRequest)
|
||||
BINDING_ENTRY(IDBVersionChangeEvent)
|
||||
|
||||
#undef BINDING_ENTRY
|
||||
};
|
||||
|
||||
const uint32_t gConstructorCount = mozilla::ArrayLength(gConstructorInfo);
|
||||
|
||||
class AsyncDeleteFileRunnable MOZ_FINAL : public nsIRunnable
|
||||
{
|
||||
public:
|
||||
@ -924,48 +884,3 @@ GetFileReferencesHelper::Run()
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
BEGIN_INDEXEDDB_NAMESPACE
|
||||
|
||||
bool
|
||||
ResolveConstructors(JSContext* aCx, JS::HandleObject aObj, JS::HandleId aId,
|
||||
JS::MutableHandleObject aObjp)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// The first time this function is called we need to intern all the strings we
|
||||
// care about.
|
||||
if (JSID_IS_VOID(gConstructorInfo[0].id)) {
|
||||
for (uint32_t i = 0; i < gConstructorCount; i++) {
|
||||
JS::RootedString str(aCx, JS_InternString(aCx, gConstructorInfo[i].name));
|
||||
if (!str) {
|
||||
NS_WARNING("Failed to intern string!");
|
||||
while (i) {
|
||||
gConstructorInfo[--i].id = JSID_VOID;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
gConstructorInfo[i].id = INTERNED_STRING_TO_JSID(aCx, str);
|
||||
}
|
||||
}
|
||||
|
||||
// Now resolve.
|
||||
for (uint32_t i = 0; i < gConstructorCount; i++) {
|
||||
if (gConstructorInfo[i].id == aId) {
|
||||
JS::RootedObject constructor(aCx,
|
||||
gConstructorInfo[i].resolve(aCx, aObj, true));
|
||||
if (!constructor) {
|
||||
return false;
|
||||
}
|
||||
|
||||
aObjp.set(aObj);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Not resolved.
|
||||
aObjp.set(nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
END_INDEXEDDB_NAMESPACE
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "nsIIndexedDatabaseManager.h"
|
||||
#include "nsIObserver.h"
|
||||
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/dom/quota/PersistenceType.h"
|
||||
#include "mozilla/Mutex.h"
|
||||
@ -167,10 +166,6 @@ private:
|
||||
static mozilla::Atomic<int32_t> sLowDiskSpaceMode;
|
||||
};
|
||||
|
||||
bool
|
||||
ResolveConstructors(JSContext* aCx, JS::HandleObject aObj, JS::HandleId aId,
|
||||
JS::MutableHandleObject aObjp);
|
||||
|
||||
END_INDEXEDDB_NAMESPACE
|
||||
|
||||
#endif /* mozilla_dom_indexeddb_indexeddatabasemanager_h__ */
|
||||
|
@ -742,40 +742,17 @@ IndexedDBObjectStoreChild::RecvPIndexedDBCursorConstructor(
|
||||
|
||||
size_t direction = static_cast<size_t>(aParams.direction());
|
||||
|
||||
nsTArray<StructuredCloneFile> blobs;
|
||||
IDBObjectStore::ConvertActorsToBlobs(aParams.blobsChild(), blobs);
|
||||
|
||||
nsRefPtr<IDBCursor> cursor;
|
||||
nsresult rv;
|
||||
nsresult rv =
|
||||
mObjectStore->OpenCursorFromChildProcess(request, direction, aParams.key(),
|
||||
aParams.cloneInfo(), blobs,
|
||||
getter_AddRefs(cursor));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
typedef ipc::OptionalStructuredCloneReadInfo CursorUnionType;
|
||||
|
||||
switch (aParams.optionalCloneInfo().type()) {
|
||||
case CursorUnionType::TSerializedStructuredCloneReadInfo: {
|
||||
nsTArray<StructuredCloneFile> blobs;
|
||||
IDBObjectStore::ConvertActorsToBlobs(aParams.blobsChild(), blobs);
|
||||
|
||||
const SerializedStructuredCloneReadInfo& cloneInfo =
|
||||
aParams.optionalCloneInfo().get_SerializedStructuredCloneReadInfo();
|
||||
|
||||
rv = mObjectStore->OpenCursorFromChildProcess(request, direction,
|
||||
aParams.key(), cloneInfo,
|
||||
blobs,
|
||||
getter_AddRefs(cursor));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
MOZ_ASSERT(blobs.IsEmpty(), "Should have swapped blob elements!");
|
||||
} break;
|
||||
|
||||
case CursorUnionType::Tvoid_t:
|
||||
MOZ_ASSERT(aParams.blobsChild().IsEmpty());
|
||||
|
||||
rv = mObjectStore->OpenCursorFromChildProcess(request, direction,
|
||||
aParams.key(),
|
||||
getter_AddRefs(cursor));
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_CRASH("Unknown union type!");
|
||||
}
|
||||
MOZ_ASSERT(blobs.IsEmpty(), "Should have swapped blob elements!");
|
||||
|
||||
actor->SetCursor(cursor);
|
||||
return true;
|
||||
@ -1092,9 +1069,6 @@ IndexedDBObjectStoreRequestChild::Recv__delete__(const ResponseValue& aResponse)
|
||||
case ResponseValue::TGetAllResponse:
|
||||
MOZ_ASSERT(mRequestType == ParamsUnionType::TGetAllParams);
|
||||
break;
|
||||
case ResponseValue::TGetAllKeysResponse:
|
||||
MOZ_ASSERT(mRequestType == ParamsUnionType::TGetAllKeysParams);
|
||||
break;
|
||||
case ResponseValue::TAddResponse:
|
||||
MOZ_ASSERT(mRequestType == ParamsUnionType::TAddParams);
|
||||
break;
|
||||
@ -1111,8 +1085,7 @@ IndexedDBObjectStoreRequestChild::Recv__delete__(const ResponseValue& aResponse)
|
||||
MOZ_ASSERT(mRequestType == ParamsUnionType::TCountParams);
|
||||
break;
|
||||
case ResponseValue::TOpenCursorResponse:
|
||||
MOZ_ASSERT(mRequestType == ParamsUnionType::TOpenCursorParams ||
|
||||
mRequestType == ParamsUnionType::TOpenKeyCursorParams);
|
||||
MOZ_ASSERT(mRequestType == ParamsUnionType::TOpenCursorParams);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -6,7 +6,6 @@ include "mozilla/dom/indexedDB/SerializationHelpers.h";
|
||||
|
||||
using mozilla::dom::indexedDB::Key;
|
||||
using mozilla::dom::indexedDB::IDBCursor::Direction;
|
||||
using mozilla::dom::indexedDB::SerializedStructuredCloneReadInfo;
|
||||
|
||||
using mozilla::void_t;
|
||||
|
||||
@ -41,12 +40,6 @@ struct GetAllParams
|
||||
uint32_t limit;
|
||||
};
|
||||
|
||||
struct GetAllKeysParams
|
||||
{
|
||||
OptionalKeyRange optionalKeyRange;
|
||||
uint32_t limit;
|
||||
};
|
||||
|
||||
struct CountParams
|
||||
{
|
||||
OptionalKeyRange optionalKeyRange;
|
||||
@ -58,18 +51,6 @@ struct OpenCursorParams
|
||||
Direction direction;
|
||||
};
|
||||
|
||||
struct OpenKeyCursorParams
|
||||
{
|
||||
OptionalKeyRange optionalKeyRange;
|
||||
Direction direction;
|
||||
};
|
||||
|
||||
union OptionalStructuredCloneReadInfo
|
||||
{
|
||||
SerializedStructuredCloneReadInfo;
|
||||
void_t;
|
||||
};
|
||||
|
||||
} // namespace ipc
|
||||
} // namespace indexedDB
|
||||
} // namespace dom
|
||||
|
@ -1097,9 +1097,6 @@ IndexedDBObjectStoreParent::RecvPIndexedDBRequestConstructor(
|
||||
case ObjectStoreRequestParams::TGetAllParams:
|
||||
return actor->GetAll(aParams.get_GetAllParams());
|
||||
|
||||
case ObjectStoreRequestParams::TGetAllKeysParams:
|
||||
return actor->GetAllKeys(aParams.get_GetAllKeysParams());
|
||||
|
||||
case ObjectStoreRequestParams::TAddParams:
|
||||
return actor->Add(aParams.get_AddParams());
|
||||
|
||||
@ -1118,9 +1115,6 @@ IndexedDBObjectStoreParent::RecvPIndexedDBRequestConstructor(
|
||||
case ObjectStoreRequestParams::TOpenCursorParams:
|
||||
return actor->OpenCursor(aParams.get_OpenCursorParams());
|
||||
|
||||
case ObjectStoreRequestParams::TOpenKeyCursorParams:
|
||||
return actor->OpenKeyCursor(aParams.get_OpenKeyCursorParams());
|
||||
|
||||
default:
|
||||
MOZ_CRASH("Unknown type!");
|
||||
}
|
||||
@ -1560,44 +1554,6 @@ IndexedDBObjectStoreRequestParent::GetAll(const GetAllParams& aParams)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
IndexedDBObjectStoreRequestParent::GetAllKeys(const GetAllKeysParams& aParams)
|
||||
{
|
||||
MOZ_ASSERT(mRequestType == ParamsUnionType::TGetAllKeysParams);
|
||||
MOZ_ASSERT(mObjectStore);
|
||||
|
||||
nsRefPtr<IDBRequest> request;
|
||||
|
||||
const ipc::OptionalKeyRange keyRangeUnion = aParams.optionalKeyRange();
|
||||
|
||||
nsRefPtr<IDBKeyRange> keyRange;
|
||||
|
||||
switch (keyRangeUnion.type()) {
|
||||
case ipc::OptionalKeyRange::TKeyRange:
|
||||
keyRange =
|
||||
IDBKeyRange::FromSerializedKeyRange(keyRangeUnion.get_KeyRange());
|
||||
break;
|
||||
|
||||
case ipc::OptionalKeyRange::Tvoid_t:
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_CRASH("Unknown param type!");
|
||||
}
|
||||
|
||||
{
|
||||
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
|
||||
|
||||
ErrorResult rv;
|
||||
request = mObjectStore->GetAllKeysInternal(keyRange, aParams.limit(), rv);
|
||||
ENSURE_SUCCESS(rv, false);
|
||||
}
|
||||
|
||||
request->SetActor(this);
|
||||
mRequest.swap(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
IndexedDBObjectStoreRequestParent::Add(const AddParams& aParams)
|
||||
{
|
||||
@ -1778,47 +1734,6 @@ IndexedDBObjectStoreRequestParent::OpenCursor(const OpenCursorParams& aParams)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
IndexedDBObjectStoreRequestParent::OpenKeyCursor(
|
||||
const OpenKeyCursorParams& aParams)
|
||||
{
|
||||
MOZ_ASSERT(mRequestType == ParamsUnionType::TOpenKeyCursorParams);
|
||||
MOZ_ASSERT(mObjectStore);
|
||||
|
||||
const ipc::OptionalKeyRange keyRangeUnion = aParams.optionalKeyRange();
|
||||
|
||||
nsRefPtr<IDBKeyRange> keyRange;
|
||||
|
||||
switch (keyRangeUnion.type()) {
|
||||
case ipc::OptionalKeyRange::TKeyRange:
|
||||
keyRange =
|
||||
IDBKeyRange::FromSerializedKeyRange(keyRangeUnion.get_KeyRange());
|
||||
break;
|
||||
|
||||
case ipc::OptionalKeyRange::Tvoid_t:
|
||||
break;
|
||||
|
||||
default:
|
||||
MOZ_CRASH("Unknown param type!");
|
||||
}
|
||||
|
||||
size_t direction = static_cast<size_t>(aParams.direction());
|
||||
|
||||
nsRefPtr<IDBRequest> request;
|
||||
|
||||
{
|
||||
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
|
||||
|
||||
ErrorResult rv;
|
||||
request = mObjectStore->OpenKeyCursorInternal(keyRange, direction, rv);
|
||||
ENSURE_SUCCESS(rv, false);
|
||||
}
|
||||
|
||||
request->SetActor(this);
|
||||
mRequest.swap(request);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* IndexedDBIndexRequestParent
|
||||
******************************************************************************/
|
||||
|
@ -707,10 +707,8 @@ class IndexedDBObjectStoreRequestParent : public IndexedDBRequestParentBase
|
||||
typedef ipc::DeleteParams DeleteParams;
|
||||
typedef ipc::GetParams GetParams;
|
||||
typedef ipc::GetAllParams GetAllParams;
|
||||
typedef ipc::GetAllKeysParams GetAllKeysParams;
|
||||
typedef ipc::CountParams CountParams;
|
||||
typedef ipc::OpenCursorParams OpenCursorParams;
|
||||
typedef ipc::OpenKeyCursorParams OpenKeyCursorParams;
|
||||
|
||||
public:
|
||||
IndexedDBObjectStoreRequestParent(IDBObjectStore* aObjectStore,
|
||||
@ -723,9 +721,6 @@ public:
|
||||
bool
|
||||
GetAll(const GetAllParams& aParams);
|
||||
|
||||
bool
|
||||
GetAllKeys(const GetAllKeysParams& aParams);
|
||||
|
||||
bool
|
||||
Add(const AddParams& aParams);
|
||||
|
||||
@ -744,9 +739,6 @@ public:
|
||||
bool
|
||||
OpenCursor(const OpenCursorParams& aParams);
|
||||
|
||||
bool
|
||||
OpenKeyCursor(const OpenKeyCursorParams& aParams);
|
||||
|
||||
protected:
|
||||
void
|
||||
ConvertBlobActors(const InfallibleTArray<PBlobParent*>& aActors,
|
||||
|
@ -9,6 +9,8 @@ include protocol PIndexedDBRequest;
|
||||
|
||||
include IndexedDBParams;
|
||||
|
||||
using mozilla::dom::indexedDB::SerializedStructuredCloneReadInfo;
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace indexedDB {
|
||||
@ -20,6 +22,18 @@ struct GetKeyParams
|
||||
KeyRange keyRange;
|
||||
};
|
||||
|
||||
struct GetAllKeysParams
|
||||
{
|
||||
OptionalKeyRange optionalKeyRange;
|
||||
uint32_t limit;
|
||||
};
|
||||
|
||||
struct OpenKeyCursorParams
|
||||
{
|
||||
OptionalKeyRange optionalKeyRange;
|
||||
Direction direction;
|
||||
};
|
||||
|
||||
union IndexRequestParams
|
||||
{
|
||||
GetParams;
|
||||
@ -31,6 +45,12 @@ union IndexRequestParams
|
||||
OpenKeyCursorParams;
|
||||
};
|
||||
|
||||
union OptionalStructuredCloneReadInfo
|
||||
{
|
||||
SerializedStructuredCloneReadInfo;
|
||||
void_t;
|
||||
};
|
||||
|
||||
struct IndexCursorConstructorParams
|
||||
{
|
||||
PIndexedDBRequest request;
|
||||
|
@ -12,6 +12,7 @@ include IndexedDBParams;
|
||||
|
||||
using mozilla::dom::indexedDB::IndexInfo;
|
||||
using mozilla::dom::indexedDB::IndexUpdateInfo;
|
||||
using mozilla::dom::indexedDB::SerializedStructuredCloneReadInfo;
|
||||
using mozilla::dom::indexedDB::SerializedStructuredCloneWriteInfo;
|
||||
|
||||
namespace mozilla {
|
||||
@ -51,14 +52,12 @@ union ObjectStoreRequestParams
|
||||
{
|
||||
GetParams;
|
||||
GetAllParams;
|
||||
GetAllKeysParams;
|
||||
AddParams;
|
||||
PutParams;
|
||||
DeleteParams;
|
||||
ClearParams;
|
||||
CountParams;
|
||||
OpenCursorParams;
|
||||
OpenKeyCursorParams;
|
||||
};
|
||||
|
||||
struct CreateIndexParams
|
||||
@ -82,7 +81,7 @@ struct ObjectStoreCursorConstructorParams
|
||||
PIndexedDBRequest request;
|
||||
Direction direction;
|
||||
Key key;
|
||||
OptionalStructuredCloneReadInfo optionalCloneInfo;
|
||||
SerializedStructuredCloneReadInfo cloneInfo;
|
||||
PBlob[] blobs;
|
||||
};
|
||||
|
||||
|
@ -36,9 +36,7 @@ tail =
|
||||
[test_names_sorted.js]
|
||||
[test_object_identity.js]
|
||||
[test_objectCursors.js]
|
||||
[test_objectStore_getAllKeys.js]
|
||||
[test_objectStore_inline_autoincrement_key_added_on_put.js]
|
||||
[test_objectStore_openKeyCursor.js]
|
||||
[test_objectStore_remove_values.js]
|
||||
[test_odd_result_order.js]
|
||||
[test_open_empty_db.js]
|
||||
|
@ -70,9 +70,7 @@ MOCHITEST_FILES = \
|
||||
test_multientry.html \
|
||||
test_names_sorted.html \
|
||||
test_objectCursors.html \
|
||||
test_objectStore_getAllKeys.html \
|
||||
test_objectStore_inline_autoincrement_key_added_on_put.html \
|
||||
test_objectStore_openKeyCursor.html \
|
||||
test_objectStore_remove_values.html \
|
||||
test_object_identity.html \
|
||||
test_odd_result_order.html \
|
||||
|
@ -1,19 +0,0 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Indexed Database Property Test</title>
|
||||
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
<script type="text/javascript;version=1.7" src="unit/test_objectStore_getAllKeys.js"></script>
|
||||
<script type="text/javascript;version=1.7" src="helpers.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="runTest();"></body>
|
||||
|
||||
</html>
|
@ -1,19 +0,0 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>Indexed Database Property Test</title>
|
||||
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
|
||||
<script type="text/javascript;version=1.7" src="unit/test_objectStore_openKeyCursor.js"></script>
|
||||
<script type="text/javascript;version=1.7" src="helpers.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body onload="runTest();"></body>
|
||||
|
||||
</html>
|
@ -38,9 +38,7 @@ MOCHITEST_FILES = \
|
||||
test_names_sorted.js \
|
||||
test_object_identity.js \
|
||||
test_objectCursors.js \
|
||||
test_objectStore_getAllKeys.js \
|
||||
test_objectStore_inline_autoincrement_key_added_on_put.js \
|
||||
test_objectStore_openKeyCursor.js \
|
||||
test_objectStore_remove_values.js \
|
||||
test_odd_result_order.js \
|
||||
test_open_empty_db.js \
|
||||
|
@ -1,123 +0,0 @@
|
||||
/**
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
let testGenerator = testSteps();
|
||||
|
||||
function testSteps() {
|
||||
const dbName = this.window ?
|
||||
window.location.pathname :
|
||||
"test_objectStore_getAllKeys";
|
||||
const dbVersion = 1;
|
||||
const objectStoreName = "foo";
|
||||
const keyCount = 200;
|
||||
|
||||
let request = indexedDB.open(dbName, dbVersion);
|
||||
request.onerror = errorHandler;
|
||||
request.onupgradeneeded = grabEventAndContinueHandler;
|
||||
request.onsuccess = unexpectedSuccessHandler;
|
||||
|
||||
let event = yield undefined;
|
||||
|
||||
info("Creating database");
|
||||
|
||||
let db = event.target.result;
|
||||
let objectStore = db.createObjectStore(objectStoreName);
|
||||
for (let i = 0; i < keyCount; i++) {
|
||||
objectStore.add(true, i);
|
||||
}
|
||||
|
||||
request.onupgradeneeded = unexpectedSuccessHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
|
||||
event = yield undefined;
|
||||
|
||||
db = event.target.result;
|
||||
objectStore = db.transaction(objectStoreName).objectStore(objectStoreName);
|
||||
|
||||
info("Getting all keys");
|
||||
objectStore.getAllKeys().onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
ok(Array.isArray(event.target.result), "Got an array result");
|
||||
is(event.target.result.length, keyCount, "Got correct array length");
|
||||
|
||||
let match = true;
|
||||
for (let i = 0; i < keyCount; i++) {
|
||||
if (event.target.result[i] != i) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ok(match, "Got correct keys");
|
||||
|
||||
info("Getting all keys with key range");
|
||||
let keyRange = IDBKeyRange.bound(10, 20, false, true);
|
||||
objectStore.getAllKeys(keyRange).onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
ok(Array.isArray(event.target.result), "Got an array result");
|
||||
is(event.target.result.length, 10, "Got correct array length");
|
||||
|
||||
match = true;
|
||||
for (let i = 10; i < 20; i++) {
|
||||
if (event.target.result[i - 10] != i) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ok(match, "Got correct keys");
|
||||
|
||||
info("Getting all keys with unmatched key range");
|
||||
keyRange = IDBKeyRange.bound(10000, 200000);
|
||||
objectStore.getAllKeys(keyRange).onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
ok(Array.isArray(event.target.result), "Got an array result");
|
||||
is(event.target.result.length, 0, "Got correct array length");
|
||||
|
||||
info("Getting all keys with limit");
|
||||
objectStore.getAllKeys(null, 5).onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
ok(Array.isArray(event.target.result), "Got an array result");
|
||||
is(event.target.result.length, 5, "Got correct array length");
|
||||
|
||||
match = true;
|
||||
for (let i = 0; i < 5; i++) {
|
||||
if (event.target.result[i] != i) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ok(match, "Got correct keys");
|
||||
|
||||
info("Getting all keys with key range and limit");
|
||||
keyRange = IDBKeyRange.bound(10, 20, false, true);
|
||||
objectStore.getAllKeys(keyRange, 5).onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
ok(Array.isArray(event.target.result), "Got an array result");
|
||||
is(event.target.result.length, 5, "Got correct array length");
|
||||
|
||||
match = true;
|
||||
for (let i = 10; i < 15; i++) {
|
||||
if (event.target.result[i - 10] != i) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ok(match, "Got correct keys");
|
||||
|
||||
info("Getting all keys with unmatched key range and limit");
|
||||
keyRange = IDBKeyRange.bound(10000, 200000);
|
||||
objectStore.getAllKeys(keyRange, 5).onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
ok(Array.isArray(event.target.result), "Got an array result");
|
||||
is(event.target.result.length, 0, "Got correct array length");
|
||||
|
||||
finishTest();
|
||||
yield undefined;
|
||||
}
|
@ -1,400 +0,0 @@
|
||||
/**
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
let testGenerator = testSteps();
|
||||
|
||||
function testSteps() {
|
||||
const dbName = this.window ?
|
||||
window.location.pathname :
|
||||
"test_objectStore_openKeyCursor";
|
||||
const dbVersion = 1;
|
||||
const objectStoreName = "foo";
|
||||
const keyCount = 100;
|
||||
|
||||
let request = indexedDB.open(dbName, dbVersion);
|
||||
request.onerror = errorHandler;
|
||||
request.onupgradeneeded = grabEventAndContinueHandler;
|
||||
request.onsuccess = unexpectedSuccessHandler;
|
||||
|
||||
let event = yield undefined;
|
||||
|
||||
info("Creating database");
|
||||
|
||||
let db = event.target.result;
|
||||
let objectStore = db.createObjectStore(objectStoreName);
|
||||
for (let i = 0; i < keyCount; i++) {
|
||||
objectStore.add(true, i);
|
||||
}
|
||||
|
||||
request.onupgradeneeded = unexpectedSuccessHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
|
||||
event = yield undefined;
|
||||
|
||||
db = event.target.result;
|
||||
objectStore = db.transaction(objectStoreName, "readwrite")
|
||||
.objectStore(objectStoreName);
|
||||
|
||||
info("Getting all keys");
|
||||
objectStore.getAllKeys().onsuccess = grabEventAndContinueHandler;
|
||||
event = yield undefined;
|
||||
|
||||
const allKeys = event.target.result;
|
||||
|
||||
ok(Array.isArray(allKeys), "Got an array result");
|
||||
is(allKeys.length, keyCount, "Got correct array length");
|
||||
|
||||
info("Opening normal key cursor");
|
||||
|
||||
let seenKeys = [];
|
||||
objectStore.openKeyCursor().onsuccess = event => {
|
||||
let cursor = event.target.result;
|
||||
if (!cursor) {
|
||||
continueToNextStepSync();
|
||||
return;
|
||||
}
|
||||
|
||||
is(cursor.source, objectStore, "Correct source");
|
||||
is(cursor.direction, "next", "Correct direction");
|
||||
|
||||
let exception = null;
|
||||
try {
|
||||
cursor.update(10);
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(!!exception, "update() throws for key cursor");
|
||||
|
||||
exception = null;
|
||||
try {
|
||||
cursor.delete();
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(!!exception, "delete() throws for key cursor");
|
||||
|
||||
is(cursor.key, cursor.primaryKey, "key and primaryKey match");
|
||||
ok(!("value" in cursor), "No 'value' property on key cursor");
|
||||
|
||||
seenKeys.push(cursor.key);
|
||||
cursor.continue();
|
||||
};
|
||||
yield undefined;
|
||||
|
||||
is(seenKeys.length, allKeys.length, "Saw the right number of keys");
|
||||
|
||||
let match = true;
|
||||
for (let i = 0; i < seenKeys.length; i++) {
|
||||
if (seenKeys[i] !== allKeys[i]) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ok(match, "All keys matched");
|
||||
|
||||
info("Opening key cursor with keyRange");
|
||||
|
||||
let keyRange = IDBKeyRange.bound(10, 20, false, true);
|
||||
|
||||
seenKeys = [];
|
||||
objectStore.openKeyCursor(keyRange).onsuccess = event => {
|
||||
let cursor = event.target.result;
|
||||
if (!cursor) {
|
||||
continueToNextStepSync();
|
||||
return;
|
||||
}
|
||||
|
||||
is(cursor.source, objectStore, "Correct source");
|
||||
is(cursor.direction, "next", "Correct direction");
|
||||
|
||||
let exception = null;
|
||||
try {
|
||||
cursor.update(10);
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(!!exception, "update() throws for key cursor");
|
||||
|
||||
exception = null;
|
||||
try {
|
||||
cursor.delete();
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(!!exception, "delete() throws for key cursor");
|
||||
|
||||
is(cursor.key, cursor.primaryKey, "key and primaryKey match");
|
||||
ok(!("value" in cursor), "No 'value' property on key cursor");
|
||||
|
||||
seenKeys.push(cursor.key);
|
||||
cursor.continue();
|
||||
};
|
||||
yield undefined;
|
||||
|
||||
is(seenKeys.length, 10, "Saw the right number of keys");
|
||||
|
||||
match = true;
|
||||
for (let i = 0; i < seenKeys.length; i++) {
|
||||
if (seenKeys[i] !== allKeys[i + 10]) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ok(match, "All keys matched");
|
||||
|
||||
info("Opening key cursor with unmatched keyRange");
|
||||
|
||||
keyRange = IDBKeyRange.bound(10000, 200000);
|
||||
|
||||
seenKeys = [];
|
||||
objectStore.openKeyCursor(keyRange).onsuccess = event => {
|
||||
let cursor = event.target.result;
|
||||
if (!cursor) {
|
||||
continueToNextStepSync();
|
||||
return;
|
||||
}
|
||||
|
||||
ok(false, "Shouldn't have any keys here");
|
||||
cursor.continue();
|
||||
};
|
||||
yield undefined;
|
||||
|
||||
is(seenKeys.length, 0, "Saw the right number of keys");
|
||||
|
||||
info("Opening reverse key cursor");
|
||||
|
||||
seenKeys = [];
|
||||
objectStore.openKeyCursor(null, "prev").onsuccess = event => {
|
||||
let cursor = event.target.result;
|
||||
if (!cursor) {
|
||||
continueToNextStepSync();
|
||||
return;
|
||||
}
|
||||
|
||||
is(cursor.source, objectStore, "Correct source");
|
||||
is(cursor.direction, "prev", "Correct direction");
|
||||
|
||||
let exception = null;
|
||||
try {
|
||||
cursor.update(10);
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(!!exception, "update() throws for key cursor");
|
||||
|
||||
exception = null;
|
||||
try {
|
||||
cursor.delete();
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(!!exception, "delete() throws for key cursor");
|
||||
|
||||
is(cursor.key, cursor.primaryKey, "key and primaryKey match");
|
||||
ok(!("value" in cursor), "No 'value' property on key cursor");
|
||||
|
||||
seenKeys.push(cursor.key);
|
||||
cursor.continue();
|
||||
};
|
||||
yield undefined;
|
||||
|
||||
is(seenKeys.length, allKeys.length, "Saw the right number of keys");
|
||||
|
||||
seenKeys.reverse();
|
||||
|
||||
match = true;
|
||||
for (let i = 0; i < seenKeys.length; i++) {
|
||||
if (seenKeys[i] !== allKeys[i]) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ok(match, "All keys matched");
|
||||
|
||||
info("Opening reverse key cursor with key range");
|
||||
|
||||
keyRange = IDBKeyRange.bound(10, 20, false, true);
|
||||
|
||||
seenKeys = [];
|
||||
objectStore.openKeyCursor(keyRange, "prev").onsuccess = event => {
|
||||
let cursor = event.target.result;
|
||||
if (!cursor) {
|
||||
continueToNextStepSync();
|
||||
return;
|
||||
}
|
||||
|
||||
is(cursor.source, objectStore, "Correct source");
|
||||
is(cursor.direction, "prev", "Correct direction");
|
||||
|
||||
let exception = null;
|
||||
try {
|
||||
cursor.update(10);
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(!!exception, "update() throws for key cursor");
|
||||
|
||||
exception = null;
|
||||
try {
|
||||
cursor.delete();
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(!!exception, "delete() throws for key cursor");
|
||||
|
||||
is(cursor.key, cursor.primaryKey, "key and primaryKey match");
|
||||
ok(!("value" in cursor), "No 'value' property on key cursor");
|
||||
|
||||
seenKeys.push(cursor.key);
|
||||
cursor.continue();
|
||||
};
|
||||
yield undefined;
|
||||
|
||||
is(seenKeys.length, 10, "Saw the right number of keys");
|
||||
|
||||
seenKeys.reverse();
|
||||
|
||||
match = true;
|
||||
for (let i = 0; i < 10; i++) {
|
||||
if (seenKeys[i] !== allKeys[i + 10]) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ok(match, "All keys matched");
|
||||
|
||||
info("Opening reverse key cursor with unmatched key range");
|
||||
|
||||
keyRange = IDBKeyRange.bound(10000, 200000);
|
||||
|
||||
seenKeys = [];
|
||||
objectStore.openKeyCursor(keyRange, "prev").onsuccess = event => {
|
||||
let cursor = event.target.result;
|
||||
if (!cursor) {
|
||||
continueToNextStepSync();
|
||||
return;
|
||||
}
|
||||
|
||||
ok(false, "Shouldn't have any keys here");
|
||||
cursor.continue();
|
||||
};
|
||||
yield undefined;
|
||||
|
||||
is(seenKeys.length, 0, "Saw the right number of keys");
|
||||
|
||||
info("Opening key cursor with advance");
|
||||
|
||||
seenKeys = [];
|
||||
objectStore.openKeyCursor().onsuccess = event => {
|
||||
let cursor = event.target.result;
|
||||
if (!cursor) {
|
||||
continueToNextStepSync();
|
||||
return;
|
||||
}
|
||||
|
||||
is(cursor.source, objectStore, "Correct source");
|
||||
is(cursor.direction, "next", "Correct direction");
|
||||
|
||||
let exception = null;
|
||||
try {
|
||||
cursor.update(10);
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(!!exception, "update() throws for key cursor");
|
||||
|
||||
exception = null;
|
||||
try {
|
||||
cursor.delete();
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(!!exception, "delete() throws for key cursor");
|
||||
|
||||
is(cursor.key, cursor.primaryKey, "key and primaryKey match");
|
||||
ok(!("value" in cursor), "No 'value' property on key cursor");
|
||||
|
||||
seenKeys.push(cursor.key);
|
||||
if (seenKeys.length == 1) {
|
||||
cursor.advance(10);
|
||||
} else {
|
||||
cursor.continue();
|
||||
}
|
||||
};
|
||||
yield undefined;
|
||||
|
||||
is(seenKeys.length, allKeys.length - 9, "Saw the right number of keys");
|
||||
|
||||
let match = true;
|
||||
for (let i = 0, j = 0; i < seenKeys.length; i++) {
|
||||
if (seenKeys[i] !== allKeys[i + j]) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
if (i == 0) {
|
||||
j = 9;
|
||||
}
|
||||
}
|
||||
ok(match, "All keys matched");
|
||||
|
||||
info("Opening key cursor with continue-to-key");
|
||||
|
||||
seenKeys = [];
|
||||
objectStore.openKeyCursor().onsuccess = event => {
|
||||
let cursor = event.target.result;
|
||||
if (!cursor) {
|
||||
continueToNextStepSync();
|
||||
return;
|
||||
}
|
||||
|
||||
is(cursor.source, objectStore, "Correct source");
|
||||
is(cursor.direction, "next", "Correct direction");
|
||||
|
||||
let exception = null;
|
||||
try {
|
||||
cursor.update(10);
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(!!exception, "update() throws for key cursor");
|
||||
|
||||
exception = null;
|
||||
try {
|
||||
cursor.delete();
|
||||
} catch(e) {
|
||||
exception = e;
|
||||
}
|
||||
ok(!!exception, "delete() throws for key cursor");
|
||||
|
||||
is(cursor.key, cursor.primaryKey, "key and primaryKey match");
|
||||
ok(!("value" in cursor), "No 'value' property on key cursor");
|
||||
|
||||
seenKeys.push(cursor.key);
|
||||
|
||||
if (seenKeys.length == 1) {
|
||||
cursor.continue(10);
|
||||
} else {
|
||||
cursor.continue();
|
||||
}
|
||||
};
|
||||
yield undefined;
|
||||
|
||||
is(seenKeys.length, allKeys.length - 9, "Saw the right number of keys");
|
||||
|
||||
let match = true;
|
||||
for (let i = 0, j = 0; i < seenKeys.length; i++) {
|
||||
if (seenKeys[i] !== allKeys[i + j]) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
if (i == 0) {
|
||||
j = 9;
|
||||
}
|
||||
}
|
||||
ok(match, "All keys matched");
|
||||
|
||||
finishTest();
|
||||
yield undefined;
|
||||
}
|
@ -39,9 +39,7 @@ tail =
|
||||
[test_names_sorted.js]
|
||||
[test_object_identity.js]
|
||||
[test_objectCursors.js]
|
||||
[test_objectStore_getAllKeys.js]
|
||||
[test_objectStore_inline_autoincrement_key_added_on_put.js]
|
||||
[test_objectStore_openKeyCursor.js]
|
||||
[test_objectStore_remove_values.js]
|
||||
[test_odd_result_order.js]
|
||||
[test_open_empty_db.js]
|
||||
|
@ -65,13 +65,4 @@ partial interface IDBObjectStore {
|
||||
// Success fires IDBTransactionEvent, result == array of values for given keys
|
||||
[Throws]
|
||||
IDBRequest mozGetAll (optional any key, optional unsigned long limit);
|
||||
|
||||
[Pref="dom.indexedDB.experimental", Throws]
|
||||
IDBRequest getAll (optional any key, optional unsigned long limit);
|
||||
|
||||
[Pref="dom.indexedDB.experimental", Throws]
|
||||
IDBRequest getAllKeys (optional any key, optional unsigned long limit);
|
||||
|
||||
[Pref="dom.indexedDB.experimental", Throws]
|
||||
IDBRequest openKeyCursor (optional any range, optional IDBCursorDirection direction = "next");
|
||||
};
|
||||
|
@ -4,17 +4,14 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/workers/Workers.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "BackstagePass.h"
|
||||
#include "nsIProgrammingLanguage.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
#include "nsIPrincipal.h"
|
||||
|
||||
#include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
|
||||
#include "mozilla/dom/workers/Workers.h"
|
||||
|
||||
using mozilla::dom::workers::ResolveWorkerClasses;
|
||||
namespace indexedDB = mozilla::dom::indexedDB;
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(BackstagePass)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIGlobalObject)
|
||||
@ -55,10 +52,12 @@ BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
JS::RootedId id(cx, idArg);
|
||||
|
||||
bool resolved;
|
||||
*objpArg = nullptr;
|
||||
|
||||
*_retval = !!JS_ResolveStandardClass(cx, obj, id, &resolved);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
if (!*_retval) {
|
||||
*objpArg = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (resolved) {
|
||||
*objpArg = obj;
|
||||
@ -66,23 +65,8 @@ BackstagePass::NewResolve(nsIXPConnectWrappedNative *wrapper,
|
||||
}
|
||||
|
||||
JS::RootedObject objp(cx, *objpArg);
|
||||
|
||||
*_retval = ResolveWorkerClasses(cx, obj, id, flags, &objp);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
if (objp) {
|
||||
*objpArg = objp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*_retval = indexedDB::ResolveConstructors(cx, obj, id, &objp);
|
||||
NS_ENSURE_TRUE(*_retval, NS_ERROR_FAILURE);
|
||||
|
||||
if (objp) {
|
||||
*objpArg = objp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*_retval = !!ResolveWorkerClasses(cx, obj, id, flags, &objp);
|
||||
*objpArg = objp;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,12 @@
|
||||
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/Exceptions.h"
|
||||
#include "mozilla/dom/IDBIndexBinding.h"
|
||||
#include "mozilla/dom/IDBObjectStoreBinding.h"
|
||||
#include "mozilla/dom/IDBOpenDBRequestBinding.h"
|
||||
#include "mozilla/dom/IDBRequestBinding.h"
|
||||
#include "mozilla/dom/IDBTransactionBinding.h"
|
||||
#include "mozilla/dom/IDBVersionChangeEventBinding.h"
|
||||
#include "mozilla/dom/TextDecoderBinding.h"
|
||||
#include "mozilla/dom/TextEncoderBinding.h"
|
||||
#include "mozilla/dom/DOMErrorBinding.h"
|
||||
@ -524,11 +530,13 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
|
||||
MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
|
||||
|
||||
// Init WebIDL binding constructors wanted on all XPConnect globals.
|
||||
// Additional bindings may be created lazily, see BackstagePass::NewResolve.
|
||||
//
|
||||
// XXX Please do not add any additional classes here without the approval of
|
||||
// the XPConnect module owner.
|
||||
if (!TextDecoderBinding::GetConstructorObject(aJSContext, global) ||
|
||||
if (!IDBIndexBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!IDBObjectStoreBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!IDBOpenDBRequestBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!IDBRequestBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!IDBTransactionBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!IDBVersionChangeEventBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!TextDecoderBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!TextEncoderBinding::GetConstructorObject(aJSContext, global) ||
|
||||
!DOMErrorBinding::GetConstructorObject(aJSContext, global)) {
|
||||
return UnexpectedFailure(NS_ERROR_FAILURE);
|
||||
|
Loading…
Reference in New Issue
Block a user