Bug 618717 - 'IndexedDB: Fix error codes to match spec changes'. r=sicking, a=blocking.

This commit is contained in:
Ben Turner 2010-12-15 13:21:14 -08:00
parent 97c1f285c2
commit 94c153d868
7 changed files with 62 additions and 24 deletions

View File

@ -94,8 +94,10 @@ DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR, "The operation failed because
DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR, "A mutation operation in the transaction failed due to a because a constraint was not satisfied. For example, an object such as an object store or index already exists and a new one was being attempted to be created.")
DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_DATA_ERR, "Data provided to an operation does not meet requirements.")
DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR, "A mutation operation was attempted on a database that did not allow mutations.")
DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_SERIAL_ERR, "The operation failed because of the size of the data set being returned or because there was a problem in serializing or deserializing the object being processed.")
DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_RECOVERABLE_ERR, " The operation failed because the database was prevented from taking an action. The operation might be able to succeed if the application performs some recovery steps and retries the entire transaction. For example, there was not enough remaining storage space, or the storage quota was reached and the user declined to give more space to the database.")
DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR, "A request was placed against a transaction which is currently not active, or which is finished.")
DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR, "A request was aborted, for example through a call to IDBTransaction.abort.")
DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR, "A mutation operation was attempted in a READ_ONLY transaction.")
DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_RECOVERABLE_ERR, "The operation failed because the database was prevented from taking an action. The operation might be able to succeed if the application performs some recovery steps and retries the entire transaction. For example, there was not enough remaining storage space, or the storage quota was reached and the user declined to give more space to the database.")
DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_TRANSIENT_ERR, "The operation failed because of some temporary problems. The failed operation might be able to succeed when the operation is retried without any intervention by application-level functionality.")
DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_TIMEOUT_ERR, "A lock for the transaction could not be obtained in a reasonable time.")
DOM_MSG_DEF(NS_ERROR_DOM_INDEXEDDB_DEADLOCK_ERR, "The current transaction was automatically rolled back by the database because of deadlock or other transaction serialization failures.")

View File

@ -98,7 +98,10 @@
#define NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,3)
#define NS_ERROR_DOM_INDEXEDDB_DATA_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,4)
#define NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,5)
#define NS_ERROR_DOM_INDEXEDDB_SERIAL_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,11)
#define NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR \
NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,6)
#define NS_ERROR_DOM_INDEXEDDB_ABORT_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,7)
#define NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,11)
#define NS_ERROR_DOM_INDEXEDDB_RECOVERABLE_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,21)
#define NS_ERROR_DOM_INDEXEDDB_TRANSIENT_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,31)
#define NS_ERROR_DOM_INDEXEDDB_TIMEOUT_ERR NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_DOM_INDEXEDDB,32)

View File

@ -415,7 +415,7 @@ IDBCursor::GetValue(JSContext* aCx,
nsCOMPtr<nsIJSON> json(new nsJSON());
rv = json->DecodeToJSVal(mValue, aCx, &mCachedValue);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_SERIAL_ERR);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_DATA_CLONE_ERR);
if (!mValueRooted) {
NS_HOLD_JS_OBJECTS(this, IDBCursor);
@ -435,7 +435,11 @@ IDBCursor::Continue(const jsval &aKey,
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mTransaction->TransactionIsOpen() || mContinueCalled) {
if (!mTransaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
if (mContinueCalled) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
}
@ -510,6 +514,14 @@ IDBCursor::Update(const jsval& aValue,
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mTransaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
if (!mTransaction->IsWriteAllowed()) {
return NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR;
}
if (mType == INDEXKEY) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
}
@ -565,6 +577,14 @@ IDBCursor::Delete(JSContext* aCx,
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mTransaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
if (!mTransaction->IsWriteAllowed()) {
return NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR;
}
if (mType == INDEXKEY) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
}

View File

@ -723,7 +723,6 @@ IDBDatabase::Transaction(nsIVariant* aStoreNames,
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!info->ContainsStoreName(name)) {
// XXX Update spec for a real error code here.
return NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR;
}

View File

@ -354,7 +354,7 @@ IDBIndex::Get(nsIVariant* aKey,
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
Key key;
@ -386,7 +386,7 @@ IDBIndex::GetKey(nsIVariant* aKey,
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
Key key;
@ -422,7 +422,7 @@ IDBIndex::GetAll(nsIVariant* aKey,
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
nsresult rv;
@ -466,7 +466,7 @@ IDBIndex::GetAllKeys(nsIVariant* aKey,
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
nsresult rv;
@ -510,7 +510,7 @@ IDBIndex::OpenCursor(nsIIDBKeyRange* aKeyRange,
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
nsresult rv;
@ -578,7 +578,7 @@ IDBIndex::OpenKeyCursor(nsIIDBKeyRange* aKeyRange,
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
nsresult rv;

View File

@ -785,7 +785,7 @@ IDBObjectStore::GetAddInfo(JSContext* aCx,
nsCOMPtr<nsIJSON> json(new nsJSON());
rv = json->EncodeFromJSVal(&aValue, aCx, aJSON);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_SERIAL_ERR);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_DATA_CLONE_ERR);
return NS_OK;
}
@ -800,8 +800,12 @@ IDBObjectStore::AddOrPut(const jsval& aValue,
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mTransaction->TransactionIsOpen() || !IsWriteAllowed()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
if (!mTransaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
if (!IsWriteAllowed()) {
return NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR;
}
jsval keyval = (aOptionalArgCount >= 1) ? aKey : JSVAL_VOID;
@ -924,7 +928,7 @@ IDBObjectStore::Get(nsIVariant* aKey,
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mTransaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
Key key;
@ -958,7 +962,7 @@ IDBObjectStore::GetAll(nsIIDBKeyRange* aKeyRange,
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mTransaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
if (aOptionalArgCount < 2) {
@ -1039,8 +1043,12 @@ IDBObjectStore::Delete(const jsval& aKey,
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mTransaction->TransactionIsOpen() || !IsWriteAllowed()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
if (!mTransaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
if (!IsWriteAllowed()) {
return NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR;
}
Key key;
@ -1071,8 +1079,12 @@ IDBObjectStore::Clear(nsIIDBRequest** _retval)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mTransaction->TransactionIsOpen() || !IsWriteAllowed()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
if (!mTransaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
if (!IsWriteAllowed()) {
return NS_ERROR_DOM_INDEXEDDB_READ_ONLY_ERR;
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
@ -1096,7 +1108,7 @@ IDBObjectStore::OpenCursor(nsIIDBKeyRange* aKeyRange,
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!mTransaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
nsresult rv;
@ -1248,7 +1260,7 @@ IDBObjectStore::Index(const nsAString& aName,
NS_PRECONDITION(NS_IsMainThread(), "Wrong thread!");
if (!mTransaction->TransactionIsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
if (aName.IsEmpty()) {

View File

@ -48,7 +48,9 @@ interface nsIIDBDatabaseException : nsISupports
const unsigned short CONSTRAINT_ERR = 3;
const unsigned short DATA_ERR = 4;
const unsigned short NOT_ALLOWED_ERR = 5;
const unsigned short SERIAL_ERR = 11;
const unsigned short TRANSACTION_INACTIVE_ERR = 6;
const unsigned short ABORT_ERR = 7;
const unsigned short READ_ONLY_ERR = 11;
const unsigned short RECOVERABLE_ERR = 21;
const unsigned short TRANSIENT_ERR = 31;
const unsigned short TIMEOUT_ERR = 32;