| Index: Source/WebCore/Modules/indexeddb/IDBBackingStore.cpp
|
| ===================================================================
|
| --- Source/WebCore/Modules/indexeddb/IDBBackingStore.cpp (revision 144946)
|
| +++ Source/WebCore/Modules/indexeddb/IDBBackingStore.cpp (working copy)
|
| @@ -323,6 +323,18 @@
|
| return true;
|
| }
|
|
|
| +class DefaultLevelDBFactory : public LevelDBFactory {
|
| +public:
|
| + virtual PassOwnPtr<LevelDBDatabase> openLevelDB(const String& fileName, const LevelDBComparator* comparator)
|
| + {
|
| + return LevelDBDatabase::open(fileName, comparator);
|
| + }
|
| + virtual bool destroyLevelDB(const String& fileName)
|
| + {
|
| + return LevelDBDatabase::destroy(fileName);
|
| + }
|
| +};
|
| +
|
| IDBBackingStore::IDBBackingStore(const String& identifier, IDBFactoryBackendImpl* factory, PassOwnPtr<LevelDBDatabase> db)
|
| : m_identifier(identifier)
|
| , m_factory(factory)
|
| @@ -360,6 +372,12 @@
|
|
|
| PassRefPtr<IDBBackingStore> IDBBackingStore::open(SecurityOrigin* securityOrigin, const String& pathBaseArg, const String& fileIdentifier, IDBFactoryBackendImpl* factory)
|
| {
|
| + DefaultLevelDBFactory levelDBFactory;
|
| + return IDBBackingStore::open(securityOrigin, pathBaseArg, fileIdentifier, factory, &levelDBFactory);
|
| +}
|
| +
|
| +PassRefPtr<IDBBackingStore> IDBBackingStore::open(SecurityOrigin* securityOrigin, const String& pathBaseArg, const String& fileIdentifier, IDBFactoryBackendImpl* factory, LevelDBFactory* levelDBFactory)
|
| +{
|
| IDB_TRACE("IDBBackingStore::open");
|
| String pathBase = pathBaseArg;
|
|
|
| @@ -378,15 +396,15 @@
|
|
|
| String path = pathByAppendingComponent(pathBase, securityOrigin->databaseIdentifier() + ".indexeddb.leveldb");
|
|
|
| - db = LevelDBDatabase::open(path, comparator.get());
|
| + db = levelDBFactory->openLevelDB(path, comparator.get());
|
| if (db) {
|
| bool known = false;
|
| bool ok = isSchemaKnown(db.get(), known);
|
| if (!ok) {
|
| + LOG_ERROR("IndexedDB had IO error checking schema, treating it as failure to open");
|
| HistogramSupport::histogramEnumeration("WebCore.IndexedDB.BackingStore.OpenStatus", IDBLevelDBBackingStoreOpenFailedIOErrCheckingSchema, IDBLevelDBBackingStoreOpenMax);
|
| - return PassRefPtr<IDBBackingStore>();
|
| - }
|
| - if (!known) {
|
| + db.clear();
|
| + } else 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();
|
| @@ -397,7 +415,7 @@
|
| HistogramSupport::histogramEnumeration("WebCore.IndexedDB.BackingStore.OpenStatus", IDBLevelDBBackingStoreOpenSuccess, IDBLevelDBBackingStoreOpenMax);
|
| else {
|
| LOG_ERROR("IndexedDB backing store open failed, attempting cleanup");
|
| - bool success = LevelDBDatabase::destroy(path);
|
| + bool success = levelDBFactory->destroyLevelDB(path);
|
| if (!success) {
|
| LOG_ERROR("IndexedDB backing store cleanup failed");
|
| HistogramSupport::histogramEnumeration("WebCore.IndexedDB.BackingStore.OpenStatus", IDBLevelDBBackingStoreOpenCleanupDestroyFailed, IDBLevelDBBackingStoreOpenMax);
|
| @@ -405,7 +423,7 @@
|
| }
|
|
|
| LOG_ERROR("IndexedDB backing store cleanup succeeded, reopening");
|
| - db = LevelDBDatabase::open(path, comparator.get());
|
| + db = levelDBFactory->openLevelDB(path, comparator.get());
|
| if (!db) {
|
| LOG_ERROR("IndexedDB backing store reopen after recovery failed");
|
| HistogramSupport::histogramEnumeration("WebCore.IndexedDB.BackingStore.OpenStatus", IDBLevelDBBackingStoreOpenCleanupReopenFailed, IDBLevelDBBackingStoreOpenMax);
|
|
|