Bug 888597 - Move IDBObjectStore to WebIDL, r=janv

This commit is contained in:
Andrea Marchesini 2013-07-31 17:48:36 +02:00
parent 47b26323bd
commit 37ded34aa5
35 changed files with 708 additions and 632 deletions

View File

@ -57,5 +57,4 @@ exports.IDBCursor = Ci.nsIIDBCursor;
exports.IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
exports.IDBDatabase = Ci.nsIIDBDatabase;
exports.IDBIndex = Ci.nsIIDBIndex;
exports.IDBObjectStore = Ci.nsIIDBObjectStore;
exports.IDBRequest = Ci.nsIIDBRequest;

View File

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

View File

@ -204,7 +204,6 @@
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
#include "mozilla/dom/indexedDB/IDBRequest.h"
#include "mozilla/dom/indexedDB/IDBDatabase.h"
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
#include "mozilla/dom/indexedDB/IDBCursor.h"
#include "mozilla/dom/indexedDB/IDBKeyRange.h"
#include "mozilla/dom/indexedDB/IDBIndex.h"
@ -638,8 +637,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBDatabase, IDBEventTargetSH,
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBObjectStore, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBCursor, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBCursorWithValue, nsDOMGenericSH,
@ -1546,10 +1543,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(IDBObjectStore, nsIIDBObjectStore)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBObjectStore)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(IDBCursor, nsIIDBCursor)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor)
DOM_CLASSINFO_MAP_END

View File

@ -121,7 +121,6 @@ DOMCI_CLASS(ChromeMessageSender)
DOMCI_CLASS(IDBRequest)
DOMCI_CLASS(IDBDatabase)
DOMCI_CLASS(IDBObjectStore)
DOMCI_CLASS(IDBCursor)
DOMCI_CLASS(IDBCursorWithValue)
DOMCI_CLASS(IDBKeyRange)

View File

@ -546,6 +546,14 @@ DOMInterfaces = {
'nativeType': 'mozilla::dom::indexedDB::IDBFileHandle',
},
'IDBObjectStore': {
'nativeType': 'mozilla::dom::indexedDB::IDBObjectStore',
'implicitJSContext': [ 'createIndex' ],
'binaryNames': {
'mozGetAll': 'getAll'
}
},
'IDBTransaction': {
'nativeType': 'mozilla::dom::indexedDB::IDBTransaction',
},
@ -1660,8 +1668,9 @@ addExternalIface('FileCallback', nativeType='nsIFileCallback',
headerFile='nsIDOMHTMLCanvasElement.h')
addExternalIface('HitRegionOptions', nativeType='nsISupports')
addExternalIface('IDBDatabase', nativeType='nsIIDBDatabase')
addExternalIface('IDBObjectStore', nativeType='nsIIDBObjectStore')
addExternalIface('IDBIndex', nativeType='nsIIDBIndex')
addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest')
addExternalIface('IDBRequest', nativeType='nsIIDBRequest')
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
addExternalIface('LockedFile')

View File

