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

Side by Side Diff: chrome/browser/value_store/leveldb_value_store.h

Issue 10928227: Make database failures in LeveldbValueStore more descriptive. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove ternary ifs, ms doesnt like Created 8 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
« no previous file with comments | « no previous file | chrome/browser/value_store/leveldb_value_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 27 matching lines...) Expand all
38 virtual WriteResult Set( 38 virtual WriteResult Set(
39 WriteOptions options, const DictionaryValue& values) OVERRIDE; 39 WriteOptions options, const DictionaryValue& values) OVERRIDE;
40 virtual WriteResult Remove(const std::string& key) OVERRIDE; 40 virtual WriteResult Remove(const std::string& key) OVERRIDE;
41 virtual WriteResult Remove(const std::vector<std::string>& keys) OVERRIDE; 41 virtual WriteResult Remove(const std::vector<std::string>& keys) OVERRIDE;
42 virtual WriteResult Clear() OVERRIDE; 42 virtual WriteResult Clear() OVERRIDE;
43 43
44 private: 44 private:
45 // Ownership of db is taken. 45 // Ownership of db is taken.
46 LeveldbValueStore(const FilePath& db_path, leveldb::DB* db); 46 LeveldbValueStore(const FilePath& db_path, leveldb::DB* db);
47 47
48 // Reads a setting from the database. Returns whether the read was 48 // Reads a setting from the database. Returns the error message on failure,
49 // successful, in which case |setting| will be reset to the Value read 49 // or "" on success in which case |setting| will be reset to the Value read
50 // from the database. This value may be NULL. 50 // from the database. This value may be NULL.
51 bool ReadFromDb( 51 std::string ReadFromDb(
52 leveldb::ReadOptions options, 52 leveldb::ReadOptions options,
53 const std::string& key, 53 const std::string& key,
54 // Will be reset() with the result, if any. 54 // Will be reset() with the result, if any.
55 scoped_ptr<Value>* setting); 55 scoped_ptr<Value>* setting);
56 56
57 // Adds a setting to a WriteBatch, and logs the change in |changes|. For 57 // Adds a setting to a WriteBatch, and logs the change in |changes|. For use
58 // use with WriteToDb. 58 // with WriteToDb. Returns the error message on failure, or "" on success.
59 bool AddToBatch( 59 std::string AddToBatch(
60 ValueStore::WriteOptions options, 60 ValueStore::WriteOptions options,
61 const std::string& key, 61 const std::string& key,
62 const base::Value& value, 62 const base::Value& value,
63 leveldb::WriteBatch* batch, 63 leveldb::WriteBatch* batch,
64 ValueStoreChangeList* changes); 64 ValueStoreChangeList* changes);
65 65
66 // Commits the changes in |batch| to the database, and returns a WriteResult 66 // Commits the changes in |batch| to the database, returning the error message
67 // with the changes. 67 // on failure or "" on success.
68 WriteResult WriteToDb( 68 std::string WriteToDb(leveldb::WriteBatch* batch);
69 leveldb::WriteBatch* batch,
70 scoped_ptr<ValueStoreChangeList> changes);
71 69
72 // Returns whether the database is empty. 70 // Returns whether the database is empty.
73 bool IsEmpty(); 71 bool IsEmpty();
74 72
75 // The location of the leveldb backend. 73 // The location of the leveldb backend.
76 const FilePath db_path_; 74 const FilePath db_path_;
77 75
78 // leveldb backend. 76 // leveldb backend.
79 scoped_ptr<leveldb::DB> db_; 77 scoped_ptr<leveldb::DB> db_;
80 78
81 DISALLOW_COPY_AND_ASSIGN(LeveldbValueStore); 79 DISALLOW_COPY_AND_ASSIGN(LeveldbValueStore);
82 }; 80 };
83 81
84 #endif // CHROME_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_ 82 #endif // CHROME_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/value_store/leveldb_value_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698