IndexedDB: Propagate more leveldb errors to script
authordgrogan@chromium.org <dgrogan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Dec 2012 00:21:14 +0000 (00:21 +0000)
committerdgrogan@chromium.org <dgrogan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Dec 2012 00:21:14 +0000 (00:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=104422

Reviewed by Tony Chang.

Source/WebCore:

These are the last places that ignore leveldb errors that can get the
usual ok/found treatment.

Nothing called getBool, so it is deleted.

* Modules/indexeddb/IDBBackingStore.cpp:
(WebCore):
(WebCore::getInt):
(WebCore::isSchemaKnown):
(WebCore::setUpMetadata):
(WebCore::getMaxObjectStoreId):
(WebCore::IDBBackingStore::open):
(WebCore::IDBBackingStore::getIDBDatabaseMetaData):
(WebCore::getNewDatabaseId):
(WebCore::IDBBackingStore::createIDBDatabaseMetaData):
(WebCore::setMaxObjectStoreId):
(WebCore::getNewVersionNumber):
(WebCore::IDBBackingStore::putRecord):
(WebCore::setMaxIndexId):
* Modules/indexeddb/IDBBackingStore.h:
(IDBBackingStore):
* Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
(WebCore::IDBObjectStoreBackendImpl::setIndexKeys):
(WebCore::IDBObjectStoreBackendImpl::ObjectStoreStorageOperation::perform):

Source/WebKit/chromium:

* tests/IDBFakeBackingStore.h:
  Delete method override that doesn't match new signature.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@137223 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBBackingStore.cpp
Source/WebCore/Modules/indexeddb/IDBBackingStore.h
Source/WebCore/Modules/indexeddb/IDBObjectStoreBackendImpl.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/tests/IDBFakeBackingStore.h

index e978e5a..240f489 100644 (file)
@@ -1,3 +1,35 @@
+2012-12-10  David Grogan  <dgrogan@chromium.org>
+
+        IndexedDB: Propagate more leveldb errors to script
+        https://bugs.webkit.org/show_bug.cgi?id=104422
+
+        Reviewed by Tony Chang.
+
+        These are the last places that ignore leveldb errors that can get the
+        usual ok/found treatment.
+
+        Nothing called getBool, so it is deleted.
+
+        * Modules/indexeddb/IDBBackingStore.cpp:
+        (WebCore):
+        (WebCore::getInt):
+        (WebCore::isSchemaKnown):
+        (WebCore::setUpMetadata):
+        (WebCore::getMaxObjectStoreId):
+        (WebCore::IDBBackingStore::open):
+        (WebCore::IDBBackingStore::getIDBDatabaseMetaData):
+        (WebCore::getNewDatabaseId):
+        (WebCore::IDBBackingStore::createIDBDatabaseMetaData):
+        (WebCore::setMaxObjectStoreId):
+        (WebCore::getNewVersionNumber):
+        (WebCore::IDBBackingStore::putRecord):
+        (WebCore::setMaxIndexId):
+        * Modules/indexeddb/IDBBackingStore.h:
+        (IDBBackingStore):
+        * Modules/indexeddb/IDBObjectStoreBackendImpl.cpp:
+        (WebCore::IDBObjectStoreBackendImpl::setIndexKeys):
+        (WebCore::IDBObjectStoreBackendImpl::ObjectStoreStorageOperation::perform):
+
 2012-12-09  Antti Koivisto  <antti@apple.com>
 
         Factor node traversal into standalone functions
index 3e110b6..4b1a1a7 100644 (file)
@@ -68,6 +68,10 @@ enum IDBLevelDBBackingStoreInternalErrorType {
     IDBLevelDBBackingStoreReadErrorKeyExistsInIndex,
     IDBLevelDBBackingStoreReadErrorVersionExists,
     IDBLevelDBBackingStoreReadErrorDeleteObjectStore,
+    IDBLevelDBBackingStoreReadErrorSetMaxObjectStoreId,
+    IDBLevelDBBackingStoreReadErrorSetMaxIndexId,
+    IDBLevelDBBackingStoreReadErrorGetNewDatabaseId,
+    IDBLevelDBBackingStoreReadErrorGetNewVersionNumber,
     IDBLevelDBBackingStoreInternalErrorMax,
 };
 static inline void recordInternalError(IDBLevelDBBackingStoreInternalErrorType type)
@@ -84,32 +88,20 @@ static inline void recordInternalError(IDBLevelDBBackingStoreInternalErrorType t
         recordInternalError(type); \
     } while (0)
 
-template <typename DBOrTransaction>
-static bool getBool(DBOrTransaction* db, const LevelDBSlice& key, bool& foundBool)
-{
-    Vector<char> result;
-    if (!db->get(key, result))
-        return false;
-
-    foundBool = decodeBool(result.begin(), result.end());
-    return true;
-}
-
 static void putBool(LevelDBTransaction* transaction, const LevelDBSlice& key, bool value)
 {
     transaction->put(key, encodeBool(value));
 }
 
 template <typename DBOrTransaction>
-static bool getInt(DBOrTransaction* db, const LevelDBSlice& key, int64_t& foundInt)
+static bool getInt(DBOrTransaction* db, const LevelDBSlice& key, int64_t& foundInt, bool& found)
 {
     Vector<char> result;
-    bool found = false;
     bool ok = db->safeGet(key, result, found);
-    // FIXME: Notify the caller if !ok.
-    ASSERT_UNUSED(ok, ok);
-    if (!found)
+    if (!ok)
         return false;
+    if (!found)
+        return true;
 
     foundInt = decodeInt(result.begin(), result.end());
     return true;
@@ -185,26 +177,42 @@ public:
 // 1 - Adds UserIntVersion to DatabaseMetaData.
 // 2 - Adds DataVersion to to global metadata.
 const int64_t latestKnownSchemaVersion = 2;
-static bool isSchemaKnown(LevelDBDatabase* db)
+WARN_UNUSED_RETURN static bool isSchemaKnown(LevelDBDatabase* db, bool& known)
 {
     int64_t dbSchemaVersion = 0;
-    if (!getInt(db, SchemaVersionKey::encode(), dbSchemaVersion))
-        return true;
-    if (dbSchemaVersion > latestKnownSchemaVersion)
+    bool found = false;
+    bool ok = getInt(db, SchemaVersionKey::encode(), dbSchemaVersion, found);
+    if (!ok)
         return false;
+    if (!found) {
+        known = true;
+        return true;
+    }
+    if (dbSchemaVersion > latestKnownSchemaVersion) {
+        known = false;
+        return true;
+    }
 
     const uint32_t latestKnownDataVersion = SerializedScriptValue::wireFormatVersion();
     int64_t dbDataVersion = 0;
-    if (!getInt(db, DataVersionKey::encode(), dbDataVersion))
+    ok = getInt(db, DataVersionKey::encode(), dbDataVersion, found);
+    if (!ok)
+        return false;
+    if (!found) {
+        known = true;
         return true;
+    }
 
-    if (dbDataVersion > latestKnownDataVersion)
-        return false;
+    if (dbDataVersion > latestKnownDataVersion) {
+        known = false;
+        return true;
+    }
 
+    known = true;
     return true;
 }
 
-static bool setUpMetadata(LevelDBDatabase* db, const String& origin)
+WARN_UNUSED_RETURN static bool setUpMetadata(LevelDBDatabase* db, const String& origin)
 {
     const uint32_t latestKnownDataVersion = SerializedScriptValue::wireFormatVersion();
     const Vector<char> schemaVersionKey = SchemaVersionKey::encode();
@@ -214,7 +222,13 @@ static bool setUpMetadata(LevelDBDatabase* db, const String& origin)
 
     int64_t dbSchemaVersion = 0;
     int64_t dbDataVersion = 0;
-    if (!getInt(transaction.get(), schemaVersionKey, dbSchemaVersion)) {
+    bool found = false;
+    bool ok = getInt(transaction.get(), schemaVersionKey, dbSchemaVersion, found);
+    if (!ok) {
+        InternalError(IDBLevelDBBackingStoreReadErrorSetupMetadata);
+        return false;
+    }
+    if (!found) {
         // Initialize new backing store.
         dbSchemaVersion = latestKnownSchemaVersion;
         putInt(transaction.get(), schemaVersionKey, dbSchemaVersion);
@@ -231,10 +245,16 @@ static bool setUpMetadata(LevelDBDatabase* db, const String& origin)
             OwnPtr<LevelDBIterator> it = db->createIterator();
             for (it->seek(startKey); it->isValid() && compareKeys(it->key(), stopKey) < 0; it->next()) {
                 int64_t databaseId = 0;
-                if (!getInt(transaction.get(), it->key(), databaseId)) {
+                found = false;
+                bool ok = getInt(transaction.get(), it->key(), databaseId, found);
+                if (!ok) {
                     InternalError(IDBLevelDBBackingStoreReadErrorSetupMetadata);
                     return false;
                 }
+                if (!found) {
+                    InternalError(IDBLevelDBBackingStoreConsistencyError);
+                    return false;
+                }
                 Vector<char> intVersionKey = DatabaseMetaDataKey::encode(databaseId, DatabaseMetaDataKey::UserIntVersion);
                 putVarInt(transaction.get(), intVersionKey, IDBDatabaseMetadata::DefaultIntVersion);
             }
@@ -248,8 +268,14 @@ static bool setUpMetadata(LevelDBDatabase* db, const String& origin)
     }
 
     // All new values will be written using this serialization version.
-    if (!getInt(transaction.get(), dataVersionKey, dbDataVersion)) {
-        InternalError(IDBLevelDBBackingStoreReadError);
+    found = false;
+    ok = getInt(transaction.get(), dataVersionKey, dbDataVersion, found);
+    if (!ok) {
+        InternalError(IDBLevelDBBackingStoreReadErrorSetupMetadata);
+        return false;
+    }
+    if (!found) {
+        InternalError(IDBLevelDBBackingStoreConsistencyError);
         return false;
     }
     if (dbDataVersion < latestKnownDataVersion) {
@@ -268,21 +294,26 @@ static bool setUpMetadata(LevelDBDatabase* db, const String& origin)
 }
 
 template <typename DBOrTransaction>
-static int64_t getMaxObjectStoreId(DBOrTransaction* db, int64_t databaseId)
+WARN_UNUSED_RETURN static bool getMaxObjectStoreId(DBOrTransaction* db, int64_t databaseId, int64_t& maxObjectStoreId)
 {
     const Vector<char> maxObjectStoreIdKey = DatabaseMetaDataKey::encode(databaseId, DatabaseMetaDataKey::MaxObjectStoreId);
-    return getMaxObjectStoreId(db, maxObjectStoreIdKey);
+    bool ok = getMaxObjectStoreId(db, maxObjectStoreIdKey, maxObjectStoreId);
+    return ok;
 }
 
 template <typename DBOrTransaction>
-static int64_t getMaxObjectStoreId(DBOrTransaction* db, const Vector<char>& maxObjectStoreIdKey)
+WARN_UNUSED_RETURN static bool getMaxObjectStoreId(DBOrTransaction* db, const Vector<char>& maxObjectStoreIdKey, int64_t& maxObjectStoreId)
 {
-    int64_t maxObjectStoreId = -1;
-    if (!getInt(db, maxObjectStoreIdKey, maxObjectStoreId))
+    maxObjectStoreId = -1;
+    bool found = false;
+    bool ok = getInt(db, maxObjectStoreIdKey, maxObjectStoreId, found);
+    if (!ok)
+        return false;
+    if (!found)
         maxObjectStoreId = 0;
 
     ASSERT(maxObjectStoreId >= 0);
-    return maxObjectStoreId;
+    return true;
 }
 
 IDBBackingStore::IDBBackingStore(const String& identifier, IDBFactoryBackendImpl* factory, PassOwnPtr<LevelDBDatabase> db)
@@ -316,6 +347,7 @@ enum IDBLevelDBBackingStoreOpenResult {
     IDBLevelDBBackingStoreOpenCleanupDestroyFailed,
     IDBLevelDBBackingStoreOpenCleanupReopenFailed,
     IDBLevelDBBackingStoreOpenCleanupReopenSuccess,
+    IDBLevelDBBackingStoreOpenFailedIOErrCheckingSchema,
     IDBLevelDBBackingStoreOpenMax,
 };
 
@@ -340,10 +372,18 @@ PassRefPtr<IDBBackingStore> IDBBackingStore::open(SecurityOrigin* securityOrigin
         String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIdentifier() + ".indexeddb.leveldb");
 
         db = LevelDBDatabase::open(path, comparator.get());
-        if (db && !isSchemaKnown(db.get())) {
-            LOG_ERROR("IndexedDB backing store had unknown schema, treating it as failure to open");
-            HistogramSupport::histogramEnumeration("WebCore.IndexedDB.BackingStore.OpenStatus", IDBLevelDBBackingStoreOpenFailedUnknownSchema, IDBLevelDBBackingStoreOpenMax);
-            db.clear();
+        if (db) {
+            bool known = false;
+            bool ok = isSchemaKnown(db.get(), known);
+            if (!ok) {
+                HistogramSupport::histogramEnumeration("WebCore.IndexedDB.BackingStore.OpenStatus", IDBLevelDBBackingStoreOpenFailedIOErrCheckingSchema, IDBLevelDBBackingStoreOpenMax);
+                return PassRefPtr<IDBBackingStore>();
+            }
+            if (!known) {
+                LOG_ERROR("IndexedDB backing store had unknown schema, treating it as failure to open");
+                HistogramSupport::histogramEnumeration("WebCore.IndexedDB.BackingStore.OpenStatus", IDBLevelDBBackingStoreOpenFailedUnknownSchema, IDBLevelDBBackingStoreOpenMax);
+                db.clear();
+            }
         }
 
         if (db)
@@ -409,11 +449,15 @@ bool IDBBackingStore::getIDBDatabaseMetaData(const String& name, IDBDatabaseMeta
     const Vector<char> key = DatabaseNameKey::encode(m_identifier, name);
     found = false;
 
-    found = getInt(m_db.get(), key, metadata->id);
+    bool ok = getInt(m_db.get(), key, metadata->id, found);
+    if (!ok) {
+        InternalError(IDBLevelDBBackingStoreReadErrorGetIDBDatabaseMetaData);
+        return false;
+    }
     if (!found)
         return true;
 
-    bool ok = getString(m_db.get(), DatabaseMetaDataKey::encode(metadata->id, DatabaseMetaDataKey::UserVersion), metadata->version, found);
+    ok = getString(m_db.get(), DatabaseMetaDataKey::encode(metadata->id, DatabaseMetaDataKey::UserVersion), metadata->version, found);
     if (!ok) {
         InternalError(IDBLevelDBBackingStoreReadErrorGetIDBDatabaseMetaData);
         return false;
@@ -436,17 +480,28 @@ bool IDBBackingStore::getIDBDatabaseMetaData(const String& name, IDBDatabaseMeta
     if (metadata->intVersion == IDBDatabaseMetadata::DefaultIntVersion)
         metadata->intVersion = IDBDatabaseMetadata::NoIntVersion;
 
-    metadata->maxObjectStoreId = getMaxObjectStoreId(m_db.get(), metadata->id);
+    ok = getMaxObjectStoreId(m_db.get(), metadata->id, metadata->maxObjectStoreId);
+    if (!ok) {
+        InternalError(IDBLevelDBBackingStoreReadErrorGetIDBDatabaseMetaData);
+        return false;
+    }
 
     return true;
 }
 
-static int64_t getNewDatabaseId(LevelDBDatabase* db)
+WARN_UNUSED_RETURN static bool getNewDatabaseId(LevelDBDatabase* db, int64_t& newId)
 {
     RefPtr<LevelDBTransaction> transaction = LevelDBTransaction::create(db);
 
+    newId = -1;
     int64_t maxDatabaseId = -1;
-    if (!getInt(transaction.get(), MaxDatabaseIdKey::encode(), maxDatabaseId))
+    bool found = false;
+    bool ok = getInt(transaction.get(), MaxDatabaseIdKey::encode(), maxDatabaseId, found);
+    if (!ok) {
+        InternalError(IDBLevelDBBackingStoreReadErrorGetNewDatabaseId);
+        return false;
+    }
+    if (!found)
         maxDatabaseId = 0;
 
     ASSERT(maxDatabaseId >= 0);
@@ -455,16 +510,18 @@ static int64_t getNewDatabaseId(LevelDBDatabase* db)
     putInt(transaction.get(), MaxDatabaseIdKey::encode(), databaseId);
     if (!transaction->commit()) {
         InternalError(IDBLevelDBBackingStoreWriteError);
-        return -1;
+        return false;
     }
-    return databaseId;
+    newId = databaseId;
+    return true;
 }
 
 bool IDBBackingStore::createIDBDatabaseMetaData(const String& name, const String& version, int64_t intVersion, int64_t& rowId)
 {
-    rowId = getNewDatabaseId(m_db.get());
-    if (rowId < 0)
+    bool ok = getNewDatabaseId(m_db.get(), rowId);
+    if (!ok)
         return false;
+    ASSERT(rowId >= 0);
 
     if (intVersion == IDBDatabaseMetadata::NoIntVersion)
         intVersion = IDBDatabaseMetadata::DefaultIntVersion;
@@ -634,10 +691,15 @@ Vector<IDBObjectStoreMetadata> IDBBackingStore::getObjectStores(int64_t database
     return objectStores;
 }
 
-static bool setMaxObjectStoreId(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId)
+WARN_UNUSED_RETURN static bool setMaxObjectStoreId(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId)
 {
     const Vector<char> maxObjectStoreIdKey = DatabaseMetaDataKey::encode(databaseId, DatabaseMetaDataKey::MaxObjectStoreId);
-    int64_t maxObjectStoreId = getMaxObjectStoreId(transaction, maxObjectStoreIdKey);
+    int64_t maxObjectStoreId = -1;
+    bool ok = getMaxObjectStoreId(transaction, maxObjectStoreIdKey, maxObjectStoreId);
+    if (!ok) {
+        InternalError(IDBLevelDBBackingStoreReadErrorSetMaxObjectStoreId);
+        return false;
+    }
 
     if (objectStoreId <= maxObjectStoreId) {
         InternalError(IDBLevelDBBackingStoreConsistencyError);
@@ -732,12 +794,19 @@ bool IDBBackingStore::getRecord(IDBBackingStore::Transaction* transaction, int64
     return true;
 }
 
-static int64_t getNewVersionNumber(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId)
+WARN_UNUSED_RETURN static bool getNewVersionNumber(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t& newVersionNumber)
 {
     const Vector<char> lastVersionKey = ObjectStoreMetaDataKey::encode(databaseId, objectStoreId, ObjectStoreMetaDataKey::LastVersion);
 
+    newVersionNumber = -1;
     int64_t lastVersion = -1;
-    if (!getInt(transaction, lastVersionKey, lastVersion))
+    bool found = false;
+    bool ok = getInt(transaction, lastVersionKey, lastVersion, found);
+    if (!ok) {
+        InternalError(IDBLevelDBBackingStoreReadErrorGetNewVersionNumber);
+        return false;
+    }
+    if (!found)
         lastVersion = 0;
 
     ASSERT(lastVersion >= 0);
@@ -747,15 +816,20 @@ static int64_t getNewVersionNumber(LevelDBTransaction* transaction, int64_t data
 
     ASSERT(version > lastVersion); // FIXME: Think about how we want to handle the overflow scenario.
 
-    return version;
+    newVersionNumber = version;
+    return true;
 }
 
-void IDBBackingStore::putRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, const String& value, RecordIdentifier* recordIdentifier)
+bool IDBBackingStore::putRecord(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId, const IDBKey& key, const String& value, RecordIdentifier* recordIdentifier)
 {
     IDB_TRACE("IDBBackingStore::putRecord");
     ASSERT(key.isValid());
     LevelDBTransaction* levelDBTransaction = IDBBackingStore::Transaction::levelDBTransactionFrom(transaction);
-    int64_t version = getNewVersionNumber(levelDBTransaction, databaseId, objectStoreId);
+    int64_t version = -1;
+    bool ok = getNewVersionNumber(levelDBTransaction, databaseId, objectStoreId, version);
+    if (!ok)
+        return false;
+    ASSERT(version >= 0);
     const Vector<char> objectStoredataKey = ObjectStoreDataKey::encode(databaseId, objectStoreId, key);
 
     Vector<char> v;
@@ -768,6 +842,7 @@ void IDBBackingStore::putRecord(IDBBackingStore::Transaction* transaction, int64
     levelDBTransaction->put(existsEntryKey, encodeInt(version));
 
     recordIdentifier->reset(encodeIDBKey(key), version);
+    return true;
 }
 
 void IDBBackingStore::clearObjectStore(IDBBackingStore::Transaction* transaction, int64_t databaseId, int64_t objectStoreId)
@@ -954,11 +1029,17 @@ Vector<IDBIndexMetadata> IDBBackingStore::getIndexes(int64_t databaseId, int64_t
     return indexes;
 }
 
-static bool setMaxIndexId(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId)
+WARN_UNUSED_RETURN static bool setMaxIndexId(LevelDBTransaction* transaction, int64_t databaseId, int64_t objectStoreId, int64_t indexId)
 {
     int64_t maxIndexId = -1;
     const Vector<char> maxIndexIdKey = ObjectStoreMetaDataKey::encode(databaseId, objectStoreId, ObjectStoreMetaDataKey::MaxIndexId);
-    if (!getInt(transaction, maxIndexIdKey, maxIndexId))
+    bool found = false;
+    bool ok = getInt(transaction, maxIndexIdKey, maxIndexId, found);
+    if (!ok) {
+        InternalError(IDBLevelDBBackingStoreReadErrorSetMaxIndexId);
+        return false;
+    }
+    if (!found)
         maxIndexId = MinimumIndexId;
 
     if (indexId <= maxIndexId) {
index e6ed4d8..5d1aacc 100644 (file)
@@ -78,7 +78,7 @@ public:
     };
 
     virtual bool getRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, String& record) WARN_UNUSED_RETURN;
-    virtual void putRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, RecordIdentifier*);
+    virtual bool putRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, RecordIdentifier*) WARN_UNUSED_RETURN;
     virtual void clearObjectStore(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId);
     virtual void deleteRecord(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier&);
     virtual bool getKeyGeneratorCurrentNumber(IDBBackingStore::Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t& currentNumber) WARN_UNUSED_RETURN;
index 2ada525..82ebd46 100644 (file)
@@ -467,7 +467,8 @@ void IDBObjectStoreBackendImpl::setIndexKeys(PassRefPtr<IDBKey> prpPrimaryKey, c
         return;
     }
     if (!found) {
-        transaction->abort();
+        RefPtr<IDBDatabaseError> error = IDBDatabaseError::create(IDBDatabaseException::UnknownError, String::format("Internal error setting index keys for object store %s.", name().utf8().data()));
+        transaction->abort(error.release());
         return;
     }
 
@@ -560,7 +561,11 @@ void IDBObjectStoreBackendImpl::ObjectStoreStorageOperation::perform(IDBTransact
 
     // Before this point, don't do any mutation.  After this point, rollback the transaction in case of error.
 
-    m_objectStore->backingStore()->putRecord(transaction->backingStoreTransaction(), m_objectStore->databaseId(), m_objectStore->id(), *m_key, m_value->toWireString(), &recordIdentifier);
+    backingStoreSuccess = m_objectStore->backingStore()->putRecord(transaction->backingStoreTransaction(), m_objectStore->databaseId(), m_objectStore->id(), *m_key, m_value->toWireString(), &recordIdentifier);
+    if (!backingStoreSuccess) {
+        m_callbacks->onError(IDBDatabaseError::create(IDBDatabaseException::UnknownError, "Internal error: backing store error performing put/add."));
+        return;
+    }
 
     for (size_t i = 0; i < indexWriters.size(); ++i) {
         IndexWriter* indexWriter = indexWriters[i].get();
index 41838e6..c2c73bc 100644 (file)
@@ -1,3 +1,13 @@
+2012-12-10  David Grogan  <dgrogan@chromium.org>
+
+        IndexedDB: Propagate more leveldb errors to script
+        https://bugs.webkit.org/show_bug.cgi?id=104422
+
+        Reviewed by Tony Chang.
+
+        * tests/IDBFakeBackingStore.h:
+          Delete method override that doesn't match new signature.
+
 2012-12-09  Antti Koivisto  <antti@apple.com>
 
         Factor node traversal into standalone functions
index 9b17add..f965073 100644 (file)
@@ -42,7 +42,6 @@ public:
     virtual Vector<IDBObjectStoreMetadata> getObjectStores(int64_t databaseId) OVERRIDE { return Vector<IDBObjectStoreMetadata>(); }
     virtual bool createObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId, const String& name, const IDBKeyPath&, bool autoIncrement) OVERRIDE { return false; };
 
-    virtual void putRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, RecordIdentifier*) OVERRIDE { }
     virtual void clearObjectStore(Transaction*, int64_t databaseId, int64_t objectStoreId) OVERRIDE { }
     virtual void deleteRecord(Transaction*, int64_t databaseId, int64_t objectStoreId, const RecordIdentifier&) OVERRIDE { }
     virtual bool getKeyGeneratorCurrentNumber(Transaction*, int64_t databaseId, int64_t objectStoreId, int64_t& currentNumber) OVERRIDE { return true; }