@ -295,6 +295,28 @@ IDBCursor::ParseDirection(const nsAString& aDirection, Direction* aResult)
return NS_OK;
}
// static
IDBCursor::Direction
IDBCursor::ConvertDirection(mozilla::dom::IDBCursorDirection aDirection)
{
switch (aDirection) {
case mozilla::dom::IDBCursorDirection::Next:
return NEXT;
case mozilla::dom::IDBCursorDirection::Nextunique:
return NEXT_UNIQUE;
case mozilla::dom::IDBCursorDirection::Prev:
return PREV;
case mozilla::dom::IDBCursorDirection::Prevunique:
return PREV_UNIQUE;
default:
MOZ_CRASH("Unknown direction!");
}
}
// static
already_AddRefed<IDBCursor>
IDBCursor::CreateCommon(IDBRequest* aRequest,
@ -732,9 +754,12 @@ IDBCursor::Update(const jsval& aValue,
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
}
rv = mObjectStore->Put(aValue, JSVAL_VOID, aCx, 0, getter_AddRefs(request));
if (NS_FAILED(rv)) {
return rv;
ErrorResult error;
JS::Rooted<JS::Value> value(aCx, aValue);
Optional<JS::Handle<JS::Value> > keyValue(aCx);
request = mObjectStore->Put(aCx, value, keyValue, error);
if (error.Failed()) {
return error.ErrorCode();
}
}
else {
@ -742,9 +767,12 @@ IDBCursor::Update(const jsval& aValue,
rv = objectKey.ToJSVal(aCx, &keyVal);
NS_ENSURE_SUCCESS(rv, rv);
rv = mObjectStore->Put(aValue, keyVal, aCx, 1, getter_AddRefs(request));
if (NS_FAILED(rv)) {
return rv;
ErrorResult error;
JS::Rooted<JS::Value> value(aCx, aValue);
Optional<JS::Handle<JS::Value> > keyValue(aCx, keyVal);
request = mObjectStore->Put(aCx, value, keyValue, error);
if (error.Failed()) {
return error.ErrorCode();
}
}
@ -813,10 +841,10 @@ IDBCursor::Delete(JSContext* aCx,
nsresult rv = objectKey.ToJSVal(aCx, &key);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIIDBRequest> request;
rv = mObjectStore->Delete(key, aCx, getter_AddRefs(request));
if (NS_FAILED(rv)) {
return rv;
ErrorResult error;
nsCOMPtr<nsIIDBRequest> request = mObjectStore->Delete(aCx, key, error);
if (error.Failed()) {
return error.ErrorCode();
}
#ifdef IDB_PROFILER_USE_MARKS

View File

@ -8,13 +8,16 @@
#define mozilla_dom_indexeddb_idbcursor_h__
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
#include "mozilla/dom/indexedDB/Key.h"
#include "nsIIDBCursorWithValue.h"
#include "mozilla/dom/IDBCursorBinding.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
#include "mozilla/dom/indexedDB/Key.h"
class nsIRunnable;
class nsIScriptContext;
class nsPIDOMWindow;
@ -113,8 +116,11 @@ public:
return mRequest;
}
static nsresult ParseDirection(const nsAString& aDirection,
Direction* aResult);
static nsresult
ParseDirection(const nsAString& aDirection, Direction* aResult);
static Direction
ConvertDirection(IDBCursorDirection aDirection);
void
SetActor(IndexedDBCursorChild* aActorChild)

View File

@ -525,7 +525,7 @@ NS_IMETHODIMP
IDBDatabase::CreateObjectStore(const nsAString& aName,
const jsval& aOptions,
JSContext* aCx,
nsIIDBObjectStore** _retval)
nsISupports** _retval)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

View File

@ -795,7 +795,8 @@ IDBIndex::GetStoreName(nsAString& aStoreName)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mObjectStore->GetName(aStoreName);
aStoreName.Assign(mObjectStore->Name());
return NS_OK;
}
NS_IMETHODIMP
@ -840,11 +841,11 @@ IDBIndex::GetMultiEntry(bool* aMultiEntry)
}
NS_IMETHODIMP
IDBIndex::GetObjectStore(nsIIDBObjectStore** aObjectStore)
IDBIndex::GetObjectStore(nsISupports** aObjectStore)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
nsCOMPtr<nsIIDBObjectStore> objectStore(mObjectStore);
nsCOMPtr<nsISupports> objectStore(mObjectStore);
objectStore.forget(aObjectStore);
return NS_OK;
}

File diff suppressed because it is too large Load Diff

View File

