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

Unified Diff: webkit/fileapi/file_system_database_test_helper.cc

Issue 13946004: FileAPI: Run database recovery on IOError. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: +test Created 7 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: webkit/fileapi/file_system_database_test_helper.cc
diff --git a/webkit/fileapi/file_system_database_test_helper.cc b/webkit/fileapi/file_system_database_test_helper.cc
index da1a5e13a28135a79a57caac5220f18e5a4913dc..a638faae24279b9445deeca10071913d4517b629 100644
--- a/webkit/fileapi/file_system_database_test_helper.cc
+++ b/webkit/fileapi/file_system_database_test_helper.cc
@@ -79,4 +79,31 @@ void CorruptDatabase(const base::FilePath& db_path,
base::ClosePlatformFile(file);
}
+void DeleteDatabaseFile(const base::FilePath& db_path,
+ leveldb::FileType type) {
+ file_util::FileEnumerator file_enum(db_path, false /* not recursive */,
+ file_util::FileEnumerator::DIRECTORIES |
+ file_util::FileEnumerator::FILES);
+ base::FilePath file_path;
+ base::FilePath picked_file_path;
+ uint64 picked_file_number = kuint64max;
+
+ while (!(file_path = file_enum.Next()).empty()) {
+ uint64 number = kuint64max;
+ leveldb::FileType file_type;
+ EXPECT_TRUE(leveldb::ParseFileName(FilePathToString(file_path.BaseName()),
+ &number, &file_type));
+ if (file_type == type &&
+ (picked_file_number == kuint64max || picked_file_number < number)) {
+ picked_file_path = file_path;
+ picked_file_number = number;
kinuko 2013/04/10 06:23:49 Maybe we could just delete all files rather than p
tzik 2013/04/10 06:49:20 Done.
+ }
+ }
+
+ EXPECT_FALSE(picked_file_path.empty());
+ EXPECT_NE(kuint64max, picked_file_number);
+
+ file_util::Delete(picked_file_path, false);
+}
+
} // namespace fileapi

Powered by Google App Engine
This is Rietveld 408576698