Index: base/prefs/leveldb_pref_store.h |
diff --git a/base/prefs/json_pref_store.h b/base/prefs/leveldb_pref_store.h |
similarity index 64% |
copy from base/prefs/json_pref_store.h |
copy to base/prefs/leveldb_pref_store.h |
index ad13feba3f6e1279c7c2bee4d597df35d1698842..2adda6bc57607ae54ab6b757177b22473e7a5056 100644 |
--- a/base/prefs/json_pref_store.h |
+++ b/base/prefs/leveldb_pref_store.h |
@@ -17,34 +17,28 @@ |
#include "base/observer_list.h" |
#include "base/prefs/base_prefs_export.h" |
#include "base/prefs/persistent_pref_store.h" |
- |
-class PrefFilter; |
+#include "base/prefs/pref_value_map.h" |
+#include "third_party/leveldatabase/src/include/leveldb/db.h" |
namespace base { |
class DictionaryValue; |
class FilePath; |
-class SequencedTaskRunner; |
class SequencedWorkerPool; |
Mattias Nissler (ping if slow)
2014/02/25 10:51:44
not used?
if it is, then please alphabetize
dgrogan
2014/03/05 03:06:58
Done.
|
+class SequencedTaskRunner; |
class Value; |
} |
+namespace leveldb { |
+class DB; |
+} |
// A writable PrefStore implementation that is used for user preferences. |
-class BASE_PREFS_EXPORT JsonPrefStore |
- : public PersistentPrefStore, |
- public base::ImportantFileWriter::DataSerializer { |
+class BASE_PREFS_EXPORT LevelDBPrefStore : public PersistentPrefStore { |
public: |
- // Returns instance of SequencedTaskRunner which guarantees that file |
- // operations on the same file will be executed in sequenced order. |
- static scoped_refptr<base::SequencedTaskRunner> GetTaskRunnerForFile( |
- const base::FilePath& pref_filename, |
- base::SequencedWorkerPool* worker_pool); |
- |
// |sequenced_task_runner| is must be a shutdown-blocking task runner, ideally |
// created by GetTaskRunnerForFile() method above. |
- JsonPrefStore(const base::FilePath& pref_filename, |
- base::SequencedTaskRunner* sequenced_task_runner, |
- scoped_ptr<PrefFilter> pref_filter); |
+ LevelDBPrefStore(const base::FilePath& pref_filename, |
+ base::SequencedTaskRunner* sequenced_task_runner); |
// PrefStore overrides: |
virtual bool GetValue(const std::string& key, |
@@ -57,6 +51,7 @@ class BASE_PREFS_EXPORT JsonPrefStore |
// PersistentPrefStore overrides: |
virtual bool GetMutableValue(const std::string& key, |
base::Value** result) OVERRIDE; |
+ // Takes ownership of value. |
virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; |
virtual void SetValueSilently(const std::string& key, |
base::Value* value) OVERRIDE; |
@@ -68,29 +63,27 @@ class BASE_PREFS_EXPORT JsonPrefStore |
virtual void CommitPendingWrite() OVERRIDE; |
virtual void ReportValueChanged(const std::string& key) OVERRIDE; |
- // This method is called after JSON file has been read. Method takes |
- // ownership of the |value| pointer. Note, this method is used with |
- // asynchronous file reading, so class exposes it only for the internal needs. |
- // (read: do not call it manually). |
- void OnFileRead(base::Value* value_owned, PrefReadError error, bool no_dir); |
- |
private: |
- virtual ~JsonPrefStore(); |
+ virtual ~LevelDBPrefStore(); |
+ |
+ void PersistOnFileThread(const std::string& key, const std::string& value); |
+ void PersistFromUIThread(const std::string& key, base::Value* value); |
+ void RemoveOnFileThread(const std::string& key); |
+ void RemoveFromUIThread(const std::string& key); |
- // ImportantFileWriter::DataSerializer overrides: |
- virtual bool SerializeData(std::string* output) OVERRIDE; |
+ void NotifyObservers(const std::string& key); |
+ void OnStorageRead(PrefReadError error, bool no_dir); |
base::FilePath path_; |
const scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_; |
+ const scoped_refptr<base::SequencedTaskRunner> original_task_runner_; |
- scoped_ptr<base::DictionaryValue> prefs_; |
+ PrefValueMap prefs_; |
- bool read_only_; |
+ scoped_ptr<leveldb::DB> db_; |
- // Helper for safely writing pref data. |
- base::ImportantFileWriter writer_; |
+ bool read_only_; |
- scoped_ptr<PrefFilter> pref_filter_; |
ObserverList<PrefStore::Observer, true> observers_; |
scoped_ptr<ReadErrorDelegate> error_delegate_; |
@@ -98,9 +91,7 @@ class BASE_PREFS_EXPORT JsonPrefStore |
bool initialized_; |
PrefReadError read_error_; |
- std::set<std::string> keys_need_empty_value_; |
- |
- DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); |
+ DISALLOW_COPY_AND_ASSIGN(LevelDBPrefStore); |
}; |
#endif // BASE_PREFS_JSON_PREF_STORE_H_ |