OLD | NEW |
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 Loading... |
38 virtual ReadResult Get() OVERRIDE; | 38 virtual ReadResult Get() OVERRIDE; |
39 virtual WriteResult Set( | 39 virtual WriteResult Set( |
40 WriteOptions options, | 40 WriteOptions options, |
41 const std::string& key, | 41 const std::string& key, |
42 const base::Value& value) OVERRIDE; | 42 const base::Value& value) OVERRIDE; |
43 virtual WriteResult Set( | 43 virtual WriteResult Set( |
44 WriteOptions options, const base::DictionaryValue& values) OVERRIDE; | 44 WriteOptions options, const base::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 virtual bool Restore() OVERRIDE; |
| 49 virtual bool RestoreKey(const std::string& key) OVERRIDE; |
| 50 |
| 51 // Write directly to the backing levelDB. Only used for testing to cause |
| 52 // corruption in the database. |
| 53 bool WriteToDbForTest(leveldb::WriteBatch* batch); |
48 | 54 |
49 private: | 55 private: |
50 // Tries to open the database if it hasn't been opened already. | 56 // Tries to open the database if it hasn't been opened already. |
51 scoped_ptr<ValueStore::Error> EnsureDbIsOpen(); | 57 scoped_ptr<ValueStore::Error> EnsureDbIsOpen(); |
52 | 58 |
53 // Reads a setting from the database. | 59 // Reads a setting from the database. |
54 scoped_ptr<ValueStore::Error> ReadFromDb( | 60 scoped_ptr<ValueStore::Error> ReadFromDb( |
55 leveldb::ReadOptions options, | 61 leveldb::ReadOptions options, |
56 const std::string& key, | 62 const std::string& key, |
57 // Will be reset() with the result, if any. | 63 // Will be reset() with the result, if any. |
(...skipping 26 matching lines...) Expand all Loading... |
84 // The location of the leveldb backend. | 90 // The location of the leveldb backend. |
85 const base::FilePath db_path_; | 91 const base::FilePath db_path_; |
86 | 92 |
87 // leveldb backend. | 93 // leveldb backend. |
88 scoped_ptr<leveldb::DB> db_; | 94 scoped_ptr<leveldb::DB> db_; |
89 | 95 |
90 DISALLOW_COPY_AND_ASSIGN(LeveldbValueStore); | 96 DISALLOW_COPY_AND_ASSIGN(LeveldbValueStore); |
91 }; | 97 }; |
92 | 98 |
93 #endif // CHROME_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_ | 99 #endif // CHROME_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_ |
OLD | NEW |