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

Unified Diff: chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.cc

Issue 165223003: Add a Restore() method to ValueStore and make StorageAPI use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 6 years, 10 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: chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.cc
diff --git a/chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.cc b/chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.cc
index f58ff7c1af89762c011ac23727aa6ca0e1657fd5..195e45a492619a602d2cd562838ea509cd9b0786 100644
--- a/chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.cc
+++ b/chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.cc
@@ -4,15 +4,33 @@
#include "chrome/browser/extensions/api/storage/leveldb_settings_storage_factory.h"
+#include "base/file_util.h"
#include "base/logging.h"
#include "chrome/browser/value_store/leveldb_value_store.h"
namespace extensions {
+namespace {
+
+base::FilePath GetDatabasePath(const base::FilePath& base_path,
+ const std::string& extension_id) {
+ return base_path.AppendASCII(extension_id);
+}
+
+} // namespace
+
ValueStore* LeveldbSettingsStorageFactory::Create(
const base::FilePath& base_path,
const std::string& extension_id) {
- return new LeveldbValueStore(base_path.AppendASCII(extension_id));
+ return new LeveldbValueStore(GetDatabasePath(base_path, extension_id));
+}
+
+void LeveldbSettingsStorageFactory::DeleteDatabaseIfExists(
+ const base::FilePath& base_path,
+ const std::string& extension_id) {
+ base::FilePath path = GetDatabasePath(base_path, extension_id);
+ if (base::PathExists(path))
+ base::DeleteFile(path, true /* recursive */);
}
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698