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

Unified Diff: content/browser/indexed_db/indexed_db_factory.cc

Issue 237143006: Make iterating over a corrupted IndexedDB fail. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 8 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: content/browser/indexed_db/indexed_db_factory.cc
diff --git a/content/browser/indexed_db/indexed_db_factory.cc b/content/browser/indexed_db/indexed_db_factory.cc
index e3a415a683a0cac066880140ba2b43eabb75aa3b..562be571d6c863ee643f70c7b7a6df42ae1a801f 100644
--- a/content/browser/indexed_db/indexed_db_factory.cc
+++ b/content/browser/indexed_db/indexed_db_factory.cc
@@ -191,7 +191,15 @@ void IndexedDBFactory::GetDatabaseNames(
return;
}
- callbacks->OnSuccess(backing_store->GetDatabaseNames());
+ leveldb::Status s;
+ std::vector<base::string16> names = backing_store->GetDatabaseNames(s);
+ if (s.ok()) {
jsbell 2014/04/14 20:44:20 I'd reduce this to just an !s.ok() case for now, s
cmumford 2014/04/14 23:39:23 Done.
+ callbacks->OnSuccess(names);
+ } else {
+ // TODO(cmumford): Handle this error
+ DLOG(ERROR) << "Internal error getting database names";
+ callbacks->OnSuccess(names);
+ }
backing_store = NULL;
ReleaseBackingStore(origin_url, false /* immediate */);
}
@@ -230,14 +238,20 @@ void IndexedDBFactory::DeleteDatabase(
return;
}
- scoped_refptr<IndexedDBDatabase> database =
- IndexedDBDatabase::Create(name, backing_store, this, unique_identifier);
+ leveldb::Status s;
+ scoped_refptr<IndexedDBDatabase> database = IndexedDBDatabase::Create(
+ name, backing_store, this, unique_identifier, s);
if (!database) {
- callbacks->OnError(IndexedDBDatabaseError(
+ IndexedDBDatabaseError error(
blink::WebIDBDatabaseExceptionUnknownError,
ASCIIToUTF16(
"Internal error creating database backend for "
- "indexedDB.deleteDatabase.")));
+ "indexedDB.deleteDatabase."));
+ callbacks->OnError(error);
+ if (s.IsCorruption()) {
+ backing_store = NULL; // Closes the LevelDB so that it can be deleted
jsbell 2014/04/14 20:44:20 Does it actually close, or just unblock closing?
cmumford 2014/04/14 23:39:23 If I'm reading that correctly that results in the
+ HandleBackingStoreCorruption(origin_url, error);
+ }
return;
}
@@ -279,9 +293,10 @@ void IndexedDBFactory::HandleBackingStoreCorruption(
HandleBackingStoreFailure(saved_origin_url);
// Note: DestroyBackingStore only deletes LevelDB files, leaving all others,
// so our corruption info file will remain.
- if (!IndexedDBBackingStore::DestroyBackingStore(path_base, saved_origin_url)
- .ok())
- DLOG(ERROR) << "Unable to delete backing store";
+ leveldb::Status s =
+ IndexedDBBackingStore::DestroyBackingStore(path_base, saved_origin_url);
+ if (!s.ok())
+ DLOG(ERROR) << "Unable to delete backing store: " << s.ToString();
}
bool IndexedDBFactory::IsDatabaseOpen(const GURL& origin_url,
@@ -383,13 +398,21 @@ void IndexedDBFactory::Open(const base::string16& name,
return;
}
- database =
- IndexedDBDatabase::Create(name, backing_store, this, unique_identifier);
+ leveldb::Status s;
+ database = IndexedDBDatabase::Create(
+ name, backing_store, this, unique_identifier, s);
if (!database) {
- connection.callbacks->OnError(IndexedDBDatabaseError(
- blink::WebIDBDatabaseExceptionUnknownError,
- ASCIIToUTF16(
- "Internal error creating database backend for indexedDB.open.")));
+ DLOG(ERROR) << "Unable to create the database";
+ IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
+ ASCIIToUTF16(
+ "Internal error creating "
+ "database backend for "
+ "indexedDB.open."));
+ connection.callbacks->OnError(error);
+ if (s.IsCorruption()) {
+ backing_store = NULL; // Closes the LevelDB so that it can be deleted
+ HandleBackingStoreCorruption(origin_url, error);
+ }
return;
}
} else {

Powered by Google App Engine
This is Rietveld 408576698