@ -9,16 +9,19 @@
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
#include "nsIIDBObjectStore.h"
#include "mozilla/dom/IDBCursorBinding.h"
#include "mozilla/dom/IDBIndexBinding.h"
#include "mozilla/dom/IDBObjectStoreBinding.h"
#include "nsCycleCollectionParticipant.h"
#include "mozilla/dom/indexedDB/IDBRequest.h"
#include "mozilla/dom/indexedDB/IDBTransaction.h"
#include "mozilla/dom/indexedDB/KeyPath.h"
class nsIDOMBlob;
class nsIScriptContext;
class nsPIDOMWindow;
class nsIIDBIndex;
namespace mozilla {
namespace dom {
@ -46,12 +49,11 @@ struct ObjectStoreInfo;
struct FileHandleData;
struct BlobOrFileData;
class IDBObjectStore MOZ_FINAL : public nsIIDBObjectStore
class IDBObjectStore MOZ_FINAL : public nsISupports,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_NSIIDBOBJECTSTORE
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBObjectStore)
static already_AddRefed<IDBObjectStore>
@ -197,13 +199,9 @@ public:
return mActorParent;
}
nsresult
already_AddRefed<nsIIDBIndex>
CreateIndexInternal(const IndexInfo& aInfo,
IDBIndex** _retval);
nsresult
IndexInternal(const nsAString& aName,
IDBIndex** _retval);
ErrorResult& aRv);
nsresult AddOrPutInternal(
const SerializedStructuredCloneWriteInfo& aCloneWriteInfo,
@ -213,30 +211,27 @@ public:
bool aOverwrite,
IDBRequest** _retval);
nsresult GetInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
GetInternal(IDBKeyRange* aKeyRange,
ErrorResult& aRv);
nsresult GetAllInternal(IDBKeyRange* aKeyRange,
already_AddRefed<IDBRequest>
GetAllInternal(IDBKeyRange* aKeyRange,
uint32_t aLimit,
JSContext* aCx,
IDBRequest** _retval);
ErrorResult& aRv);
nsresult DeleteInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
DeleteInternal(IDBKeyRange* aKeyRange,
ErrorResult& aRv);
nsresult ClearInternal(JSContext* aCx,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
CountInternal(IDBKeyRange* aKeyRange,
ErrorResult& aRv);
nsresult CountInternal(IDBKeyRange* aKeyRange,
JSContext* aCx,
IDBRequest** _retval);
nsresult OpenCursorInternal(IDBKeyRange* aKeyRange,
already_AddRefed<IDBRequest>
OpenCursorInternal(IDBKeyRange* aKeyRange,
size_t aDirection,
JSContext* aCx,
IDBRequest** _retval);
ErrorResult& aRv);
nsresult OpenCursorFromChildProcess(
IDBRequest* aRequest,
@ -251,6 +246,96 @@ public:
static JSClass sDummyPropJSClass;
// nsWrapperCache
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
// WebIDL
IDBTransaction*
GetParentObject() const
{
return mTransaction;
}
void
GetName(nsString& aName) const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
aName.Assign(mName);
}
JS::Value
GetKeyPath(JSContext* aCx, ErrorResult& aRv);
already_AddRefed<nsIDOMDOMStringList>
GetIndexNames(ErrorResult& aRv);
IDBTransaction*
Transaction() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mTransaction;
}
bool
AutoIncrement() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mAutoIncrement;
}
already_AddRefed<IDBRequest>
Put(JSContext* aCx, JS::Handle<JS::Value> aValue,
const Optional<JS::Handle<JS::Value> >& aKey, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return AddOrPut(aCx, aValue, aKey, true, aRv);
}
already_AddRefed<IDBRequest>
Add(JSContext* aCx, JS::Handle<JS::Value> aValue,
const Optional<JS::Handle<JS::Value> >& aKey, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return AddOrPut(aCx, aValue, aKey, false, aRv);
}
already_AddRefed<IDBRequest>
Delete(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Get(JSContext* aCx, JS::Handle<JS::Value> aKey, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Clear(ErrorResult& aRv);
already_AddRefed<IDBRequest>
OpenCursor(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aRange,
IDBCursorDirection aDirection, ErrorResult& aRv);
already_AddRefed<nsIIDBIndex>
CreateIndex(JSContext* aCx, const nsAString& aName, const nsAString& aKeyPath,
const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv);
already_AddRefed<nsIIDBIndex>
CreateIndex(JSContext* aCx, const nsAString& aName,
const Sequence<nsString >& aKeyPath,
const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv);
already_AddRefed<nsIIDBIndex>
Index(const nsAString& aName, ErrorResult &aRv);
void
DeleteIndex(const nsAString& aIndexName, ErrorResult& aRv);
already_AddRefed<IDBRequest>
Count(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
ErrorResult& aRv);
already_AddRefed<IDBRequest>
GetAll(JSContext* aCx, const Optional<JS::Handle<JS::Value> >& aKey,
const Optional<uint32_t >& aLimit, ErrorResult& aRv);
protected:
IDBObjectStore();
~IDBObjectStore();
@ -262,12 +347,14 @@ protected:
Key& aKey,
nsTArray<IndexUpdateInfo>& aUpdateInfoArray);
nsresult AddOrPut(const jsval& aValue,
const jsval& aKey,
JSContext* aCx,
uint8_t aOptionalArgCount,
bool aOverwrite,
IDBRequest** _retval);
already_AddRefed<IDBRequest>
AddOrPut(JSContext* aCx, JS::Handle<JS::Value> aValue,
const Optional<JS::Handle<JS::Value> >& aKey, bool aOverwrite,
ErrorResult& aRv);
already_AddRefed<nsIIDBIndex>
CreateIndex(JSContext* aCx, const nsAString& aName, KeyPath& aKeyPath,
const IDBIndexParameters& aOptionalParameters, ErrorResult& aRv);
static void
ClearStructuredCloneBuffer(JSAutoStructuredCloneBuffer& aBuffer);

View File

@ -699,7 +699,7 @@ IDBTransaction::GetObjectStoreNames(ErrorResult& aRv)
return list.forget();
}
already_AddRefed<nsIIDBObjectStore>
already_AddRefed<IDBObjectStore>
IDBTransaction::ObjectStore(const nsAString& aName, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");

View File

@ -240,7 +240,7 @@ public:
DOMError*
GetError(ErrorResult& aRv);
already_AddRefed<nsIIDBObjectStore>
already_AddRefed<IDBObjectStore>
ObjectStore(const nsAString& aName, ErrorResult& aRv);
void

View File

@ -12,6 +12,8 @@
#include "nsJSUtils.h"
#include "xpcpublic.h"
#include "mozilla/dom/BindingDeclarations.h"
USING_INDEXEDDB_NAMESPACE
namespace {
@ -220,6 +222,39 @@ GetJSValFromKeyPathString(JSContext* aCx,
} // anonymous namespace
// static
nsresult
KeyPath::Parse(JSContext* aCx, const nsAString& aString, KeyPath* aKeyPath)
{
KeyPath keyPath(0);
keyPath.SetType(STRING);
if (!keyPath.AppendStringWithValidation(aCx, aString)) {
return NS_ERROR_FAILURE;
}
*aKeyPath = keyPath;
return NS_OK;
}
//static
nsresult
KeyPath::Parse(JSContext* aCx, const mozilla::dom::Sequence<nsString>& aStrings,
KeyPath* aKeyPath)
{
KeyPath keyPath(0);
keyPath.SetType(ARRAY);
for (uint32_t i = 0; i < aStrings.Length(); ++i) {
if (!keyPath.AppendStringWithValidation(aCx, aStrings[i])) {
return NS_ERROR_FAILURE;
}
}
*aKeyPath = keyPath;
return NS_OK;
}
// static
nsresult
KeyPath::Parse(JSContext* aCx, const JS::Value& aValue, KeyPath* aKeyPath)

View File

@ -9,6 +9,8 @@
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
#include "mozilla/dom/BindingDeclarations.h"
BEGIN_INDEXEDDB_NAMESPACE
class Key;
@ -45,6 +47,12 @@ public:
MOZ_COUNT_DTOR(KeyPath);
}
static nsresult
Parse(JSContext* aCx, const nsAString& aString, KeyPath* aKeyPath);
static nsresult
Parse(JSContext* aCx, const Sequence<nsString>& aStrings, KeyPath* aKeyPath);
static nsresult
Parse(JSContext* aCx, const JS::Value& aValue, KeyPath* aKeyPath);

View File

@ -796,13 +796,9 @@ IndexedDBTransactionParent::RecvPIndexedDBObjectStoreConstructor(
AutoSetCurrentTransaction asct(mTransaction);
ErrorResult rv;
nsCOMPtr<nsIIDBObjectStore> store = mTransaction->ObjectStore(name, rv);
if (rv.Failed()) {
NS_WARNING("Failed to get object store!");
return false;
}
objectStore = mTransaction->ObjectStore(name, rv);
ENSURE_SUCCESS(rv, false);
objectStore = static_cast<IDBObjectStore*>(store.get());
actor->SetObjectStore(objectStore);
}
@ -1153,9 +1149,11 @@ IndexedDBObjectStoreParent::RecvPIndexedDBIndexConstructor(
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv = mObjectStore->IndexInternal(name, getter_AddRefs(index));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
nsCOMPtr<nsIIDBIndex> obj = mObjectStore->Index(name, rv);
ENSURE_SUCCESS(rv, false);
index = static_cast<IDBIndex*>(obj.get());
actor->SetIndex(index);
}
@ -1253,16 +1251,15 @@ IndexedDBVersionChangeObjectStoreParent::RecvDeleteIndex(const nsString& aName)
return true;
}
nsresult rv;
ErrorResult rv;
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
rv = mObjectStore->DeleteIndex(aName);
mObjectStore->DeleteIndex(aName, rv);
}
NS_ENSURE_SUCCESS(rv, false);
ENSURE_SUCCESS(rv, false);
return true;
}
@ -1297,15 +1294,15 @@ IndexedDBVersionChangeObjectStoreParent::RecvPIndexedDBIndexConstructor(
nsRefPtr<IDBIndex> index;
nsresult rv;
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
rv = mObjectStore->CreateIndexInternal(info, getter_AddRefs(index));
}
ErrorResult rv;
nsCOMPtr<nsIIDBIndex> obj = mObjectStore->CreateIndexInternal(info, rv);
ENSURE_SUCCESS(rv, false);
NS_ENSURE_SUCCESS(rv, false);
index = static_cast<IDBIndex*>(obj.get());
}
actor->SetIndex(index);
index->SetActor(actor);
@ -1513,9 +1510,9 @@ IndexedDBObjectStoreRequestParent::Get(const GetParams& aParams)
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv = mObjectStore->GetInternal(keyRange, nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mObjectStore->GetInternal(keyRange, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1553,10 +1550,9 @@ IndexedDBObjectStoreRequestParent::GetAll(const GetAllParams& aParams)
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv = mObjectStore->GetAllInternal(keyRange, aParams.limit(),
nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mObjectStore->GetAllInternal(keyRange, aParams.limit(), rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1635,9 +1631,9 @@ IndexedDBObjectStoreRequestParent::Delete(const DeleteParams& aParams)
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv =
mObjectStore->DeleteInternal(keyRange, nullptr, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mObjectStore->DeleteInternal(keyRange, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1656,8 +1652,9 @@ IndexedDBObjectStoreRequestParent::Clear(const ClearParams& aParams)
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv = mObjectStore->ClearInternal(nullptr, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mObjectStore->Clear(rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1694,9 +1691,9 @@ IndexedDBObjectStoreRequestParent::Count(const CountParams& aParams)
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv =
mObjectStore->CountInternal(keyRange, nullptr, getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mObjectStore->CountInternal(keyRange, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);
@ -1735,10 +1732,9 @@ IndexedDBObjectStoreRequestParent::OpenCursor(const OpenCursorParams& aParams)
{
AutoSetCurrentTransaction asct(mObjectStore->Transaction());
nsresult rv =
mObjectStore->OpenCursorInternal(keyRange, direction, nullptr,
getter_AddRefs(request));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
request = mObjectStore->OpenCursorInternal(keyRange, direction, rv);
ENSURE_SUCCESS(rv, false);
}
request->SetActor(this);

View File

@ -13,7 +13,6 @@ XPIDL_SOURCES += [
'nsIIDBDatabase.idl',
'nsIIDBIndex.idl',
'nsIIDBKeyRange.idl',
'nsIIDBObjectStore.idl',
'nsIIDBOpenDBRequest.idl',
'nsIIDBRequest.idl',
'nsIIndexedDatabaseManager.idl',

View File

@ -6,7 +6,6 @@
#include "nsISupports.idl"
interface nsIIDBObjectStore;
interface nsIIDBRequest;
interface nsIDOMDOMStringList;
interface nsIDOMEventListener;
@ -26,7 +25,7 @@ interface nsIIDBDatabase : nsISupports
readonly attribute nsIDOMDOMStringList objectStoreNames;
[implicit_jscontext]
nsIIDBObjectStore
nsISupports // IDBObjectStore
createObjectStore([Null(Stringify)] in DOMString name,
/* IDBObjectStoreParameters */
[optional /* none */] in jsval options);

View File

@ -6,7 +6,6 @@
#include "nsISupports.idl"
interface nsIIDBObjectStore;
interface nsIIDBRequest;
/**
@ -28,7 +27,8 @@ interface nsIIDBIndex : nsISupports
readonly attribute boolean multiEntry;
readonly attribute nsIIDBObjectStore objectStore;
// This is a IDBObjectStore
readonly attribute nsISupports objectStore;
[implicit_jscontext]
nsIIDBRequest

View File

@ -1,99 +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 nsIIDBIndex;
interface nsIIDBKeyRange;
interface nsIIDBRequest;
interface nsIDOMDOMStringList;
dictionary IDBIndexParameters
{
boolean unique;
boolean multiEntry;
};
/**
* nsIIDBObjectStore interface. See
* http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-nsIIDBObjectStore
* for more information.
*/
[scriptable, builtinclass, uuid(dd189afd-e1b7-4496-bf8d-629c58709595)]
interface nsIIDBObjectStore : nsISupports
{
readonly attribute DOMString name;
[implicit_jscontext]
readonly attribute jsval keyPath;
readonly attribute nsIDOMDOMStringList indexNames;
// IDBTransaction
readonly attribute nsISupports transaction;
readonly attribute boolean autoIncrement;
// Success fires IDBTransactionEvent, result == value for key
[implicit_jscontext]
nsIIDBRequest
get(in jsval key);
// Success fires IDBTransactionEvent, result == array of values for given keys
[implicit_jscontext, optional_argc, binaryname(GetAll)]
nsIIDBRequest
mozGetAll([optional /* null */] in jsval key,
[optional /* unlimited */] in unsigned long limit);
// Success fires IDBTransactionEvent, result == key
[implicit_jscontext, optional_argc]
nsIIDBRequest
add(in jsval value,
[optional /* undefined */] in jsval key);
// Success fires IDBTransactionEvent, result == key
[implicit_jscontext, optional_argc]
nsIIDBRequest
put(in jsval value,
[optional /* undefined */] in jsval key);
// Success fires IDBTransactionEvent, result == null
[implicit_jscontext]
nsIIDBRequest
delete(in jsval key);
// Success fires IDBTransactionEvent, result == null
[implicit_jscontext]
nsIIDBRequest
clear();
// Success fires IDBTransactionEvent, result == IDBCursor or result == null if
// no match.
// direction can be "next", "nextunique", "prev" or "prevunique"
[implicit_jscontext, optional_argc]
nsIIDBRequest
openCursor([optional /* null */] in jsval range,
[optional /* "next" */] in DOMString direction);
[implicit_jscontext]
nsIIDBIndex
createIndex([Null(Stringify)] in DOMString name,
in jsval keyPath,
/* nsIIDBIndexParameters */
[optional /* none */] in jsval options);
// Returns object immediately
nsIIDBIndex
index([Null(Stringify)] in DOMString name);
void
deleteIndex([Null(Stringify)] in DOMString name);
// Accepts null, a key value, or a nsIIDBKeyRange object.
[implicit_jscontext, optional_argc]
nsIIDBRequest
count([optional] in jsval key);
};

View File

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

View File

@ -7,8 +7,6 @@ var testGenerator = testSteps();
function testSteps()
{
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
// Test object stores
const name = "test_complex_keyPaths";

View File

@ -7,7 +7,6 @@ var testGenerator = testSteps();
function testSteps()
{
const IDBObjectStore = Components.interfaces.nsIIDBObjectStore;
const name = this.window ? window.location.pathname : "Splendid Test";
var request = indexedDB.open(name, 1);

View File

@ -7,7 +7,6 @@ var testGenerator = testSteps();
function testSteps()
{
const IDBObjectStore = Components.interfaces.nsIIDBObjectStore;
const name = this.window ? window.location.pathname : "Splendid Test";
var data = [

View File

@ -7,7 +7,6 @@ var testGenerator = testSteps();
function testSteps()
{
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
const name = this.window ? window.location.pathname : "Splendid Test";
const objectStoreName = "Objects";

View File

@ -7,8 +7,6 @@ var testGenerator = testSteps();
function testSteps()
{
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
const name = this.window ? window.location.pathname : "Splendid Test";
const indexName = "My Test Index";

View File

@ -7,8 +7,6 @@ var testGenerator = testSteps();
function testSteps()
{
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
const name = this.window ? window.location.pathname : "Splendid Test";
const objectStoreName = "Objects";

View File

@ -0,0 +1,15 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBCursorDirection
*/
enum IDBCursorDirection {
"next",
"nextunique",
"prev",
"prevunique"
};

View File

@ -0,0 +1,14 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBIndexParameters
*/
dictionary IDBIndexParameters {
boolean unique = false;
boolean multiEntry = false;
};

View File

@ -0,0 +1,65 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*
* The origin of this IDL file is
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBObjectStore
*/
interface IDBRequest;
interface IDBIndex;
interface IDBObjectStore {
readonly attribute DOMString name;
[Throws]
readonly attribute any keyPath;
[Throws]
readonly attribute DOMStringList indexNames;
readonly attribute IDBTransaction transaction;
readonly attribute boolean autoIncrement;
[Throws]
IDBRequest put (any value, optional any key);
[Throws]
IDBRequest add (any value, optional any key);
[Throws]
IDBRequest delete (any key);
[Throws]
IDBRequest get (any key);
[Throws]
IDBRequest clear ();
[Throws]
IDBRequest openCursor (optional any range, optional IDBCursorDirection direction = "next");
// Bug 899972
// IDBIndex createIndex (DOMString name, (DOMString or sequence<DOMString>) keyPath, optional IDBIndexParameters optionalParameters);
[Throws]
IDBIndex createIndex (DOMString name, DOMString keyPath, optional IDBIndexParameters optionalParameters);
[Throws]
IDBIndex createIndex (DOMString name, sequence<DOMString> keyPath, optional IDBIndexParameters optionalParameters);
[Throws]
IDBIndex index (DOMString name);
[Throws]
void deleteIndex (DOMString indexName);
[Throws]
IDBRequest count (optional any key);
};
partial interface IDBObjectStore {
// Success fires IDBTransactionEvent, result == array of values for given keys
[Throws]
IDBRequest mozGetAll (optional any key, optional unsigned long limit);
};

View File

@ -8,8 +8,6 @@
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBTransactionMode
*/
interface IDBObjectStore;
enum IDBTransactionMode {
"readonly",
"readwrite",

View File

@ -164,9 +164,12 @@ webidl_files = \
HTMLTrackElement.webidl \
HTMLUListElement.webidl \
HTMLVideoElement.webidl \
IDBCursor.webidl \
IDBDatabase.webidl \
IDBFactory.webidl \
IDBFileHandle.webidl \
IDBIndex.webidl \
IDBObjectStore.webidl \
IDBTransaction.webidl \
IDBVersionChangeEvent.webidl \
ImageData.webidl \

View File

@ -4,7 +4,6 @@
# Dictionary interface name, interface file name
dictionaries = [
[ 'IDBIndexParameters', 'nsIIDBObjectStore.idl' ],
[ 'GeoPositionOptions', 'nsIDOMGeoGeolocation.idl' ],
[ 'DOMFileMetadataParameters', 'nsIDOMLockedFile.idl' ],
[ 'CameraSize', 'nsIDOMCameraManager.idl' ],

View File

@ -89,7 +89,6 @@ members = [
'nsIIDBDatabase.*',
'nsIIDBIndex.*',
'nsIIDBKeyRange.*',
'nsIIDBObjectStore.*',
'nsIIDBRequest.*',
'nsIIDBOpenDBRequest.*',
'nsIIndexedDatabaseManager.*',

View File

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