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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_ 5 #ifndef CHROME_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_
6 #define CHROME_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_ 6 #define CHROME_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 29 matching lines...) Expand all
40 WriteOptions options, 40 WriteOptions options,
41 const std::string& key, 41 const std::string& key,
42 const Value& value) OVERRIDE; 42 const Value& value) OVERRIDE;
43 virtual WriteResult Set( 43 virtual WriteResult Set(
44 WriteOptions options, const DictionaryValue& values) OVERRIDE; 44 WriteOptions options, const DictionaryValue& values) OVERRIDE;
45 virtual WriteResult Remove(const std::string& key) OVERRIDE; 45 virtual WriteResult Remove(const std::string& key) OVERRIDE;
46 virtual WriteResult Remove(const std::vector<std::string>& keys) OVERRIDE; 46 virtual WriteResult Remove(const std::vector<std::string>& keys) OVERRIDE;
47 virtual WriteResult Clear() OVERRIDE; 47 virtual WriteResult Clear() OVERRIDE;
48 48
49 private: 49 private:
50 // Tries to open the database if it hasn't been opened already. Returns the 50 // Tries to open the database if it hasn't been opened already.
51 // error message on failure, or "" on success (guaranteeding that |db_| is 51 scoped_ptr<ValueStore::Error> EnsureDbIsOpen();
52 // non-NULL),
53 std::string EnsureDbIsOpen();
54 52
55 // Reads a setting from the database. Returns the error message on failure, 53 // Reads a setting from the database.
56 // or "" on success in which case |setting| will be reset to the Value read 54 scoped_ptr<ValueStore::Error> ReadFromDb(
57 // from the database. This value may be NULL.
58 std::string ReadFromDb(
59 leveldb::ReadOptions options, 55 leveldb::ReadOptions options,
60 const std::string& key, 56 const std::string& key,
61 // Will be reset() with the result, if any. 57 // Will be reset() with the result, if any.
62 scoped_ptr<Value>* setting); 58 scoped_ptr<Value>* setting);
63 59
64 // Adds a setting to a WriteBatch, and logs the change in |changes|. For use 60 // Adds a setting to a WriteBatch, and logs the change in |changes|. For use
65 // with WriteToDb. Returns the error message on failure, or "" on success. 61 // with WriteToDb.
66 std::string AddToBatch( 62 scoped_ptr<ValueStore::Error> AddToBatch(ValueStore::WriteOptions options,
67 ValueStore::WriteOptions options, 63 const std::string& key,
68 const std::string& key, 64 const base::Value& value,
69 const base::Value& value, 65 leveldb::WriteBatch* batch,
70 leveldb::WriteBatch* batch, 66 ValueStoreChangeList* changes);
71 ValueStoreChangeList* changes);
72 67
73 // Commits the changes in |batch| to the database, returning the error message 68 // Commits the changes in |batch| to the database.
74 // on failure or "" on success. 69 scoped_ptr<ValueStore::Error> WriteToDb(leveldb::WriteBatch* batch);
75 std::string WriteToDb(leveldb::WriteBatch* batch); 70
71 // Converts an error leveldb::Status to a ValueStore::Error. Returns a
72 // scoped_ptr for convenience; the result will always be non-empty.
73 scoped_ptr<ValueStore::Error> ToValueStoreError(
74 const leveldb::Status& status,
75 scoped_ptr<std::string> key);
76
77 // Removes the on-disk database at |db_path_|. Any file system locks should
78 // be released before calling this method.
79 void DeleteDbFile();
76 80
77 // Returns whether the database is empty. 81 // Returns whether the database is empty.
78 bool IsEmpty(); 82 bool IsEmpty();
79 83
80 // The location of the leveldb backend. 84 // The location of the leveldb backend.
81 const base::FilePath db_path_; 85 const base::FilePath db_path_;
82 86
83 // leveldb backend. 87 // leveldb backend.
84 scoped_ptr<leveldb::DB> db_; 88 scoped_ptr<leveldb::DB> db_;
85 89
86 DISALLOW_COPY_AND_ASSIGN(LeveldbValueStore); 90 DISALLOW_COPY_AND_ASSIGN(LeveldbValueStore);
87 }; 91 };
88 92
89 #endif // CHROME_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_ 93 #endif // CHROME_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_
OLDNEW
« 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