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

Unified Diff: chrome/browser/value_store/leveldb_value_store.h

Issue 24021002: Propagate more information about ValueStore errors to callers, notably an (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add Pass*() Created 7 years, 3 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/value_store/leveldb_value_store.h
diff --git a/chrome/browser/value_store/leveldb_value_store.h b/chrome/browser/value_store/leveldb_value_store.h
index da8edbc5577da27433a3c10a49f2f49fb27c938f..ce6e484731efdc3dfec4ec61d9e8fba3a804e192 100644
--- a/chrome/browser/value_store/leveldb_value_store.h
+++ b/chrome/browser/value_store/leveldb_value_store.h
@@ -47,32 +47,36 @@ class LeveldbValueStore : public ValueStore {
virtual WriteResult Clear() OVERRIDE;
private:
- // Tries to open the database if it hasn't been opened already. Returns the
- // error message on failure, or "" on success (guaranteeding that |db_| is
- // non-NULL),
- std::string EnsureDbIsOpen();
-
- // Reads a setting from the database. Returns the error message on failure,
- // or "" on success in which case |setting| will be reset to the Value read
- // from the database. This value may be NULL.
- std::string ReadFromDb(
+ // Tries to open the database if it hasn't been opened already.
+ scoped_ptr<ValueStore::Error> EnsureDbIsOpen();
+
+ // Reads a setting from the database.
+ scoped_ptr<ValueStore::Error> ReadFromDb(
leveldb::ReadOptions options,
const std::string& key,
// Will be reset() with the result, if any.
scoped_ptr<Value>* setting);
// Adds a setting to a WriteBatch, and logs the change in |changes|. For use
- // with WriteToDb. Returns the error message on failure, or "" on success.
- std::string AddToBatch(
- ValueStore::WriteOptions options,
- const std::string& key,
- const base::Value& value,
- leveldb::WriteBatch* batch,
- ValueStoreChangeList* changes);
+ // with WriteToDb.
+ scoped_ptr<ValueStore::Error> AddToBatch(ValueStore::WriteOptions options,
+ const std::string& key,
+ const base::Value& value,
+ leveldb::WriteBatch* batch,
+ ValueStoreChangeList* changes);
+
+ // Commits the changes in |batch| to the database.
+ scoped_ptr<ValueStore::Error> WriteToDb(leveldb::WriteBatch* batch);
+
+ // Converts an error leveldb::Status to a ValueStore::Error. Returns a
+ // scoped_ptr for convenience; the result will always be non-empty.
+ scoped_ptr<ValueStore::Error> ToValueStoreError(
+ const leveldb::Status& status,
+ scoped_ptr<std::string> key);
- // Commits the changes in |batch| to the database, returning the error message
- // on failure or "" on success.
- std::string WriteToDb(leveldb::WriteBatch* batch);
+ // Removes the on-disk database at |db_path_|. Any file system locks should
+ // be released before calling this method.
+ void DeleteDbFile();
// Returns whether the database is empty.
bool IsEmpty();
« no previous file with comments | « chrome/browser/sync/test/integration/extension_settings_helper.cc ('k') | chrome/browser/value_store/leveldb_value_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698