| 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 62%
|
| copy from base/prefs/json_pref_store.h
|
| copy to base/prefs/leveldb_pref_store.h
|
| index ad13feba3f6e1279c7c2bee4d597df35d1698842..ee614e3f981434243bd50a5a5815e190243b2001 100644
|
| --- a/base/prefs/json_pref_store.h
|
| +++ b/base/prefs/leveldb_pref_store.h
|
| @@ -11,40 +11,31 @@
|
| #include "base/basictypes.h"
|
| #include "base/compiler_specific.h"
|
| #include "base/files/file_path.h"
|
| -#include "base/files/important_file_writer.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/message_loop/message_loop_proxy.h"
|
| #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"
|
|
|
| namespace base {
|
| class DictionaryValue;
|
| class FilePath;
|
| class SequencedTaskRunner;
|
| -class SequencedWorkerPool;
|
| 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 +48,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 +60,23 @@ 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 PersistFromUIThread(const std::string& key, base::Value* value);
|
| + 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_;
|
|
|
| - // Helper for safely writing pref data.
|
| - base::ImportantFileWriter writer_;
|
| -
|
| - scoped_ptr<PrefFilter> pref_filter_;
|
| ObserverList<PrefStore::Observer, true> observers_;
|
|
|
| scoped_ptr<ReadErrorDelegate> error_delegate_;
|
| @@ -98,9 +84,10 @@ class BASE_PREFS_EXPORT JsonPrefStore
|
| bool initialized_;
|
| PrefReadError read_error_;
|
|
|
| - std::set<std::string> keys_need_empty_value_;
|
| + class Helper;
|
| + scoped_ptr<Helper> helper_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(JsonPrefStore);
|
| + DISALLOW_COPY_AND_ASSIGN(LevelDBPrefStore);
|
| };
|
|
|
| #endif // BASE_PREFS_JSON_PREF_STORE_H_
|
|
|