Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: Source/WebCore/Modules/indexeddb/IDBBackingStore.cpp

Issue 12549003: Merge 144323 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1410/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
« no previous file with comments | « Source/WebCore/Modules/indexeddb/IDBBackingStore.h ('k') | Source/WebCore/platform/leveldb/LevelDBDatabase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698