Bug 958359 - IndexedDB should log a message to the console when it returns NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR. r=bent

This commit is contained in:
Ted Clancy 2014-01-27 19:37:05 -05:00
parent f1d0bcf182
commit 64a7be3a28
14 changed files with 395 additions and 267 deletions

View File

@ -20,6 +20,7 @@
#include "IDBTransaction.h"
#include "IndexedDatabaseManager.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "TransactionThreadPool.h"
#include "ipc/IndexedDBChild.h"
@ -59,13 +60,13 @@ ConvertCloneReadInfosToArrayInternal(
{
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
if (!array) {
NS_WARNING("Failed to make array!");
IDB_WARNING("Failed to make array!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
if (!aReadInfos.IsEmpty()) {
if (!JS_SetArrayLength(aCx, array, uint32_t(aReadInfos.Length()))) {
NS_WARNING("Failed to set array length!");
IDB_WARNING("Failed to set array length!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -80,7 +81,7 @@ ConvertCloneReadInfosToArrayInternal(
}
if (!JS_SetElement(aCx, array, index, val)) {
NS_WARNING("Failed to set array element!");
IDB_WARNING("Failed to set array element!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
}
@ -126,7 +127,7 @@ HelperBase::WrapNative(JSContext* aCx,
nsresult rv =
nsContentUtils::WrapNative(aCx, global, aNative, aResult);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -246,7 +247,7 @@ AsyncConnectionHelper::Run()
}
case Error: {
NS_WARNING("MaybeSendResultsToChildProcess failed!");
IDB_WARNING("MaybeSendResultsToChildProcess failed!");
mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
if (mRequest) {
mRequest->NotifyHelperSentResultsToChildProcess(mResultCode);
@ -341,6 +342,7 @@ AsyncConnectionHelper::Run()
mResultCode = NS_ERROR_DOM_INDEXEDDB_RECOVERABLE_ERR;
}
else {
IDB_REPORT_INTERNAL_ERR();
mResultCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
}
@ -459,13 +461,13 @@ AsyncConnectionHelper::OnSuccess()
nsRefPtr<nsIDOMEvent> event = CreateSuccessEvent(mRequest);
if (!event) {
NS_ERROR("Failed to create event!");
IDB_WARNING("Failed to create event!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
bool dummy;
nsresult rv = mRequest->DispatchEvent(event, &dummy);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
WidgetEvent* internalEvent = event->GetInternalNSEvent();
NS_ASSERTION(internalEvent, "This should never be null!");

View File

@ -20,6 +20,7 @@
#include "IDBObjectStore.h"
#include "IDBTransaction.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "TransactionThreadPool.h"
#include "ipc/IndexedDBChild.h"
@ -497,7 +498,7 @@ IDBCursor::ContinueInternal(const Key& aKey, int32_t aCount, ErrorResult& aRv)
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return;
}
@ -998,6 +999,7 @@ CursorHelper::Dispatch(nsIEventTarget* aDatabaseThread)
// If we've been invalidated then there's no point sending anything to the
// parent process.
if (mCursor->Transaction()->Database()->IsInvalidated()) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1006,11 +1008,11 @@ CursorHelper::Dispatch(nsIEventTarget* aDatabaseThread)
CursorRequestParams params;
nsresult rv = PackArgumentsForParentProcess(params);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NoDispatchEventTarget target;
rv = AsyncConnectionHelper::Dispatch(&target);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mActor = new IndexedDBCursorRequestChild(this, mCursor, params.type());
cursorActor->SendPIndexedDBRequestConstructor(mActor, params);
@ -1046,19 +1048,19 @@ ContinueHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
query.AppendInt(mCount);
nsCOMPtr<mozIStorageStatement> stmt = mTransaction->GetCachedStatement(query);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = BindArgumentsToStatement(stmt);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ASSERTION(mCount > 0, "Not ok!");
bool hasResult;
for (int32_t index = 0; index < mCount; index++) {
rv = stmt->ExecuteStep(&hasResult);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!hasResult) {
break;
@ -1067,7 +1069,7 @@ ContinueHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
if (hasResult) {
rv = GatherResultsFromStatement(stmt);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
else {
mKey.Unset();
@ -1193,7 +1195,7 @@ ContinueHelper::UnpackResponseFromParentProcess(
"Inconsistent clone info!");
if (!mCloneReadInfo.SetFromSerialized(cloneInfo)) {
NS_WARNING("Failed to copy clone buffer!");
IDB_WARNING("Failed to copy clone buffer!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1212,7 +1214,7 @@ ContinueObjectStoreHelper::BindArgumentsToStatement(
// Bind object store id.
nsresult rv = aStatement->BindInt64ByName(NS_LITERAL_CSTRING("id"),
mCursor->mObjectStore->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_NAMED_LITERAL_CSTRING(currentKeyName, "current_key");
NS_NAMED_LITERAL_CSTRING(rangeKeyName, "range_key");
@ -1274,7 +1276,7 @@ ContinueIndexHelper::BindArgumentsToStatement(mozIStorageStatement* aStatement)
// Bind index id.
nsresult rv = aStatement->BindInt64ByName(NS_LITERAL_CSTRING("id"),
mCursor->mIndex->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_NAMED_LITERAL_CSTRING(currentKeyName, "current_key");

View File

@ -29,6 +29,7 @@
#include "IDBTransaction.h"
#include "IDBFactory.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "TransactionThreadPool.h"
#include "ipc/IndexedDBChild.h"
@ -418,7 +419,7 @@ IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction,
newInfo->comittedAutoIncrementId = newInfo->nextAutoIncrementId;
if (!databaseInfo->PutObjectStore(newInfo)) {
NS_WARNING("Put failed!");
IDB_WARNING("Put failed!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -429,7 +430,7 @@ IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction,
nsRefPtr<IDBObjectStore> objectStore =
aTransaction->GetOrCreateObjectStore(newInfo->name, newInfo, true);
if (!objectStore) {
NS_WARNING("Failed to get objectStore!");
IDB_WARNING("Failed to get objectStore!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -440,7 +441,7 @@ IDBDatabase::CreateObjectStoreInternal(IDBTransaction* aTransaction,
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -502,7 +503,7 @@ IDBDatabase::GetObjectStoreNames(ErrorResult& aRv) const
nsAutoTArray<nsString, 10> objectStoreNames;
if (!info->GetObjectStoreNames(objectStoreNames)) {
NS_WARNING("Couldn't get names!");
IDB_WARNING("Couldn't get names!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -511,7 +512,7 @@ IDBDatabase::GetObjectStoreNames(ErrorResult& aRv) const
uint32_t count = objectStoreNames.Length();
for (uint32_t index = 0; index < count; index++) {
if (!list->Add(objectStoreNames[index])) {
NS_WARNING("Failed to add element");
IDB_WARNING("Failed to add element");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -590,7 +591,7 @@ IDBDatabase::DeleteObjectStore(const nsAString& aName, ErrorResult& aRv)
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return;
}
@ -619,6 +620,7 @@ IDBDatabase::Transaction(const Sequence<nsString>& aStoreNames,
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (QuotaManager::IsShuttingDown()) {
IDB_REPORT_INTERNAL_ERR();
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -665,7 +667,7 @@ IDBDatabase::Transaction(const Sequence<nsString>& aStoreNames,
nsRefPtr<IDBTransaction> transaction =
IDBTransaction::Create(this, aStoreNames, transactionMode, false);
if (!transaction) {
NS_WARNING("Failed to create the transaction!");
IDB_WARNING("Failed to create the transaction!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -686,12 +688,13 @@ IDBDatabase::MozCreateFileHandle(const nsAString& aName,
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (!IndexedDatabaseManager::IsMainProcess()) {
NS_WARNING("Not supported yet!");
IDB_WARNING("Not supported yet!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
if (QuotaManager::IsShuttingDown()) {
IDB_REPORT_INTERNAL_ERR();
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -712,7 +715,7 @@ IDBDatabase::MozCreateFileHandle(const nsAString& aName,
nsresult rv = helper->Dispatch(quotaManager->IOThread());
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -834,20 +837,20 @@ CreateObjectStoreHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
"INSERT INTO object_store (id, auto_increment, name, key_path) "
"VALUES (:id, :auto_increment, :name, :key_path)"
));
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"),
mObjectStore->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("auto_increment"),
mObjectStore->IsAutoIncrement() ? 1 : 0);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), mObjectStore->Name());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
const KeyPath& keyPath = mObjectStore->GetKeyPath();
if (keyPath.IsValid()) {
@ -855,15 +858,15 @@ CreateObjectStoreHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
keyPath.SerializeToString(keyPathSerialization);
rv = stmt->BindStringByName(NS_LITERAL_CSTRING("key_path"),
keyPathSerialization);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
else {
rv = stmt->BindNullByName(NS_LITERAL_CSTRING("key_path"));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
rv = stmt->Execute();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -888,15 +891,15 @@ DeleteObjectStoreHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
"DELETE FROM object_store "
"WHERE id = :id "
));
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mObjectStoreId);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = stmt->Execute();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -917,7 +920,7 @@ CreateFileHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
FileManager* fileManager = mDatabase->Manager();
mFileInfo = fileManager->GetNewFileInfo();
NS_ENSURE_TRUE(mFileInfo, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(mFileInfo, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
const int64_t& fileId = mFileInfo->Id();
@ -931,13 +934,13 @@ CreateFileHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
NS_ENSURE_SUCCESS(rv, rv);
directory = fileManager->GetDirectory();
NS_ENSURE_TRUE(directory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(directory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
file = fileManager->GetFileForId(directory, fileId);
NS_ENSURE_TRUE(file, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(file, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = file->Create(nsIFile::NORMAL_FILE_TYPE, 0644);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -948,7 +951,7 @@ CreateFileHelper::GetSuccessResult(JSContext* aCx,
{
nsRefPtr<IDBFileHandle> fileHandle =
IDBFileHandle::Create(mDatabase, mName, mType, mFileInfo.forget());
NS_ENSURE_TRUE(fileHandle, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(fileHandle, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return WrapNative(aCx, NS_ISUPPORTS_CAST(nsIDOMFileHandle*, fileHandle),
aVal);

View File

@ -44,6 +44,7 @@
#include "IndexedDatabaseManager.h"
#include "Key.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "nsNetUtil.h"
#include "ipc/IndexedDBChild.h"
@ -109,18 +110,18 @@ IDBFactory::Create(nsPIDOMWindow* aWindow,
NS_ASSERTION(aASCIIOrigin.IsEmpty() || nsContentUtils::IsCallerChrome(),
"Non-chrome may not supply their own origin!");
NS_ENSURE_TRUE(aWindow, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(aWindow, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (aWindow->IsOuterWindow()) {
aWindow = aWindow->GetCurrentInnerWindow();
NS_ENSURE_TRUE(aWindow, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(aWindow, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
// Make sure that the manager is up before we do anything here since lots of
// decisions depend on which process we're running in.
indexedDB::IndexedDatabaseManager* mgr =
indexedDB::IndexedDatabaseManager::GetOrCreate();
NS_ENSURE_TRUE(mgr, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(mgr, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsresult rv;
@ -154,7 +155,7 @@ IDBFactory::Create(nsPIDOMWindow* aWindow,
if (!IndexedDatabaseManager::IsMainProcess()) {
TabChild* tabChild = TabChild::GetFrom(aWindow);
NS_ENSURE_TRUE(tabChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(tabChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IndexedDBChild* actor = new IndexedDBChild(origin);
@ -191,7 +192,7 @@ IDBFactory::Create(JSContext* aCx,
// Make sure that the manager is up before we do anything here since lots of
// decisions depend on which process we're running in.
IndexedDatabaseManager* mgr = IndexedDatabaseManager::GetOrCreate();
NS_ENSURE_TRUE(mgr, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(mgr, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsCString group;
nsCString origin;
@ -213,7 +214,7 @@ IDBFactory::Create(JSContext* aCx,
if (!IndexedDatabaseManager::IsMainProcess()) {
ContentChild* contentChild = ContentChild::GetSingleton();
NS_ENSURE_TRUE(contentChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(contentChild, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IndexedDBChild* actor = new IndexedDBChild(origin);
@ -372,7 +373,7 @@ IDBFactory::SetDefaultPragmas(mozIStorageConnection* aConnection)
"PRAGMA recursive_triggers = ON;";
nsresult rv = aConnection->ExecuteSimpleSQL(NS_LITERAL_CSTRING(query));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -611,7 +612,7 @@ IDBFactory::OpenInternal(const nsAString& aName,
nsRefPtr<IDBOpenDBRequest> request =
IDBOpenDBRequest::Create(this, window, scriptOwner);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsresult rv;
@ -622,7 +623,7 @@ IDBFactory::OpenInternal(const nsAString& aName,
aPrivilege);
rv = openHelper->Init();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!Preferences::GetBool(PREF_INDEXEDDB_ENABLED)) {
openHelper->SetError(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
@ -647,7 +648,7 @@ IDBFactory::OpenInternal(const nsAString& aName,
rv = openHelper->WaitForOpenAllowed();
}
}
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
else if (aDeleting) {
nsCString databaseId;
@ -798,6 +799,7 @@ IDBFactory::Open(nsIPrincipal* aPrincipal, const nsAString& aName,
&privilege,
&defaultPersistenceType);
if (NS_FAILED(rv)) {
IDB_REPORT_INTERNAL_ERR();
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}

View File

@ -25,6 +25,7 @@
#include "IDBObjectStore.h"
#include "IDBTransaction.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "ipc/IndexedDBChild.h"
#include "ipc/IndexedDBParent.h"
@ -438,7 +439,7 @@ IDBIndex::GetInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -448,7 +449,7 @@ IDBIndex::GetInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -480,7 +481,7 @@ IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -490,7 +491,7 @@ IDBIndex::GetKeyInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -523,7 +524,7 @@ IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange, uint32_t aLimit,
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -533,7 +534,7 @@ IDBIndex::GetAllInternal(IDBKeyRange* aKeyRange, uint32_t aLimit,
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -567,7 +568,7 @@ IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit,
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -577,7 +578,7 @@ IDBIndex::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit,
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -610,7 +611,7 @@ IDBIndex::CountInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -620,7 +621,7 @@ IDBIndex::CountInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -656,7 +657,7 @@ IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection,
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -666,7 +667,7 @@ IDBIndex::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection,
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -702,13 +703,13 @@ IDBIndex::OpenCursorInternal(IDBKeyRange* aKeyRange,
static_cast<IDBCursor::Direction>(aDirection);
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsRefPtr<OpenCursorHelper> helper =
new OpenCursorHelper(transaction, request, this, aKeyRange, direction);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_PROFILER_MARK("IndexedDB Request %llu: "
"database(%s).transaction(%s).objectStore(%s).index(%s)."
@ -741,7 +742,7 @@ IDBIndex::OpenCursorFromChildProcess(IDBRequest* aRequest,
nsRefPtr<IDBCursor> cursor =
IDBCursor::Create(aRequest, mObjectStore->Transaction(), this, direction,
Key(), EmptyCString(), EmptyCString(), aKey, aObjectKey);
NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
cursor.forget(_retval);
return NS_OK;
@ -768,7 +769,7 @@ IDBIndex::OpenCursorFromChildProcess(
StructuredCloneReadInfo cloneInfo;
if (!cloneInfo.SetFromSerialized(aCloneInfo)) {
NS_WARNING("Failed to copy clone buffer!");
IDB_WARNING("Failed to copy clone buffer!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -778,7 +779,7 @@ IDBIndex::OpenCursorFromChildProcess(
IDBCursor::Create(aRequest, mObjectStore->Transaction(), this, direction,
Key(), EmptyCString(), EmptyCString(), aKey, aObjectKey,
cloneInfo);
NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ASSERTION(!cloneInfo.mCloneBuffer.data(), "Should have swapped!");
@ -969,7 +970,7 @@ IDBIndex::OpenCursor(JSContext* aCx,
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -979,7 +980,7 @@ IDBIndex::OpenCursor(JSContext* aCx,
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -1051,6 +1052,7 @@ IndexHelper::Dispatch(nsIEventTarget* aDatabaseThread)
// If we've been invalidated then there's no point sending anything to the
// parent process.
if (mIndex->ObjectStore()->Transaction()->Database()->IsInvalidated()) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1059,11 +1061,11 @@ IndexHelper::Dispatch(nsIEventTarget* aDatabaseThread)
IndexRequestParams params;
nsresult rv = PackArgumentsForParentProcess(params);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NoDispatchEventTarget target;
rv = AsyncConnectionHelper::Dispatch(&target);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mActor = new IndexedDBIndexRequestChild(this, mIndex, params.type());
indexActor->SendPIndexedDBRequestConstructor(mActor, params);
@ -1100,20 +1102,20 @@ GetKeyHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
NS_LITERAL_CSTRING(" LIMIT 1");
nsCOMPtr<mozIStorageStatement> stmt = mTransaction->GetCachedStatement(query);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("index_id"),
mIndex->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
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);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (hasResult) {
rv = mKey.SetFromStatement(stmt, 0);
@ -1226,20 +1228,20 @@ GetHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
NS_LITERAL_CSTRING(" LIMIT 1");
nsCOMPtr<mozIStorageStatement> stmt = mTransaction->GetCachedStatement(query);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("index_id"),
mIndex->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
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);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (hasResult) {
rv = IDBObjectStore::GetStructuredCloneReadInfoFromStatement(stmt, 0, 1,
@ -1355,7 +1357,7 @@ GetHelper::UnpackResponseFromParentProcess(const ResponseValue& aResponseValue)
"Inconsistent clone info!");
if (!mCloneReadInfo.SetFromSerialized(cloneInfo)) {
NS_WARNING("Failed to copy clone buffer!");
IDB_WARNING("Failed to copy clone buffer!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1398,13 +1400,13 @@ GetAllKeysHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
keyRangeClause + limitClause;
nsCOMPtr<mozIStorageStatement> stmt = mTransaction->GetCachedStatement(query);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("index_id"),
mIndex->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (mKeyRange) {
rv = mKeyRange->BindToStatement(stmt);
@ -1425,7 +1427,7 @@ GetAllKeysHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
rv = key->SetFromStatement(stmt, 0);
NS_ENSURE_SUCCESS(rv, rv);
}
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -1446,13 +1448,13 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
if (!array) {
NS_WARNING("Failed to make array!");
IDB_WARNING("Failed to make array!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
if (!keys.IsEmpty()) {
if (!JS_SetArrayLength(aCx, array, uint32_t(keys.Length()))) {
NS_WARNING("Failed to set array length!");
IDB_WARNING("Failed to set array length!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1468,7 +1470,7 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
}
if (!JS_SetElement(aCx, array, index, value)) {
NS_WARNING("Failed to set array element!");
IDB_WARNING("Failed to set array element!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
}
@ -1582,13 +1584,13 @@ GetAllHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
keyRangeClause + limitClause;
nsCOMPtr<mozIStorageStatement> stmt = mTransaction->GetCachedStatement(query);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("index_id"),
mIndex->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (mKeyRange) {
rv = mKeyRange->BindToStatement(stmt);
@ -1610,7 +1612,7 @@ GetAllHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
mDatabase, *readInfo);
NS_ENSURE_SUCCESS(rv, rv);
}
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -1761,7 +1763,7 @@ GetAllHelper::UnpackResponseFromParentProcess(
StructuredCloneReadInfo* destInfo = mCloneReadInfos.AppendElement();
if (!destInfo->SetFromSerialized(srcInfo)) {
NS_WARNING("Failed to copy clone buffer!");
IDB_WARNING("Failed to copy clone buffer!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1821,13 +1823,13 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
nsCOMPtr<mozIStorageStatement> stmt =
mTransaction->GetCachedStatement(firstQuery);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("index_id"),
mIndex->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (mKeyRange) {
rv = mKeyRange->BindToStatement(stmt);
@ -1836,7 +1838,7 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
bool hasResult;
rv = stmt->ExecuteStep(&hasResult);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!hasResult) {
mKey.Unset();
@ -1949,7 +1951,7 @@ OpenKeyCursorHelper::EnsureCursor()
nsRefPtr<IDBCursor> cursor =
IDBCursor::Create(mRequest, mTransaction, mIndex, mDirection, mRangeKey,
mContinueQuery, mContinueToQuery, mKey, mObjectKey);
NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mCursor.swap(cursor);
return NS_OK;
@ -1964,7 +1966,7 @@ OpenKeyCursorHelper::GetSuccessResult(JSContext* aCx,
if (mCursor) {
rv = WrapNative(aCx, mCursor, aVal);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
else {
aVal.setUndefined();
@ -2099,8 +2101,7 @@ OpenKeyCursorHelper::UnpackResponseFromParentProcess(
} break;
default:
NS_NOTREACHED("Unknown response union type!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
MOZ_CRASH();
}
return NS_OK;
@ -2166,12 +2167,12 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
nsCOMPtr<mozIStorageStatement> stmt =
mTransaction->GetCachedStatement(firstQuery);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mIndex->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (mKeyRange) {
rv = mKeyRange->BindToStatement(stmt);
@ -2180,7 +2181,7 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
bool hasResult;
rv = stmt->ExecuteStep(&hasResult);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!hasResult) {
mKey.Unset();
@ -2304,7 +2305,7 @@ OpenCursorHelper::EnsureCursor()
IDBCursor::Create(mRequest, mTransaction, mIndex, mDirection, mRangeKey,
mContinueQuery, mContinueToQuery, mKey, mObjectKey,
mCloneReadInfo);
NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ASSERTION(!mCloneReadInfo.mCloneBuffer.data(), "Should have swapped!");
@ -2477,12 +2478,12 @@ CountHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
keyRangeClause;
nsCOMPtr<mozIStorageStatement> stmt = mTransaction->GetCachedStatement(query);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"), mIndex->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (mKeyRange) {
if (!mKeyRange->Lower().IsUnset()) {
@ -2497,8 +2498,8 @@ CountHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
bool hasResult;
rv = stmt->ExecuteStep(&hasResult);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ENSURE_TRUE(hasResult, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(hasResult, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mCount = stmt->AsInt64(0);
return NS_OK;

View File

@ -42,6 +42,7 @@
#include "DictionaryHelpers.h"
#include "KeyPath.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "ipc/IndexedDBChild.h"
#include "ipc/IndexedDBParent.h"
@ -1047,12 +1048,14 @@ IDBObjectStore::AppendIndexUpdateInfo(
JS::Rooted<JSObject*> array(aCx, JSVAL_TO_OBJECT(val));
uint32_t arrayLength;
if (!JS_GetArrayLength(aCx, array, &arrayLength)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
for (uint32_t arrayIndex = 0; arrayIndex < arrayLength; arrayIndex++) {
JS::Rooted<JS::Value> arrayItem(aCx);
if (!JS_GetElement(aCx, array, arrayIndex, &arrayItem)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1219,7 +1222,7 @@ IDBObjectStore::GetStructuredCloneReadInfoFromStatement(
uint32_t blobDataLength;
nsresult rv = aStatement->GetSharedBlob(aDataIndex, &blobDataLength,
&blobData);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
const char* compressed = reinterpret_cast<const char*>(blobData);
size_t compressedLength = size_t(blobDataLength);
@ -1229,7 +1232,7 @@ IDBObjectStore::GetStructuredCloneReadInfoFromStatement(
size_t uncompressedLength;
if (!snappy::GetUncompressedLength(compressed, compressedLength,
&uncompressedLength)) {
NS_WARNING("Snappy can't determine uncompressed length!");
IDB_WARNING("Snappy can't determine uncompressed length!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1238,28 +1241,29 @@ IDBObjectStore::GetStructuredCloneReadInfoFromStatement(
if (!snappy::RawUncompress(compressed, compressedLength,
uncompressed.get())) {
NS_WARNING("Snappy can't determine uncompressed length!");
IDB_WARNING("Snappy can't determine uncompressed length!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
JSAutoStructuredCloneBuffer& buffer = aInfo.mCloneBuffer;
if (!buffer.copy(reinterpret_cast<const uint64_t *>(uncompressed.get()),
uncompressedLength)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
bool isNull;
rv = aStatement->GetIsNull(aFileIdsIndex, &isNull);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!isNull) {
nsString ids;
rv = aStatement->GetString(aFileIdsIndex, ids);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsAutoTArray<int64_t, 10> array;
rv = ConvertFileIdsToArray(ids, array);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
FileManager* fileManager = aDatabase->Manager();
@ -1770,7 +1774,7 @@ IDBObjectStore::ConvertBlobsToActors(
if (!aFiles.IsEmpty()) {
nsCOMPtr<nsIFile> directory = aFileManager->GetDirectory();
if (!directory) {
NS_WARNING("Failed to get directory!");
IDB_WARNING("Failed to get directory!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1784,7 +1788,7 @@ IDBObjectStore::ConvertBlobsToActors(
nsCOMPtr<nsIFile> nativeFile =
aFileManager->GetFileForId(directory, file.mFileInfo->Id());
if (!nativeFile) {
NS_WARNING("Failed to get file!");
IDB_WARNING("Failed to get file!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1794,6 +1798,7 @@ IDBObjectStore::ConvertBlobsToActors(
aContentParent->GetOrCreateActorForBlob(blob);
if (!actor) {
// This can only fail if the child has crashed.
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1931,7 +1936,7 @@ IDBObjectStore::AddOrPut(JSContext* aCx, JS::Handle<JS::Value> aValue,
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -1942,7 +1947,7 @@ IDBObjectStore::AddOrPut(JSContext* aCx, JS::Handle<JS::Value> aValue,
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -1994,11 +1999,11 @@ IDBObjectStore::AddOrPutInternal(
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
StructuredCloneWriteInfo cloneWriteInfo;
if (!cloneWriteInfo.SetFromSerialized(aCloneWriteInfo)) {
NS_WARNING("Failed to copy structured clone buffer!");
IDB_WARNING("Failed to copy structured clone buffer!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -2021,12 +2026,12 @@ IDBObjectStore::AddOrPutInternal(
if (!fileInfo) {
fileInfo = fileManager->GetNewFileInfo();
if (!fileInfo) {
NS_WARNING("Failed to get new file info!");
IDB_WARNING("Failed to get new file info!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
if (NS_FAILED(blob->GetInternalStream(getter_AddRefs(inputStream)))) {
NS_WARNING("Failed to get internal steam!");
IDB_WARNING("Failed to get internal steam!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -2053,7 +2058,7 @@ IDBObjectStore::AddOrPutInternal(
updateInfo);
nsresult rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
#ifdef IDB_PROFILER_USE_MARKS
if (aOverwrite) {
@ -2095,7 +2100,7 @@ IDBObjectStore::GetInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2105,7 +2110,7 @@ IDBObjectStore::GetInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2134,7 +2139,7 @@ IDBObjectStore::GetAllInternal(IDBKeyRange* aKeyRange,
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2144,7 +2149,7 @@ IDBObjectStore::GetAllInternal(IDBKeyRange* aKeyRange,
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2175,7 +2180,7 @@ IDBObjectStore::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit,
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2185,7 +2190,7 @@ IDBObjectStore::GetAllKeysInternal(IDBKeyRange* aKeyRange, uint32_t aLimit,
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2222,7 +2227,7 @@ IDBObjectStore::DeleteInternal(IDBKeyRange* aKeyRange,
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2232,7 +2237,7 @@ IDBObjectStore::DeleteInternal(IDBKeyRange* aKeyRange,
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2265,7 +2270,7 @@ IDBObjectStore::Clear(ErrorResult& aRv)
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2274,7 +2279,7 @@ IDBObjectStore::Clear(ErrorResult& aRv)
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2302,7 +2307,7 @@ IDBObjectStore::CountInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2311,7 +2316,7 @@ IDBObjectStore::CountInternal(IDBKeyRange* aKeyRange, ErrorResult& aRv)
new CountHelper(mTransaction, request, this, aKeyRange);
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2343,7 +2348,7 @@ IDBObjectStore::OpenCursorInternal(IDBKeyRange* aKeyRange,
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2353,7 +2358,7 @@ IDBObjectStore::OpenCursorInternal(IDBKeyRange* aKeyRange,
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2391,7 +2396,7 @@ IDBObjectStore::OpenCursorFromChildProcess(
StructuredCloneReadInfo cloneInfo;
if (!cloneInfo.SetFromSerialized(aCloneInfo)) {
NS_WARNING("Failed to copy clone buffer!");
IDB_WARNING("Failed to copy clone buffer!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -2400,7 +2405,7 @@ IDBObjectStore::OpenCursorFromChildProcess(
nsRefPtr<IDBCursor> cursor =
IDBCursor::Create(aRequest, mTransaction, this, direction, Key(),
EmptyCString(), EmptyCString(), aKey, cloneInfo);
NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ASSERTION(!cloneInfo.mCloneBuffer.data(), "Should have swapped!");
@ -2422,7 +2427,7 @@ IDBObjectStore::OpenCursorFromChildProcess(IDBRequest* aRequest,
nsRefPtr<IDBCursor> cursor =
IDBCursor::Create(aRequest, mTransaction, this, direction, Key(),
EmptyCString(), EmptyCString(), aKey);
NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
cursor.forget(_retval);
return NS_OK;
@ -2441,7 +2446,7 @@ IDBObjectStore::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection,
nsRefPtr<IDBRequest> request = GenerateRequest(this);
if (!request) {
NS_WARNING("Failed to generate request!");
IDB_WARNING("Failed to generate request!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2453,7 +2458,7 @@ IDBObjectStore::OpenKeyCursorInternal(IDBKeyRange* aKeyRange, size_t aDirection,
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2506,7 +2511,7 @@ IDBObjectStore::CreateIndexInternal(const IndexInfo& aInfo, ErrorResult& aRv)
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2561,13 +2566,13 @@ IDBObjectStore::Index(const nsAString& aName, ErrorResult &aRv)
if (!retval) {
retval = IDBIndex::Create(this, indexInfo, false);
if (!retval) {
NS_WARNING("Failed to create index!");
IDB_WARNING("Failed to create index!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
if (!mCreatedIndexes.AppendElement(retval)) {
NS_WARNING("Out of memory!");
IDB_WARNING("Out of memory!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2659,7 +2664,7 @@ IDBObjectStore::GetIndexNames(ErrorResult& aRv)
for (uint32_t index = 0; index < count; index++) {
if (!list->Add(names[index])) {
NS_WARNING("Failed to add element!");
IDB_WARNING("Failed to add element!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -2903,7 +2908,7 @@ IDBObjectStore::DeleteIndex(const nsAString& aName, ErrorResult& aRv)
nsresult rv = helper->DispatchToTransactionPool();
if (NS_FAILED(rv)) {
NS_WARNING("Failed to dispatch!");
IDB_WARNING("Failed to dispatch!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return;
}
@ -3016,7 +3021,7 @@ CopyData(nsIInputStream* aInputStream, nsIOutputStream* aOutputStream)
uint32_t numRead;
rv = aInputStream->Read(copyBuffer, sizeof(copyBuffer), &numRead);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!numRead) {
break;
@ -3024,7 +3029,7 @@ CopyData(nsIInputStream* aInputStream, nsIOutputStream* aOutputStream)
uint32_t numWrite;
rv = aOutputStream->Write(copyBuffer, numRead, &numWrite);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (numWrite < numRead) {
// Must have hit the quota limit.
@ -3033,7 +3038,7 @@ CopyData(nsIInputStream* aInputStream, nsIOutputStream* aOutputStream)
} while (true);
rv = aOutputStream->Flush();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -3059,6 +3064,7 @@ ObjectStoreHelper::Dispatch(nsIEventTarget* aDatabaseThread)
// If we've been invalidated then there's no point sending anything to the
// parent process.
if (mObjectStore->Transaction()->Database()->IsInvalidated()) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -3067,11 +3073,11 @@ ObjectStoreHelper::Dispatch(nsIEventTarget* aDatabaseThread)
ObjectStoreRequestParams params;
nsresult rv = PackArgumentsForParentProcess(params);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NoDispatchEventTarget target;
rv = AsyncConnectionHelper::Dispatch(&target);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mActor =
new IndexedDBObjectStoreRequestChild(this, mObjectStore, params.type());
@ -3092,8 +3098,7 @@ nsresult
NoRequestObjectStoreHelper::UnpackResponseFromParentProcess(
const ResponseValue& aResponseValue)
{
NS_NOTREACHED("Should never get here!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
MOZ_CRASH();
}
AsyncConnectionHelper::ChildProcessSendResult
@ -3160,12 +3165,12 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
"INSERT OR REPLACE INTO object_data (object_store_id, key_value, data, "
"file_ids) "
"VALUES (:osid, :key_value, :data, :file_ids)");
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), osid);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ASSERTION(!keyUnset || mObjectStore->IsAutoIncrement(),
"Should have key unless autoincrement");
@ -3180,6 +3185,7 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
"Generated key must always be a positive integer");
if (autoIncrementNum > (1LL << 53)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -3225,7 +3231,7 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
rv = stmt->BindBlobByName(NS_LITERAL_CSTRING("data"), dataBuffer,
dataBufferLength);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
// Handle blobs
uint32_t length = mCloneWriteInfo.mFiles.Length();
@ -3233,10 +3239,10 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
nsRefPtr<FileManager> fileManager = mDatabase->Manager();
nsCOMPtr<nsIFile> directory = fileManager->GetDirectory();
NS_ENSURE_TRUE(directory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(directory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsCOMPtr<nsIFile> journalDirectory = fileManager->EnsureJournalDirectory();
NS_ENSURE_TRUE(journalDirectory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(journalDirectory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsAutoString fileIds;
@ -3251,20 +3257,20 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
// Create a journal file first
nsCOMPtr<nsIFile> nativeFile =
fileManager->GetFileForId(journalDirectory, id);
NS_ENSURE_TRUE(nativeFile, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(nativeFile, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = nativeFile->Create(nsIFile::NORMAL_FILE_TYPE, 0644);
NS_ENSURE_TRUE(nativeFile, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(nativeFile, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
// Now we can copy the blob
nativeFile = fileManager->GetFileForId(directory, id);
NS_ENSURE_TRUE(nativeFile, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(nativeFile, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDBDatabase* database = mObjectStore->Transaction()->Database();
nsRefPtr<FileOutputStream> outputStream =
FileOutputStream::Create(database->Type(), database->Group(),
database->Origin(), nativeFile);
NS_ENSURE_TRUE(outputStream, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(outputStream, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = CopyData(inputStream, outputStream);
NS_ENSURE_SUCCESS(rv, rv);
@ -3283,18 +3289,18 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
else {
rv = stmt->BindNullByName(NS_LITERAL_CSTRING("file_ids"));
}
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = stmt->Execute();
if (rv == NS_ERROR_STORAGE_CONSTRAINT) {
NS_ASSERTION(!keyUnset, "Generated key had a collision!?");
return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR;
}
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
int64_t objectDataId;
rv = aConnection->GetLastInsertRowID(&objectDataId);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
// Update our indexes if needed.
if (mOverwrite || !mIndexUpdateInfo.IsEmpty()) {
@ -3303,7 +3309,7 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
if (rv == NS_ERROR_STORAGE_CONSTRAINT) {
return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR;
}
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
if (autoIncrementNum) {
@ -3365,6 +3371,7 @@ AddHelper::PackArgumentsForParentProcess(ObjectStoreRequestParams& aParams)
BlobChild* actor =
contentChild->GetOrCreateActorForBlob(file.mFile);
if (!actor) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
blobsChild.AppendElement(actor);
@ -3452,20 +3459,20 @@ GetHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
keyRangeClause + NS_LITERAL_CSTRING(" LIMIT 1");
nsCOMPtr<mozIStorageStatement> stmt = mTransaction->GetCachedStatement(query);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv =
stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"), mObjectStore->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
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);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (hasResult) {
rv = IDBObjectStore::GetStructuredCloneReadInfoFromStatement(stmt, 0, 1,
@ -3582,7 +3589,7 @@ GetHelper::UnpackResponseFromParentProcess(const ResponseValue& aResponseValue)
"Inconsistent clone info!");
if (!mCloneReadInfo.SetFromSerialized(cloneInfo)) {
NS_WARNING("Failed to copy clone buffer!");
IDB_WARNING("Failed to copy clone buffer!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -3610,19 +3617,19 @@ DeleteHelper::DoDatabaseWork(mozIStorageConnection* /*aConnection */)
keyRangeClause;
nsCOMPtr<mozIStorageStatement> stmt = mTransaction->GetCachedStatement(query);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"),
mObjectStore->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = mKeyRange->BindToStatement(stmt);
NS_ENSURE_SUCCESS(rv, rv);
rv = stmt->Execute();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -3703,16 +3710,16 @@ ClearHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
mTransaction->GetCachedStatement(
NS_LITERAL_CSTRING("DELETE FROM object_data "
"WHERE object_store_id = :osid"));
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"),
mObjectStore->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = stmt->Execute();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -3807,13 +3814,13 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
nsCOMPtr<mozIStorageStatement> stmt =
mTransaction->GetCachedStatement(firstQuery);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"),
mObjectStore->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (mKeyRange) {
rv = mKeyRange->BindToStatement(stmt);
@ -3822,7 +3829,7 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
bool hasResult;
rv = stmt->ExecuteStep(&hasResult);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!hasResult) {
mKey.Unset();
@ -3909,7 +3916,7 @@ OpenCursorHelper::EnsureCursor()
IDBCursor::Create(mRequest, mTransaction, mObjectStore, mDirection,
mRangeKey, mContinueQuery, mContinueToQuery, mKey,
mCloneReadInfo);
NS_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(cursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ASSERTION(!mCloneReadInfo.mCloneBuffer.data(), "Should have swapped!");
@ -3926,7 +3933,7 @@ OpenCursorHelper::GetSuccessResult(JSContext* aCx,
if (mCursor) {
rv = WrapNative(aCx, mCursor, aVal);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
else {
aVal.setUndefined();
@ -4098,8 +4105,7 @@ OpenCursorHelper::UnpackResponseFromParentProcess(
} break;
default:
NS_NOTREACHED("Unknown response union type!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
MOZ_CRASH();
}
return NS_OK;
@ -4149,12 +4155,12 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
nsCOMPtr<mozIStorageStatement> stmt =
mTransaction->GetCachedStatement(firstQuery);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_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);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (mKeyRange) {
rv = mKeyRange->BindToStatement(stmt);
@ -4163,7 +4169,7 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
bool hasResult;
rv = stmt->ExecuteStep(&hasResult);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!hasResult) {
mKey.Unset();
@ -4239,7 +4245,7 @@ OpenKeyCursorHelper::EnsureCursor()
mCursor = IDBCursor::Create(mRequest, mTransaction, mObjectStore, mDirection,
mRangeKey, mContinueQuery, mContinueToQuery,
mKey);
NS_ENSURE_TRUE(mCursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(mCursor, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -4259,7 +4265,7 @@ OpenKeyCursorHelper::GetSuccessResult(JSContext* aCx,
if (mCursor) {
rv = WrapNative(aCx, mCursor, aVal);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
else {
aVal.setUndefined();
@ -4430,34 +4436,34 @@ CreateIndexHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
"multientry, object_store_id) "
"VALUES (:id, :name, :key_path, :unique, :multientry, :osid)"
);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("id"),
mIndex->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), mIndex->Name());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsAutoString keyPathSerialization;
mIndex->GetKeyPath().SerializeToString(keyPathSerialization);
rv = stmt->BindStringByName(NS_LITERAL_CSTRING("key_path"),
keyPathSerialization);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("unique"),
mIndex->IsUnique() ? 1 : 0);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = stmt->BindInt32ByName(NS_LITERAL_CSTRING("multientry"),
mIndex->IsMultiEntry() ? 1 : 0);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"),
mIndex->ObjectStore()->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (NS_FAILED(stmt->Execute())) {
return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR;
@ -4494,20 +4500,20 @@ CreateIndexHelper::InsertDataFromObjectStore(mozIStorageConnection* aConnection)
mTransaction->GetCachedStatement(
NS_LITERAL_CSTRING("SELECT id, data, file_ids, key_value FROM "
"object_data WHERE object_store_id = :osid"));
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"),
mIndex->ObjectStore()->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ENSURE_TRUE(sTLSIndex != BAD_TLS_INDEX,
NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(sTLSIndex != BAD_TLS_INDEX,
NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
bool hasResult;
rv = stmt->ExecuteStep(&hasResult);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!hasResult) {
// Bail early if we have no data to avoid creating the below runtime
return NS_OK;
@ -4518,7 +4524,7 @@ CreateIndexHelper::InsertDataFromObjectStore(mozIStorageConnection* aConnection)
if (!tlsEntry) {
tlsEntry = ThreadLocalJSRuntime::Create();
NS_ENSURE_TRUE(tlsEntry, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(tlsEntry, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
PR_SetThreadPrivate(sTLSIndex, tlsEntry);
}
@ -4567,7 +4573,7 @@ CreateIndexHelper::InsertDataFromObjectStore(mozIStorageConnection* aConnection)
NS_ENSURE_SUCCESS(rv, rv);
} while (NS_SUCCEEDED(rv = stmt->ExecuteStep(&hasResult)) && hasResult);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -4591,12 +4597,12 @@ DeleteIndexHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
"DELETE FROM object_store_index "
"WHERE name = :name "
);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), mName);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (NS_FAILED(stmt->Execute())) {
return NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR;
@ -4657,13 +4663,13 @@ GetAllHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
mCloneReadInfos.SetCapacity(50);
nsCOMPtr<mozIStorageStatement> stmt = mTransaction->GetCachedStatement(query);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"),
mObjectStore->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (mKeyRange) {
if (!mKeyRange->Lower().IsUnset()) {
@ -4689,7 +4695,7 @@ GetAllHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
mDatabase, *readInfo);
NS_ENSURE_SUCCESS(rv, rv);
}
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -4837,7 +4843,7 @@ GetAllHelper::UnpackResponseFromParentProcess(
StructuredCloneReadInfo* destInfo = mCloneReadInfos.AppendElement();
if (!destInfo->SetFromSerialized(srcInfo)) {
NS_WARNING("Failed to copy clone buffer!");
IDB_WARNING("Failed to copy clone buffer!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -4879,12 +4885,12 @@ GetAllKeysHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
limitClause;
nsCOMPtr<mozIStorageStatement> stmt = mTransaction->GetCachedStatement(query);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_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);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (mKeyRange) {
rv = mKeyRange->BindToStatement(stmt);
@ -4905,7 +4911,7 @@ GetAllKeysHelper::DoDatabaseWork(mozIStorageConnection* /* aConnection */)
rv = key->SetFromStatement(stmt, 0);
NS_ENSURE_SUCCESS(rv, rv);
}
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return NS_OK;
}
@ -4926,13 +4932,13 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
if (!array) {
NS_WARNING("Failed to make array!");
IDB_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!");
IDB_WARNING("Failed to set array length!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -4948,7 +4954,7 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
}
if (!JS_SetElement(aCx, array, index, value)) {
NS_WARNING("Failed to set array element!");
IDB_WARNING("Failed to set array element!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
}
@ -5079,13 +5085,13 @@ CountHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
keyRangeClause;
nsCOMPtr<mozIStorageStatement> stmt = mTransaction->GetCachedStatement(query);
NS_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(stmt, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mozStorageStatementScoper scoper(stmt);
nsresult rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("osid"),
mObjectStore->Id());
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (mKeyRange) {
if (!mKeyRange->Lower().IsUnset()) {
@ -5100,8 +5106,8 @@ CountHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
bool hasResult;
rv = stmt->ExecuteStep(&hasResult);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ENSURE_TRUE(hasResult, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(hasResult, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mCount = stmt->AsInt64(0);
return NS_OK;

View File

@ -30,6 +30,7 @@
#include "IDBIndex.h"
#include "IDBObjectStore.h"
#include "IDBTransaction.h"
#include "ReportInternalError.h"
namespace {
@ -187,7 +188,7 @@ IDBRequest::NotifyHelperCompleted(HelperBase* aHelper)
// Otherwise we need to get the result from the helper.
AutoPushJSContext cx(GetJSContext());
if (!cx) {
NS_WARNING("Failed to get safe JSContext!");
IDB_WARNING("Failed to get safe JSContext!");
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
SetError(rv);
return rv;

View File

@ -29,6 +29,7 @@
#include "IDBObjectStore.h"
#include "IndexedDatabaseManager.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
#include "TransactionThreadPool.h"
#include "ipc/IndexedDBChild.h"
@ -680,7 +681,7 @@ IDBTransaction::GetObjectStoreNames(ErrorResult& aRv)
uint32_t count = arrayOfNames->Length();
for (uint32_t index = 0; index < count; index++) {
if (!list->Add(arrayOfNames->ElementAt(index))) {
NS_WARNING("Failed to add element!");
IDB_WARNING("Failed to add element!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -714,7 +715,7 @@ IDBTransaction::ObjectStore(const nsAString& aName, ErrorResult& aRv)
nsRefPtr<IDBObjectStore> objectStore =
GetOrCreateObjectStore(aName, info, false);
if (!objectStore) {
NS_WARNING("Failed to get or create object store!");
IDB_WARNING("Failed to get or create object store!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
@ -829,7 +830,7 @@ CommitHelper::Run()
NS_LITERAL_STRING(COMPLETE_EVT_STR),
eDoesNotBubble, eNotCancelable);
}
NS_ENSURE_TRUE(event, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(event, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (mListener) {
mListener->NotifyTransactionPreComplete(mTransaction);
@ -861,6 +862,7 @@ CommitHelper::Run()
IDBDatabase* database = mTransaction->Database();
if (database->IsInvalidated()) {
IDB_REPORT_INTERNAL_ERR();
mAbortCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -869,10 +871,12 @@ CommitHelper::Run()
if (NS_SUCCEEDED(mAbortCode) && mUpdateFileRefcountFunction &&
NS_FAILED(mUpdateFileRefcountFunction->WillCommit(mConnection))) {
IDB_REPORT_INTERNAL_ERR();
mAbortCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
if (NS_SUCCEEDED(mAbortCode) && NS_FAILED(WriteAutoIncrementCounts())) {
IDB_REPORT_INTERNAL_ERR();
mAbortCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -891,6 +895,7 @@ CommitHelper::Run()
mAbortCode = NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR;
}
else {
IDB_REPORT_INTERNAL_ERR();
mAbortCode = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
}

View File

@ -7,6 +7,8 @@
#include "mozilla/FloatingPoint.h"
#include "Key.h"
#include "ReportInternalError.h"
#include "jsfriendapi.h"
#include "nsAlgorithm.h"
#include "nsJSUtils.h"
@ -112,6 +114,7 @@ Key::EncodeJSValInternal(JSContext* aCx, JS::Handle<JS::Value> aVal,
if (aVal.isString()) {
nsDependentJSString str;
if (!str.init(aCx, aVal)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
EncodeString(str, aTypeOffset);
@ -142,12 +145,14 @@ Key::EncodeJSValInternal(JSContext* aCx, JS::Handle<JS::Value> aVal,
uint32_t length;
if (!JS_GetArrayLength(aCx, obj, &length)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
for (uint32_t index = 0; index < length; index++) {
JS::Rooted<JS::Value> val(aCx);
if (!JS_GetElement(aCx, obj, index, &val)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -189,6 +194,7 @@ Key::DecodeJSValInternal(const unsigned char*& aPos, const unsigned char* aEnd,
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, 0, nullptr));
if (!array) {
NS_WARNING("Failed to make array!");
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -210,6 +216,7 @@ Key::DecodeJSValInternal(const unsigned char*& aPos, const unsigned char* aEnd,
if (!JS_SetElement(aCx, array, index++, val)) {
NS_WARNING("Failed to set array element!");
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
}
@ -224,6 +231,7 @@ Key::DecodeJSValInternal(const unsigned char*& aPos, const unsigned char* aEnd,
nsString key;
DecodeString(aPos, aEnd, key);
if (!xpc::StringToJsval(aCx, key, aVal)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
}
@ -231,7 +239,7 @@ Key::DecodeJSValInternal(const unsigned char*& aPos, const unsigned char* aEnd,
double msec = static_cast<double>(DecodeNumber(aPos, aEnd));
JSObject* date = JS_NewDateObjectMsec(aCx, msec);
if (!date) {
NS_WARNING("Failed to make date!");
IDB_WARNING("Failed to make date!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}

View File

@ -7,6 +7,7 @@
#include "KeyPath.h"
#include "IDBObjectStore.h"
#include "Key.h"
#include "ReportInternalError.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsJSUtils.h"
@ -114,13 +115,13 @@ GetJSValFromKeyPathString(JSContext* aCx,
bool ok = JS_HasUCProperty(aCx, obj, keyPathChars, keyPathLen,
&hasProp);
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (hasProp) {
// Get if the property exists...
JS::Rooted<JS::Value> intermediate(aCx);
bool ok = JS_GetUCProperty(aCx, obj, keyPathChars, keyPathLen, &intermediate);
NS_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(ok, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
// Treat explicitly undefined as an error.
if (intermediate == JSVAL_VOID) {
@ -162,6 +163,7 @@ GetJSValFromKeyPathString(JSContext* aCx,
JS::Rooted<JSObject*> dummy(aCx, JS_NewObject(aCx, nullptr, JS::NullPtr(),
JS::NullPtr()));
if (!dummy) {
IDB_REPORT_INTERNAL_ERR();
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
break;
}
@ -170,6 +172,7 @@ GetJSValFromKeyPathString(JSContext* aCx,
token.Length(),
OBJECT_TO_JSVAL(dummy), nullptr, nullptr,
JSPROP_ENUMERATE)) {
IDB_REPORT_INTERNAL_ERR();
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
break;
}
@ -180,6 +183,7 @@ GetJSValFromKeyPathString(JSContext* aCx,
JS::Rooted<JSObject*> dummy(aCx, JS_NewObject(aCx, &IDBObjectStore::sDummyPropJSClass,
JS::NullPtr(), JS::NullPtr()));
if (!dummy) {
IDB_REPORT_INTERNAL_ERR();
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
break;
}
@ -187,6 +191,7 @@ GetJSValFromKeyPathString(JSContext* aCx,
if (!JS_DefineUCProperty(aCx, obj, token.BeginReading(),
token.Length(), OBJECT_TO_JSVAL(dummy),
nullptr, nullptr, JSPROP_ENUMERATE)) {
IDB_REPORT_INTERNAL_ERR();
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
break;
}
@ -210,9 +215,10 @@ GetJSValFromKeyPathString(JSContext* aCx,
targetObjectPropName.get(),
targetObjectPropName.Length(),
&succeeded)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
NS_ENSURE_TRUE(succeeded, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(succeeded, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
NS_ENSURE_SUCCESS(rv, rv);
@ -400,6 +406,7 @@ KeyPath::ExtractKeyAsJSVal(JSContext* aCx, const JS::Value& aValue,
}
if (!JS_SetElement(aCx, arrayObj, i, value)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
}
@ -497,7 +504,7 @@ KeyPath::ToJSVal(JSContext* aCx, JS::MutableHandle<JS::Value> aValue) const
uint32_t len = mStrings.Length();
JS::Rooted<JSObject*> array(aCx, JS_NewArrayObject(aCx, len, nullptr));
if (!array) {
NS_WARNING("Failed to make array!");
IDB_WARNING("Failed to make array!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -505,10 +512,12 @@ KeyPath::ToJSVal(JSContext* aCx, JS::MutableHandle<JS::Value> aValue) const
JS::Rooted<JS::Value> val(aCx);
nsString tmp(mStrings[i]);
if (!xpc::StringToJsval(aCx, tmp, &val)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
if (!JS_SetElement(aCx, array, i, val)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
}
@ -520,6 +529,7 @@ KeyPath::ToJSVal(JSContext* aCx, JS::MutableHandle<JS::Value> aValue) const
if (IsString()) {
nsString tmp(mStrings[0]);
if (!xpc::StringToJsval(aCx, tmp, aValue)) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
return NS_OK;

View File

@ -24,6 +24,7 @@
#include "IDBFactory.h"
#include "IndexedDatabaseManager.h"
#include "ProfilerHelpers.h"
#include "ReportInternalError.h"
using namespace mozilla;
using namespace mozilla::dom;
@ -1786,6 +1787,7 @@ OpenDatabaseHelper::DoDatabaseWork()
mState = eFiringEvents; // In case we fail somewhere along the line.
if (QuotaManager::IsShuttingDown()) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -1805,18 +1807,18 @@ OpenDatabaseHelper::DoDatabaseWork()
quotaManager->EnsureOriginIsInitialized(mPersistenceType, mGroup,
mASCIIOrigin, mTrackingQuota,
getter_AddRefs(dbDirectory));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = dbDirectory->Append(NS_LITERAL_STRING(IDB_DIRECTORY_NAME));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
bool exists;
rv = dbDirectory->Exists(&exists);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!exists) {
rv = dbDirectory->Create(nsIFile::DIRECTORY_TYPE, 0755);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
#ifdef DEBUG
else {
@ -1828,24 +1830,24 @@ OpenDatabaseHelper::DoDatabaseWork()
nsAutoString filename;
rv = GetDatabaseFilename(mName, filename);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsCOMPtr<nsIFile> dbFile;
rv = dbDirectory->Clone(getter_AddRefs(dbFile));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = dbFile->Append(filename + NS_LITERAL_STRING(".sqlite"));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = dbFile->GetPath(mDatabaseFilePath);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsCOMPtr<nsIFile> fmDirectory;
rv = dbDirectory->Clone(getter_AddRefs(fmDirectory));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = fmDirectory->Append(filename);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsCOMPtr<mozIStorageConnection> connection;
rv = CreateDatabaseConnection(dbFile, fmDirectory, mName, mPersistenceType,
@ -1853,13 +1855,14 @@ OpenDatabaseHelper::DoDatabaseWork()
getter_AddRefs(connection));
if (NS_FAILED(rv) &&
NS_ERROR_GET_MODULE(rv) != NS_ERROR_MODULE_DOM_INDEXEDDB) {
IDB_REPORT_INTERNAL_ERR();
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
NS_ENSURE_SUCCESS(rv, rv);
rv = IDBFactory::LoadDatabaseInformation(connection, mDatabaseId,
&mCurrentVersion, mObjectStores);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (mForDeletion) {
mState = eDeletePending;
@ -1908,7 +1911,7 @@ OpenDatabaseHelper::DoDatabaseWork()
mPrivilege, mName);
rv = fileManager->Init(fmDirectory, connection);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
mgr->AddFileManager(fileManager);
}
@ -1976,7 +1979,7 @@ OpenDatabaseHelper::CreateDatabaseConnection(
bool isDirectory;
rv = aFMDirectory->IsDirectory(&isDirectory);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(isDirectory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(isDirectory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = aFMDirectory->Remove(true);
NS_ENSURE_SUCCESS(rv, rv);
@ -1999,12 +2002,12 @@ OpenDatabaseHelper::CreateDatabaseConnection(
// Unknown schema will fail origin initialization too
if (!schemaVersion && aName.IsVoid()) {
NS_WARNING("Unable to open IndexedDB database, schema is not set!");
IDB_WARNING("Unable to open IndexedDB database, schema is not set!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
if (schemaVersion > kSQLiteSchemaVersion) {
NS_WARNING("Unable to open IndexedDB database, schema is too high!");
IDB_WARNING("Unable to open IndexedDB database, schema is too high!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -2044,13 +2047,13 @@ OpenDatabaseHelper::CreateDatabaseConnection(
"INSERT INTO database (name) "
"VALUES (:name)"
), getter_AddRefs(stmt));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = stmt->BindStringByName(NS_LITERAL_CSTRING("name"), aName);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = stmt->Execute();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
else {
// This logic needs to change next time we change the schema!
@ -2092,6 +2095,7 @@ OpenDatabaseHelper::CreateDatabaseConnection(
else {
NS_WARNING("Unable to open IndexedDB database, no upgrade path is "
"available!");
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
NS_ENSURE_SUCCESS(rv, rv);
@ -2136,7 +2140,7 @@ OpenDatabaseHelper::StartSetVersion()
nsRefPtr<IDBTransaction> transaction =
IDBTransaction::Create(mDatabase, storesToOpen,
IDBTransaction::VERSION_CHANGE, true);
NS_ENSURE_TRUE(transaction, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(transaction, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsRefPtr<SetVersionHelper> helper =
new SetVersionHelper(transaction, mOpenDBRequest, this, mRequestedVersion,
@ -2149,7 +2153,7 @@ OpenDatabaseHelper::StartSetVersion()
mDatabase, mDatabase->Origin(), helper,
&VersionChangeEventsRunnable::QueueVersionChange<SetVersionHelper>,
helper);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
// The SetVersionHelper is responsible for dispatching us back to the
// main thread again and changing the state to eSetVersionCompleted.
@ -2179,7 +2183,7 @@ OpenDatabaseHelper::StartDelete()
mDatabase, mDatabase->Origin(), helper,
&VersionChangeEventsRunnable::QueueVersionChange<DeleteDatabaseHelper>,
helper);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
// The DeleteDatabaseHelper is responsible for dispatching us back to the
// main thread again and changing the state to eDeleteCompleted.
@ -2374,7 +2378,6 @@ OpenDatabaseHelper::EnsureSuccessResult()
newInfo->filePath = mDatabaseFilePath;
if (!DatabaseInfo::Put(newInfo)) {
NS_ERROR("Failed to add to hash!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -2382,7 +2385,7 @@ OpenDatabaseHelper::EnsureSuccessResult()
nsresult rv = IDBFactory::SetDatabaseMetadata(dbInfo, mCurrentVersion,
mObjectStores);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ASSERTION(mObjectStores.IsEmpty(), "Should have swapped!");
}
@ -2395,6 +2398,7 @@ OpenDatabaseHelper::EnsureSuccessResult()
dbInfo.forget(), mASCIIOrigin, mFileManager,
mContentParent);
if (!database) {
IDB_REPORT_INTERNAL_ERR();
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
@ -2538,11 +2542,11 @@ SetVersionHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
"UPDATE database "
"SET version = :version"
), getter_AddRefs(stmt));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("version"),
mRequestedVersion);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (NS_FAILED(stmt->Execute())) {
return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR;
@ -2663,38 +2667,38 @@ DeleteDatabaseHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
nsresult rv = quotaManager->GetDirectoryForOrigin(mPersistenceType,
mASCIIOrigin,
getter_AddRefs(directory));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ASSERTION(directory, "What?");
rv = directory->Append(NS_LITERAL_STRING(IDB_DIRECTORY_NAME));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsAutoString filename;
rv = GetDatabaseFilename(mName, filename);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsCOMPtr<nsIFile> dbFile;
rv = directory->Clone(getter_AddRefs(dbFile));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = dbFile->Append(filename + NS_LITERAL_STRING(".sqlite"));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
bool exists = false;
rv = dbFile->Exists(&exists);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (exists) {
int64_t fileSize;
if (privilege != Chrome) {
rv = dbFile->GetFileSize(&fileSize);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
rv = dbFile->Remove(false);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (privilege != Chrome) {
QuotaManager* quotaManager = QuotaManager::Get();
@ -2707,44 +2711,44 @@ DeleteDatabaseHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
nsCOMPtr<nsIFile> dbJournalFile;
rv = directory->Clone(getter_AddRefs(dbJournalFile));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = dbJournalFile->Append(filename + NS_LITERAL_STRING(".sqlite-journal"));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = dbJournalFile->Exists(&exists);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (exists) {
rv = dbJournalFile->Remove(false);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
nsCOMPtr<nsIFile> fmDirectory;
rv = directory->Clone(getter_AddRefs(fmDirectory));
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = fmDirectory->Append(filename);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = fmDirectory->Exists(&exists);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (exists) {
bool isDirectory;
rv = fmDirectory->IsDirectory(&isDirectory);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(isDirectory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_TRUE(isDirectory, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
uint64_t usage = 0;
if (privilege != Chrome) {
rv = FileManager::GetUsage(fmDirectory, &usage);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
}
rv = fmDirectory->Remove(true);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (privilege != Chrome) {
QuotaManager* quotaManager = QuotaManager::Get();

View File

@ -0,0 +1,32 @@
/* -*- 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 "ReportInternalError.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "nsContentUtils.h"
#include "nsPrintfCString.h"
BEGIN_INDEXEDDB_NAMESPACE
void
ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr)
{
// Get leaf of file path
for (const char* p = aFile; *p; ++p) {
if (*p == '/' && *(p + 1)) {
aFile = p + 1;
}
}
nsContentUtils::LogSimpleConsoleError(
NS_ConvertUTF8toUTF16(nsPrintfCString(
"IndexedDB %s: %s:%lu", aStr, aFile, aLine)),
"indexedDB");
}
END_INDEXEDDB_NAMESPACE

View File

@ -0,0 +1,51 @@
/* -*- 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/. */
#ifndef mozilla_dom_indexeddb_reportinternalerror_h__
#define mozilla_dom_indexeddb_reportinternalerror_h__
#include "nsDebug.h"
#include "IndexedDatabase.h"
#define IDB_WARNING(x) \
mozilla::dom::indexedDB::ReportInternalError(__FILE__, __LINE__, x); \
NS_WARNING(x)
#define IDB_REPORT_INTERNAL_ERR() \
mozilla::dom::indexedDB::ReportInternalError(__FILE__, __LINE__, \
"UnknownErr")
// Based on NS_ENSURE_TRUE
#define IDB_ENSURE_TRUE(x, ret) \
do { \
if (MOZ_UNLIKELY(!(x))) { \
IDB_REPORT_INTERNAL_ERR(); \
NS_WARNING("IDB_ENSURE_TRUE(" #x ") failed"); \
return ret; \
} \
} while(0)
// Based on NS_ENSURE_SUCCESS
#define IDB_ENSURE_SUCCESS(res, ret) \
do { \
nsresult __rv = res; /* Don't evaluate |res| more than once */ \
if (NS_FAILED(__rv)) { \
IDB_REPORT_INTERNAL_ERR(); \
NS_ENSURE_SUCCESS_BODY(res, ret) \
return ret; \
} \
} while(0)
BEGIN_INDEXEDDB_NAMESPACE
void
ReportInternalError(const char* aFile, uint32_t aLine, const char* aStr);
END_INDEXEDDB_NAMESPACE
#endif // mozilla_dom_indexeddb_reportinternalerror_h__

View File

@ -62,6 +62,7 @@ SOURCES += [
'IDBCursor.cpp',
'IDBIndex.cpp',
'IDBObjectStore.cpp',
'ReportInternalError.cpp',
]
FAIL_ON_WARNINGS = True