| 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 BASE_PREFS_JSON_PREF_STORE_H_ | 5 #ifndef BASE_PREFS_JSON_PREF_STORE_H_ |
| 6 #define BASE_PREFS_JSON_PREF_STORE_H_ | 6 #define BASE_PREFS_JSON_PREF_STORE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 public: | 40 public: |
| 41 struct ReadResult; | 41 struct ReadResult; |
| 42 | 42 |
| 43 // Returns instance of SequencedTaskRunner which guarantees that file | 43 // Returns instance of SequencedTaskRunner which guarantees that file |
| 44 // operations on the same file will be executed in sequenced order. | 44 // operations on the same file will be executed in sequenced order. |
| 45 static scoped_refptr<base::SequencedTaskRunner> GetTaskRunnerForFile( | 45 static scoped_refptr<base::SequencedTaskRunner> GetTaskRunnerForFile( |
| 46 const base::FilePath& pref_filename, | 46 const base::FilePath& pref_filename, |
| 47 base::SequencedWorkerPool* worker_pool); | 47 base::SequencedWorkerPool* worker_pool); |
| 48 | 48 |
| 49 // Same as the constructor below with no alternate filename. | 49 // Same as the constructor below with no alternate filename. |
| 50 JsonPrefStore(const base::FilePath& pref_filename, | 50 JsonPrefStore( |
| 51 base::SequencedTaskRunner* sequenced_task_runner, | 51 const base::FilePath& pref_filename, |
| 52 scoped_ptr<PrefFilter> pref_filter); | 52 const scoped_refptr<base::SequencedTaskRunner>& sequenced_task_runner, |
| 53 scoped_ptr<PrefFilter> pref_filter); |
| 53 | 54 |
| 54 // |sequenced_task_runner| must be a shutdown-blocking task runner, ideally | 55 // |sequenced_task_runner| must be a shutdown-blocking task runner, ideally |
| 55 // created by the GetTaskRunnerForFile() method above. | 56 // created by the GetTaskRunnerForFile() method above. |
| 56 // |pref_filename| is the path to the file to read prefs from. | 57 // |pref_filename| is the path to the file to read prefs from. |
| 57 // |pref_alternate_filename| is the path to an alternate file which the | 58 // |pref_alternate_filename| is the path to an alternate file which the |
| 58 // desired prefs may have previously been written to. If |pref_filename| | 59 // desired prefs may have previously been written to. If |pref_filename| |
| 59 // doesn't exist and |pref_alternate_filename| does, |pref_alternate_filename| | 60 // doesn't exist and |pref_alternate_filename| does, |pref_alternate_filename| |
| 60 // will be moved to |pref_filename| before the read occurs. | 61 // will be moved to |pref_filename| before the read occurs. |
| 61 JsonPrefStore(const base::FilePath& pref_filename, | 62 JsonPrefStore( |
| 62 const base::FilePath& pref_alternate_filename, | 63 const base::FilePath& pref_filename, |
| 63 base::SequencedTaskRunner* sequenced_task_runner, | 64 const base::FilePath& pref_alternate_filename, |
| 64 scoped_ptr<PrefFilter> pref_filter); | 65 const scoped_refptr<base::SequencedTaskRunner>& sequenced_task_runner, |
| 66 scoped_ptr<PrefFilter> pref_filter); |
| 65 | 67 |
| 66 // PrefStore overrides: | 68 // PrefStore overrides: |
| 67 virtual bool GetValue(const std::string& key, | 69 virtual bool GetValue(const std::string& key, |
| 68 const base::Value** result) const OVERRIDE; | 70 const base::Value** result) const OVERRIDE; |
| 69 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; | 71 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; |
| 70 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; | 72 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; |
| 71 virtual bool HasObservers() const OVERRIDE; | 73 virtual bool HasObservers() const OVERRIDE; |
| 72 virtual bool IsInitializationComplete() const OVERRIDE; | 74 virtual bool IsInitializationComplete() const OVERRIDE; |
| 73 | 75 |
| 74 // PersistentPrefStore overrides: | 76 // PersistentPrefStore overrides: |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 bool initialized_; | 143 bool initialized_; |
| 142 bool filtering_in_progress_; | 144 bool filtering_in_progress_; |
| 143 PrefReadError read_error_; | 145 PrefReadError read_error_; |
| 144 | 146 |
| 145 std::set<std::string> keys_need_empty_value_; | 147 std::set<std::string> keys_need_empty_value_; |
| 146 | 148 |
| 147 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); | 149 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); |
| 148 }; | 150 }; |
| 149 | 151 |
| 150 #endif // BASE_PREFS_JSON_PREF_STORE_H_ | 152 #endif // BASE_PREFS_JSON_PREF_STORE_H_ |
| OLD | NEW |