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 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/important_file_writer.h" | 14 #include "base/files/important_file_writer.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/message_loop/message_loop_proxy.h" | 16 #include "base/message_loop/message_loop_proxy.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "base/prefs/base_prefs_export.h" | 18 #include "base/prefs/base_prefs_export.h" |
19 #include "base/prefs/persistent_pref_store.h" | 19 #include "base/prefs/persistent_pref_store.h" |
20 | 20 |
21 namespace base { | 21 namespace base { |
22 class DictionaryValue; | 22 class DictionaryValue; |
23 class FilePath; | 23 class FilePath; |
| 24 class SequencedTaskRunner; |
24 class SequencedWorkerPool; | 25 class SequencedWorkerPool; |
25 class SequencedTaskRunner; | |
26 class Value; | 26 class Value; |
27 } | 27 } |
28 | 28 |
29 | 29 |
30 // A writable PrefStore implementation that is used for user preferences. | 30 // A writable PrefStore implementation that is used for user preferences. |
31 class BASE_PREFS_EXPORT JsonPrefStore | 31 class BASE_PREFS_EXPORT JsonPrefStore |
32 : public PersistentPrefStore, | 32 : public PersistentPrefStore, |
33 public base::ImportantFileWriter::DataSerializer { | 33 public base::ImportantFileWriter::DataSerializer { |
34 public: | 34 public: |
35 // Returns instance of SequencedTaskRunner which guarantees that file | 35 // Returns instance of SequencedTaskRunner which guarantees that file |
(...skipping 15 matching lines...) Expand all Loading... |
51 virtual bool HasObservers() const OVERRIDE; | 51 virtual bool HasObservers() const OVERRIDE; |
52 virtual bool IsInitializationComplete() const OVERRIDE; | 52 virtual bool IsInitializationComplete() const OVERRIDE; |
53 | 53 |
54 // PersistentPrefStore overrides: | 54 // PersistentPrefStore overrides: |
55 virtual bool GetMutableValue(const std::string& key, | 55 virtual bool GetMutableValue(const std::string& key, |
56 base::Value** result) OVERRIDE; | 56 base::Value** result) OVERRIDE; |
57 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; | 57 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; |
58 virtual void SetValueSilently(const std::string& key, | 58 virtual void SetValueSilently(const std::string& key, |
59 base::Value* value) OVERRIDE; | 59 base::Value* value) OVERRIDE; |
60 virtual void RemoveValue(const std::string& key) OVERRIDE; | 60 virtual void RemoveValue(const std::string& key) OVERRIDE; |
61 virtual void MarkNeedsEmptyValue(const std::string& key) OVERRIDE; | |
62 virtual bool ReadOnly() const OVERRIDE; | 61 virtual bool ReadOnly() const OVERRIDE; |
63 virtual PrefReadError GetReadError() const OVERRIDE; | 62 virtual PrefReadError GetReadError() const OVERRIDE; |
64 virtual PrefReadError ReadPrefs() OVERRIDE; | 63 virtual PrefReadError ReadPrefs() OVERRIDE; |
65 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) OVERRIDE; | 64 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) OVERRIDE; |
66 virtual void CommitPendingWrite() OVERRIDE; | 65 virtual void CommitPendingWrite() OVERRIDE; |
67 virtual void ReportValueChanged(const std::string& key) OVERRIDE; | 66 virtual void ReportValueChanged(const std::string& key) OVERRIDE; |
68 | 67 |
69 // This method is called after JSON file has been read. Method takes | 68 // This method is called after JSON file has been read. Method takes |
70 // ownership of the |value| pointer. Note, this method is used with | 69 // ownership of the |value| pointer. Note, this method is used with |
71 // asynchronous file reading, so class exposes it only for the internal needs. | 70 // asynchronous file reading, so class exposes it only for the internal needs. |
(...skipping 22 matching lines...) Expand all Loading... |
94 | 93 |
95 bool initialized_; | 94 bool initialized_; |
96 PrefReadError read_error_; | 95 PrefReadError read_error_; |
97 | 96 |
98 std::set<std::string> keys_need_empty_value_; | 97 std::set<std::string> keys_need_empty_value_; |
99 | 98 |
100 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); | 99 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); |
101 }; | 100 }; |
102 | 101 |
103 #endif // BASE_PREFS_JSON_PREF_STORE_H_ | 102 #endif // BASE_PREFS_JSON_PREF_STORE_H_ |
OLD | NEW |