| 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); | |
| 54 | 48 |
| 55 private: | 49 private: |
| 56 // Tries to open the database if it hasn't been opened already. | 50 // Tries to open the database if it hasn't been opened already. |
| 57 scoped_ptr<ValueStore::Error> EnsureDbIsOpen(); | 51 scoped_ptr<ValueStore::Error> EnsureDbIsOpen(); |
| 58 | 52 |
| 59 // Reads a setting from the database. | 53 // Reads a setting from the database. |
| 60 scoped_ptr<ValueStore::Error> ReadFromDb( | 54 scoped_ptr<ValueStore::Error> ReadFromDb( |
| 61 leveldb::ReadOptions options, | 55 leveldb::ReadOptions options, |
| 62 const std::string& key, | 56 const std::string& key, |
| 63 // Will be reset() with the result, if any. | 57 // Will be reset() with the result, if any. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 90 // The location of the leveldb backend. | 84 // The location of the leveldb backend. |
| 91 const base::FilePath db_path_; | 85 const base::FilePath db_path_; |
| 92 | 86 |
| 93 // leveldb backend. | 87 // leveldb backend. |
| 94 scoped_ptr<leveldb::DB> db_; | 88 scoped_ptr<leveldb::DB> db_; |
| 95 | 89 |
| 96 DISALLOW_COPY_AND_ASSIGN(LeveldbValueStore); | 90 DISALLOW_COPY_AND_ASSIGN(LeveldbValueStore); |
| 97 }; | 91 }; |
| 98 | 92 |
| 99 #endif // CHROME_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_ | 93 #endif // CHROME_BROWSER_VALUE_STORE_LEVELDB_VALUE_STORE_H_ |
| OLD | NEW |