Bug 892065 - Move IDBIndex to WebIDL, r=janv

This commit is contained in:
Andrea Marchesini 2013-07-31 17:48:40 +02:00
Родитель 37ded34aa5
Коммит 7d820ab021
19 изменённых файлов: 394 добавлений и 436 удалений

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

@ -56,5 +56,4 @@ exports.DOMException = Ci.nsIDOMDOMException;
exports.IDBCursor = Ci.nsIIDBCursor;
exports.IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
exports.IDBDatabase = Ci.nsIIDBDatabase;
exports.IDBIndex = Ci.nsIIDBIndex;
exports.IDBRequest = Ci.nsIIDBRequest;

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

@ -9,7 +9,7 @@ if (xulApp.versionInRange(xulApp.platformVersion, "16.0a1", "*")) {
new function tests() {
const { indexedDB, IDBKeyRange, DOMException, IDBCursor,
IDBOpenDBRequest, IDBDatabase, IDBIndex, IDBRequest
IDBOpenDBRequest, IDBDatabase, IDBRequest
} = require("sdk/indexed-db");
exports["test indexedDB is frozen"] = function(assert){
@ -23,7 +23,7 @@ exports["test indexedDB is frozen"] = function(assert){
exports["test db variables"] = function(assert) {
[ indexedDB, IDBKeyRange, DOMException, IDBCursor,
IDBOpenDBRequest, IDBOpenDBRequest, IDBDatabase, IDBIndex,
IDBOpenDBRequest, IDBOpenDBRequest, IDBDatabase,
IDBRequest
].forEach(function(value) {
assert.notEqual(typeof(value), "undefined", "variable is defined");

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

@ -206,7 +206,6 @@
#include "mozilla/dom/indexedDB/IDBDatabase.h"
#include "mozilla/dom/indexedDB/IDBCursor.h"
#include "mozilla/dom/indexedDB/IDBKeyRange.h"
#include "mozilla/dom/indexedDB/IDBIndex.h"
using mozilla::dom::indexedDB::IDBWrapperCache;
using mozilla::dom::workers::ResolveWorkerClasses;
@ -643,8 +642,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBKeyRange, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBIndex, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBOpenDBRequest, IDBEventTargetSH,
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
@ -1556,10 +1553,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIIDBKeyRange)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(IDBIndex, nsIIDBIndex)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBIndex)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(IDBOpenDBRequest, nsIIDBOpenDBRequest)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBOpenDBRequest)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBRequest)

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

@ -124,7 +124,6 @@ DOMCI_CLASS(IDBDatabase)
DOMCI_CLASS(IDBCursor)
DOMCI_CLASS(IDBCursorWithValue)
DOMCI_CLASS(IDBKeyRange)
DOMCI_CLASS(IDBIndex)
DOMCI_CLASS(IDBOpenDBRequest)

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

@ -546,6 +546,14 @@ DOMInterfaces = {
'nativeType': 'mozilla::dom::indexedDB::IDBFileHandle',
},
'IDBIndex': {
'nativeType': 'mozilla::dom::indexedDB::IDBIndex',
'binaryNames': {
'mozGetAll': 'getAll',
'mozGetAllKeys': 'getAllKeys',
}
},
'IDBObjectStore': {
'nativeType': 'mozilla::dom::indexedDB::IDBObjectStore',
'implicitJSContext': [ 'createIndex' ],
@ -1668,7 +1676,6 @@ addExternalIface('FileCallback', nativeType='nsIFileCallback',
headerFile='nsIDOMHTMLCanvasElement.h')
addExternalIface('HitRegionOptions', nativeType='nsISupports')
addExternalIface('IDBDatabase', nativeType='nsIIDBDatabase')
addExternalIface('IDBIndex', nativeType='nsIIDBIndex')
addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest')
addExternalIface('IDBRequest', nativeType='nsIIDBRequest')
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')

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

@ -272,29 +272,6 @@ IDBCursor::Create(IDBRequest* aRequest,
return cursor.forget();
}
// static
nsresult
IDBCursor::ParseDirection(const nsAString& aDirection, Direction* aResult)
{
if (aDirection.EqualsLiteral("next")) {
*aResult = NEXT;
}
else if (aDirection.EqualsLiteral("nextunique")) {
*aResult = NEXT_UNIQUE;
}
else if (aDirection.EqualsLiteral("prev")) {
*aResult = PREV;
}
else if (aDirection.EqualsLiteral("prevunique")) {
*aResult = PREV_UNIQUE;
}
else {
return NS_ERROR_TYPE_ERR;
}
return NS_OK;
}
// static
IDBCursor::Direction
IDBCursor::ConvertDirection(mozilla::dom::IDBCursorDirection aDirection)

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

@ -116,9 +116,6 @@ public:
return mRequest;
}
static nsresult
ParseDirection(const nsAString& aDirection, Direction* aResult);
static Direction
ConvertDirection(IDBCursorDirection aDirection);

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

@ -15,7 +15,6 @@
#include "mozilla/dom/ipc/Blob.h"
#include "mozilla/storage.h"
#include "nsContentUtils.h"
#include "nsDOMClassInfoID.h"
#include "nsEventDispatcher.h"
#include "nsThreadUtils.h"
#include "xpcpublic.h"
@ -37,6 +36,7 @@
USING_INDEXEDDB_NAMESPACE
using namespace mozilla::dom;
using namespace mozilla::dom::indexedDB::ipc;
using mozilla::ErrorResult;
namespace {
@ -406,6 +406,8 @@ IDBIndex::IDBIndex()
mRooted(false)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
SetIsDOMBinding();
}
IDBIndex::~IDBIndex()
@ -425,26 +427,33 @@ IDBIndex::~IDBIndex()
}
}
nsresult
IDBIndex::GetInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::GetInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<GetHelper> helper =
new GetHelper(transaction, request, this, aKeyRange);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
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).index(%s)."
@ -457,30 +466,36 @@ IDBIndex::GetInternal(IDBKeyRange* aKeyRange,
IDB_PROFILER_STRING(ObjectStore()),
IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange));
request.forget(_retval);
return NS_OK;
return request.forget();
}
nsresult
IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<GetKeyHelper> helper =
new GetKeyHelper(transaction, request, this, aKeyRange);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
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).index(%s)."
@ -493,31 +508,37 @@ IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange,
IDB_PROFILER_STRING(ObjectStore()),
IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange));
request.forget(_retval);
return NS_OK;
return request.forget();
}
nsresult
IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
JSContext* aCx,
IDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange, uint32_t aLimit,
ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<GetAllHelper> helper =
new GetAllHelper(transaction, request, this, aKeyRange, aLimit);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
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).index(%s)."
@ -531,31 +552,36 @@ IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange,
IDB_PROFILER_STRING(this),
IDB_PROFILER_STRING(aKeyRange), aLimit);
request.forget(_retval);
return NS_OK;
return request.forget();
}
nsresult
IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
JSContext* aCx,
IDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit,
ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<GetAllKeysHelper> helper =
new GetAllKeysHelper(transaction, request, this, aKeyRange, aLimit);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
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).index(%s)."
@ -569,30 +595,36 @@ IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange,
IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange),
aLimit);
request.forget(_retval);
return NS_OK;
return request.forget();
}
nsresult
IDBIndex::CountInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::CountInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<CountHelper> helper =
new CountHelper(transaction, request, this, aKeyRange);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
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).index(%s)."
@ -605,34 +637,40 @@ IDBIndex::CountInternal(IDBKeyRange* aKeyRange,
IDB_PROFILER_STRING(ObjectStore()),
IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange));
request.forget(_retval);
return NS_OK;
return request.forget();
}
nsresult
IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange,
size_t aDirection,
JSContext* aCx,
IDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection,
ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
IDBCursor::Direction direction =
static_cast<IDBCursor::Direction>(aDirection);
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<OpenKeyCursorHelper> helper =
new OpenKeyCursorHelper(transaction, request, this, aKeyRange, direction);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
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).index(%s)."
@ -646,8 +684,7 @@ IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange,
IDB_PROFILER_STRING(this), IDB_PROFILER_STRING(aKeyRange),
IDB_PROFILER_STRING(direction));
request.forget(_retval);
return NS_OK;
return request.forget();
}
nsresult
@ -751,6 +788,7 @@ IDBIndex::OpenCursorFromChildProcess(
}
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBIndex)
NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mCachedKeyPath)
NS_IMPL_CYCLE_COLLECTION_TRACE_END
@ -760,6 +798,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBIndex)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBIndex)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
// Don't unlink mObjectStore!
tmp->mCachedKeyPath = JSVAL_VOID;
@ -771,316 +811,222 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBIndex)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBIndex)
NS_INTERFACE_MAP_ENTRY(nsIIDBIndex)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBIndex)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBIndex)
NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBIndex)
DOMCI_DATA(IDBIndex, IDBIndex)
NS_IMETHODIMP
IDBIndex::GetName(nsAString& aName)
JSObject*
IDBIndex::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
aName.Assign(mName);
return NS_OK;
return IDBIndexBinding::Wrap(aCx, aScope, this);
}
NS_IMETHODIMP
IDBIndex::GetStoreName(nsAString& aStoreName)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
aStoreName.Assign(mObjectStore->Name());
return NS_OK;
}
NS_IMETHODIMP
IDBIndex::GetKeyPath(JSContext* aCx,
jsval* aVal)
JS::Value
IDBIndex::GetKeyPath(JSContext* aCx, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!JSVAL_IS_VOID(mCachedKeyPath)) {
*aVal = mCachedKeyPath;
return NS_OK;
return mCachedKeyPath;
}
nsresult rv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath);
NS_ENSURE_SUCCESS(rv, rv);
aRv = GetKeyPath().ToJSVal(aCx, mCachedKeyPath);
ENSURE_SUCCESS(aRv, JSVAL_VOID);
if (JSVAL_IS_GCTHING(mCachedKeyPath)) {
NS_HOLD_JS_OBJECTS(this, IDBIndex);
mRooted = true;
}
*aVal = mCachedKeyPath;
return NS_OK;
return mCachedKeyPath;
}
NS_IMETHODIMP
IDBIndex::GetUnique(bool* aUnique)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
*aUnique = mUnique;
return NS_OK;
}
NS_IMETHODIMP
IDBIndex::GetMultiEntry(bool* aMultiEntry)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
*aMultiEntry = mMultiEntry;
return NS_OK;
}
NS_IMETHODIMP
IDBIndex::GetObjectStore(nsISupports** aObjectStore)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
nsCOMPtr<nsISupports> objectStore(mObjectStore);
objectStore.forget(aObjectStore);
return NS_OK;
}
NS_IMETHODIMP
IDBIndex::Get(const jsval& aKey,
JSContext* aCx,
nsIIDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::Get(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBKeyRange> keyRange;
nsresult rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
if (!keyRange) {
// Must specify a key or keyRange for getKey().
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
return nullptr;
}
return GetInternal(keyRange, aRv);
}
already_AddRefed<IDBRequest>
IDBIndex::GetKey(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBKeyRange> keyRange;
aRv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
if (!keyRange) {
// Must specify a key or keyRange for get().
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_DATA_ERR);
return nullptr;
}
nsRefPtr<IDBRequest> request;
rv = GetInternal(keyRange, aCx, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
request.forget(_retval);
return NS_OK;
return GetKeyInternal(keyRange, aRv);
}
NS_IMETHODIMP
IDBIndex::GetKey(const jsval& aKey,
JSContext* aCx,
nsIIDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::GetAll(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsRefPtr<IDBKeyRange> keyRange;
nsresult rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (!keyRange) {
// Must specify a key or keyRange for get().
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
if (aKey.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
nsRefPtr<IDBRequest> request;
rv = GetKeyInternal(keyRange, aCx, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
uint32_t limit = UINT32_MAX;
if (aLimit.WasPassed() && aLimit.Value() > 0) {
limit = aLimit.Value();
}
request.forget(_retval);
return NS_OK;
return GetAllInternal(keyRange, limit, aRv);
}
NS_IMETHODIMP
IDBIndex::GetAll(const jsval& aKey,
uint32_t aLimit,
JSContext* aCx,
uint8_t aOptionalArgCount,
nsIIDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::GetAllKeys(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsresult rv;
nsRefPtr<IDBKeyRange> keyRange;
if (aOptionalArgCount) {
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (aKey.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
if (aOptionalArgCount < 2 || aLimit == 0) {
aLimit = UINT32_MAX;
uint32_t limit = UINT32_MAX;
if (aLimit.WasPassed() && aLimit.Value() > 0) {
limit = aLimit.Value();
}
nsRefPtr<IDBRequest> request;
rv = GetAllInternal(keyRange, aLimit, aCx, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
request.forget(_retval);
return NS_OK;
return GetAllKeysInternal(keyRange, limit, aRv);
}
NS_IMETHODIMP
IDBIndex::GetAllKeys(const jsval& aKey,
uint32_t aLimit,
JSContext* aCx,
uint8_t aOptionalArgCount,
nsIIDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::OpenCursor(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aRange,
IDBCursorDirection aDirection, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsresult rv;
nsRefPtr<IDBKeyRange> keyRange;
if (aOptionalArgCount) {
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (aRange.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aRange.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
if (aOptionalArgCount < 2 || aLimit == 0) {
aLimit = UINT32_MAX;
}
nsRefPtr<IDBRequest> request;
rv = GetAllKeysInternal(keyRange, aLimit, aCx, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
request.forget(_retval);
return NS_OK;
}
NS_IMETHODIMP
IDBIndex::OpenCursor(const jsval& aKey,
const nsAString& aDirection,
JSContext* aCx,
uint8_t aOptionalArgCount,
nsIIDBRequest** _retval)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
nsresult rv;
IDBCursor::Direction direction = IDBCursor::NEXT;
nsRefPtr<IDBKeyRange> keyRange;
if (aOptionalArgCount) {
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (aOptionalArgCount >= 2) {
rv = IDBCursor::ParseDirection(aDirection, &direction);
NS_ENSURE_SUCCESS(rv, rv);
}
}
IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection);
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!request) {
NS_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
nsRefPtr<OpenCursorHelper> helper =
new OpenCursorHelper(transaction, request, this, keyRange, direction);
rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
request.forget(_retval);
return NS_OK;
return request.forget();
}
NS_IMETHODIMP
IDBIndex::OpenKeyCursor(const jsval& aKey,
const nsAString& aDirection,
JSContext* aCx,
uint8_t aOptionalArgCount,
nsIIDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::OpenKeyCursor(JSContext* aCx,
const Optional<JS::Handle<JS::Value> >& aRange,
IDBCursorDirection aDirection, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsresult rv;
IDBCursor::Direction direction = IDBCursor::NEXT;
nsRefPtr<IDBKeyRange> keyRange;
if (aOptionalArgCount) {
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (aOptionalArgCount >= 2) {
rv = IDBCursor::ParseDirection(aDirection, &direction);
NS_ENSURE_SUCCESS(rv, rv);
}
if (aRange.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aRange.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
nsRefPtr<IDBRequest> request;
rv = OpenKeyCursorInternal(keyRange, direction, aCx,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
IDBCursor::Direction direction = IDBCursor::ConvertDirection(aDirection);
request.forget(_retval);
return NS_OK;
return OpenKeyCursorInternal(keyRange, direction, aRv);
}
NS_IMETHODIMP
IDBIndex::Count(const jsval& aKey,
JSContext* aCx,
uint8_t aOptionalArgCount,
nsIIDBRequest** _retval)
already_AddRefed<IDBRequest>
IDBIndex::Count(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
ErrorResult& aRv)
{
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return nullptr;
}
nsresult rv;
nsRefPtr<IDBKeyRange> keyRange;
if (aOptionalArgCount) {
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (aKey.WasPassed()) {
aRv = IDBKeyRange::FromJSVal(aCx, aKey.Value(), getter_AddRefs(keyRange));
ENSURE_SUCCESS(aRv, nullptr);
}
nsRefPtr<IDBRequest> request;
rv = CountInternal(keyRange, aCx, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, rv);
request.forget(_retval);
return NS_OK;
return CountInternal(keyRange, aRv);
}
void

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

@ -8,11 +8,16 @@
#define mozilla_dom_indexeddb_idbindex_h__
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
#include "mozilla/dom/indexedDB/KeyPath.h"
#include "nsIIDBIndex.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/IDBCursorBinding.h"
#include "mozilla/ErrorResult.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
#include "mozilla/dom/indexedDB/IDBRequest.h"
#include "mozilla/dom/indexedDB/KeyPath.h"
class nsIScriptContext;
class nsPIDOMWindow;
@ -30,12 +35,11 @@ class Key;
struct IndexInfo;
class IDBIndex MOZ_FINAL : public nsIIDBIndex
class IDBIndex MOZ_FINAL : public nsISupports,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIIDBINDEX
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBIndex)
static already_AddRefed<IDBIndex>
@ -100,27 +104,27 @@ public:
return mActorParent;
}
nsresult GetInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
GetInternal(IDBKeyRange* aKeyRange,
ErrorResult& aRv);
nsresult GetKeyInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
GetKeyInternal(IDBKeyRange* aKeyRange,
ErrorResult& aRv);
nsresult GetAllInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
GetAllInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
ErrorResult& aRv);
nsresult GetAllKeysInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
GetAllKeysInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
ErrorResult& aRv);
nsresult CountInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
CountInternal(IDBKeyRange* aKeyRange,
ErrorResult& aRv);
nsresult OpenCursorFromChildProcess(
IDBRequest* aRequest,
@ -129,10 +133,10 @@ public:
const Key& aObjectKey,
IDBCursor** _retval);
nsresult OpenKeyCursorInternal(IDBKeyRange* aKeyRange,
size_t aDirection,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
OpenKeyCursorInternal(IDBKeyRange* aKeyRange,
size_t aDirection,
ErrorResult& aRv);
nsresult OpenCursorInternal(IDBKeyRange* aKeyRange,
size_t aDirection,
@ -147,6 +151,81 @@ public:
nsTArray<StructuredCloneFile>& aBlobs,
IDBCursor** _retval);
// nsWrapperCache
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
// WebIDL
IDBObjectStore*
GetParentObject() const
{
return mObjectStore;
}
void
GetName(nsString& aName) const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
aName.Assign(mName);
}
IDBObjectStore*
ObjectStore() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mObjectStore;
}
JS::Value
GetKeyPath(JSContext* aCx, ErrorResult& aRv);
bool
MultiEntry() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mMultiEntry;
}
bool
Unique() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mUnique;
}
already_AddRefed<IDBRequest>
OpenCursor(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aRange,
IDBCursorDirection aDirection, ErrorResult& aRv);
already_AddRefed<IDBRequest>
OpenKeyCursor(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aRange,
IDBCursorDirection aDirection, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Get(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
already_AddRefed<IDBRequest>
GetKey(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Count(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
ErrorResult& aRv);
void
GetStoreName(nsString& aStoreName) const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
mObjectStore->GetName(aStoreName);
}
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::Handle<JS::Value> >& aKey,
const Optional<uint32_t>& aLimit, ErrorResult& aRv);
private:
IDBIndex();
~IDBIndex();

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

@ -2293,7 +2293,7 @@ IDBObjectStore::SetInfo(ObjectStoreInfo* aInfo)
mInfo = aInfo;
}
already_AddRefed<nsIIDBIndex>
already_AddRefed<IDBIndex>
IDBObjectStore::CreateIndexInternal(const IndexInfo& aInfo, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -2338,7 +2338,7 @@ IDBObjectStore::CreateIndexInternal(const IndexInfo& aInfo, ErrorResult& aRv)
return index.forget();
}
already_AddRefed<nsIIDBIndex>
already_AddRefed<IDBIndex>
IDBObjectStore::Index(const nsAString& aName, ErrorResult &aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -2400,7 +2400,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBObjectStore)
for (uint32_t i = 0; i < tmp->mCreatedIndexes.Length(); i++) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mCreatedIndexes[i]");
cb.NoteXPCOMChild(static_cast<nsIIDBIndex*>(tmp->mCreatedIndexes[i].get()));
cb.NoteXPCOMChild(static_cast<nsISupports*>(tmp->mCreatedIndexes[i].get()));
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
@ -2582,7 +2582,7 @@ IDBObjectStore::OpenCursor(JSContext* aCx,
return OpenCursorInternal(keyRange, argDirection, aRv);
}
already_AddRefed<nsIIDBIndex>
already_AddRefed<IDBIndex>
IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName,
const nsAString& aKeyPath,
const IDBIndexParameters& aOptionalParameters,
@ -2600,7 +2600,7 @@ IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName,
return CreateIndex(aCx, aName, keyPath, aOptionalParameters, aRv);
}
already_AddRefed<nsIIDBIndex>
already_AddRefed<IDBIndex>
IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName,
const Sequence<nsString >& aKeyPath,
const IDBIndexParameters& aOptionalParameters,
@ -2622,7 +2622,7 @@ IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName,
return CreateIndex(aCx, aName, keyPath, aOptionalParameters, aRv);
}
already_AddRefed<nsIIDBIndex>
already_AddRefed<IDBIndex>
IDBObjectStore::CreateIndex(JSContext* aCx, const nsAString& aName,
KeyPath& aKeyPath,
const IDBIndexParameters& aOptionalParameters,

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

@ -21,7 +21,6 @@
class nsIDOMBlob;
class nsIScriptContext;
class nsPIDOMWindow;
class nsIIDBIndex;
namespace mozilla {
namespace dom {
@ -199,7 +198,7 @@ public:
return mActorParent;
}
already_AddRefed<nsIIDBIndex>
already_AddRefed<IDBIndex>
CreateIndexInternal(const IndexInfo& aInfo,
ErrorResult& aRv);
@ -313,16 +312,16 @@ public:
OpenCursor(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aRange,
IDBCursorDirection aDirection, ErrorResult& aRv);
already_AddRefed<nsIIDBIndex>
already_AddRefed<IDBIndex>
CreateIndex(JSContext* aCx, const nsAString& aName, const nsAString& aKeyPath,
const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv);
already_AddRefed<nsIIDBIndex>
already_AddRefed<IDBIndex>
CreateIndex(JSContext* aCx, const nsAString& aName,
const Sequence<nsString >& aKeyPath,
const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv);
already_AddRefed<nsIIDBIndex>
already_AddRefed<IDBIndex>
Index(const nsAString& aName, ErrorResult &aRv);
void
@ -352,7 +351,7 @@ protected:
const Optional<JS::Handle<JS::Value> >& aKey, bool aOverwrite,
ErrorResult& aRv);
already_AddRefed<nsIIDBIndex>
already_AddRefed<IDBIndex>
CreateIndex(JSContext* aCx, const nsAString& aName, KeyPath& aKeyPath,
const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv);

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

@ -1150,10 +1150,9 @@ IndexedDBObjectStoreParent::RecvPIndexedDBIndexConstructor(
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
ErrorResult rv;
nsCOMPtr<nsIIDBIndex> obj = mObjectStore->Index(name, rv);
index = mObjectStore->Index(name, rv);
ENSURE_SUCCESS(rv, false);
index = static_cast<IDBIndex*>(obj.get());
actor->SetIndex(index);
}
@ -1298,10 +1297,8 @@ IndexedDBVersionChangeObjectStoreParent::RecvPIndexedDBIndexConstructor(
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
ErrorResult rv;
nsCOMPtr<nsIIDBIndex> obj = mObjectStore->CreateIndexInternal(info, rv);
index = mObjectStore->CreateIndexInternal(info, rv);
ENSURE_SUCCESS(rv, false);
index = static_cast<IDBIndex*>(obj.get());
}
actor->SetIndex(index);
@ -1785,9 +1782,9 @@ IndexedDBIndexRequestParent::Get(const GetParams& aParams)
{
AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction());
nsresult rv = mIndex->GetInternal(keyRange, nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mIndex->GetInternal(keyRange, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1810,9 +1807,9 @@ IndexedDBIndexRequestParent::GetKey(const GetKeyParams& aParams)
{
AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction());
nsresult rv = mIndex->GetKeyInternal(keyRange, nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mIndex->GetKeyInternal(keyRange, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1849,9 +1846,9 @@ IndexedDBIndexRequestParent::GetAll(const GetAllParams& aParams)
{
AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction());
nsresult rv = mIndex->GetAllInternal(keyRange, aParams.limit(), nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mIndex->GetAllInternal(keyRange, aParams.limit(), rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1888,9 +1885,9 @@ IndexedDBIndexRequestParent::GetAllKeys(const GetAllKeysParams& aParams)
{
AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction());
nsresult rv = mIndex->GetAllKeysInternal(keyRange, aParams.limit(), nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mIndex->GetAllKeysInternal(keyRange, aParams.limit(), rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1927,9 +1924,9 @@ IndexedDBIndexRequestParent::Count(const CountParams& aParams)
{
AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction());
nsresult rv = mIndex->CountInternal(keyRange, nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mIndex->CountInternal(keyRange, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -2009,10 +2006,9 @@ IndexedDBIndexRequestParent::OpenKeyCursor(const OpenKeyCursorParams& aParams)
{
AutoSetCurrentTransaction asct(mIndex->ObjectStore()->Transaction());
nsresult rv =
mIndex->OpenKeyCursorInternal(keyRange, direction, nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mIndex->OpenKeyCursorInternal(keyRange, direction, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);

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

@ -11,7 +11,6 @@ XPIDL_SOURCES += [
'nsIIDBCursor.idl',
'nsIIDBCursorWithValue.idl',
'nsIIDBDatabase.idl',
'nsIIDBIndex.idl',
'nsIIDBKeyRange.idl',
'nsIIDBOpenDBRequest.idl',
'nsIIDBRequest.idl',

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

@ -1,67 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 "nsISupports.idl"
interface nsIIDBRequest;
/**
* IDBIndex interface. See
* http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-IDBIndex for more
* information.
*/
[scriptable, builtinclass, uuid(a859747a-0f05-4dfb-8f42-05c61415d4e4)]
interface nsIIDBIndex : nsISupports
{
readonly attribute DOMString name;
readonly attribute DOMString storeName;
[implicit_jscontext]
readonly attribute jsval keyPath;
readonly attribute boolean unique;
readonly attribute boolean multiEntry;
// This is a IDBObjectStore
readonly attribute nsISupports objectStore;
[implicit_jscontext]
nsIIDBRequest
get(in jsval key);
[implicit_jscontext]
nsIIDBRequest
getKey(in jsval key);
[implicit_jscontext, optional_argc, binaryname(GetAll)]
nsIIDBRequest
mozGetAll([optional /* null */] in jsval key,
[optional /* unlimited */] in unsigned long limit);
[implicit_jscontext, optional_argc, binaryname(GetAllKeys)]
nsIIDBRequest
mozGetAllKeys([optional /* null */] in jsval key,
[optional /* unlimited */] in unsigned long limit);
// direction can be "next", "nextunique", "prev" or "prevunique"
[implicit_jscontext, optional_argc]
nsIIDBRequest
openCursor([optional /* null */] in jsval key,
[optional /* "next" */] in DOMString direction);
// direction can be "next", "nextunique", "prev" or "prevunique"
[implicit_jscontext, optional_argc]
nsIIDBRequest
openKeyCursor([optional /* null */] in jsval key,
[optional /* "next" */] in DOMString direction);
// Accepts null, a key value, or a nsIIDBKeyRange object.
[implicit_jscontext, optional_argc]
nsIIDBRequest
count([optional] in jsval key);
};

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

@ -9,7 +9,6 @@ const DOMException = Ci.nsIDOMDOMException;
const IDBCursor = Ci.nsIIDBCursor;
const IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
const IDBDatabase = Ci.nsIIDBDatabase
const IDBIndex = Ci.nsIIDBIndex
const IDBRequest = Ci.nsIIDBRequest
function is(a, b, msg) {

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

@ -12,3 +12,38 @@ dictionary IDBIndexParameters {
boolean multiEntry = false;
};
interface IDBIndex {
readonly attribute DOMString name;
readonly attribute IDBObjectStore objectStore;
[Throws]
readonly attribute any keyPath;
readonly attribute boolean multiEntry;
readonly attribute boolean unique;
[Throws]
IDBRequest openCursor (optional any range, optional IDBCursorDirection direction = "next");
[Throws]
IDBRequest openKeyCursor (optional any range, optional IDBCursorDirection direction = "next");
[Throws]
IDBRequest get (any key);
[Throws]
IDBRequest getKey (any key);
[Throws]
IDBRequest count (optional any key);
};
partial interface IDBIndex {
readonly attribute DOMString storeName;
[Throws]
IDBRequest mozGetAll (optional any key, optional unsigned long limit);
[Throws]
IDBRequest mozGetAllKeys (optional any key, optional unsigned long limit);
};

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

@ -8,7 +8,6 @@
*/
interface IDBRequest;
interface IDBIndex;
interface IDBObjectStore {
readonly attribute DOMString name;

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

@ -87,7 +87,6 @@ members = [
'nsIIDBCursor.*',
'nsIIDBCursorWithValue.*',
'nsIIDBDatabase.*',
'nsIIDBIndex.*',
'nsIIDBKeyRange.*',
'nsIIDBRequest.*',
'nsIIDBOpenDBRequest.*',

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

@ -35,6 +35,7 @@
#include "XPCQuickStubs.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/IDBIndexBinding.h"
#include "mozilla/dom/IDBObjectStoreBinding.h"
#include "mozilla/dom/IDBTransactionBinding.h"
#include "mozilla/dom/IDBVersionChangeEventBinding.h"
@ -545,7 +546,8 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
// Init WebIDL binding constructors wanted on all XPConnect globals.
if (!IDBObjectStoreBinding::GetConstructorObject(aJSContext, global) ||
if (!IDBIndexBinding::GetConstructorObject(aJSContext, global) ||
!IDBObjectStoreBinding::GetConstructorObject(aJSContext, global) ||
!IDBTransactionBinding::GetConstructorObject(aJSContext, global) ||
!IDBVersionChangeEventBinding::GetConstructorObject(aJSContext, global) ||
!TextDecoderBinding::GetConstructorObject(aJSContext, global) ||