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/file_path.h" | 13 #include "base/file_path.h" |
| 14 #include "base/files/important_file_writer.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/message_loop_proxy.h" |
15 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
16 #include "base/prefs/persistent_pref_store.h" | 18 #include "base/prefs/persistent_pref_store.h" |
17 #include "chrome/common/important_file_writer.h" | |
18 | 19 |
19 namespace base { | 20 namespace base { |
20 class DictionaryValue; | 21 class DictionaryValue; |
21 class MessageLoopProxy; | 22 class MessageLoopProxy; |
22 class Value; | 23 class Value; |
23 } | 24 } |
24 | 25 |
25 class FilePath; | 26 class FilePath; |
26 | 27 |
27 // A writable PrefStore implementation that is used for user preferences. | 28 // A writable PrefStore implementation that is used for user preferences. |
28 class JsonPrefStore : public PersistentPrefStore, | 29 class JsonPrefStore : public PersistentPrefStore, |
29 public ImportantFileWriter::DataSerializer { | 30 public base::ImportantFileWriter::DataSerializer { |
30 public: | 31 public: |
31 // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which | 32 // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which |
32 // file I/O can be done. | 33 // file I/O can be done. |
33 JsonPrefStore(const FilePath& pref_filename, | 34 JsonPrefStore(const FilePath& pref_filename, |
34 base::MessageLoopProxy* file_message_loop_proxy); | 35 base::MessageLoopProxy* file_message_loop_proxy); |
35 | 36 |
36 // PrefStore overrides: | 37 // PrefStore overrides: |
37 virtual ReadResult GetValue(const std::string& key, | 38 virtual ReadResult GetValue(const std::string& key, |
38 const base::Value** result) const OVERRIDE; | 39 const base::Value** result) const OVERRIDE; |
39 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; | 40 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; |
(...skipping 29 matching lines...) Expand all Loading... |
69 virtual bool SerializeData(std::string* output) OVERRIDE; | 70 virtual bool SerializeData(std::string* output) OVERRIDE; |
70 | 71 |
71 FilePath path_; | 72 FilePath path_; |
72 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy_; | 73 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy_; |
73 | 74 |
74 scoped_ptr<base::DictionaryValue> prefs_; | 75 scoped_ptr<base::DictionaryValue> prefs_; |
75 | 76 |
76 bool read_only_; | 77 bool read_only_; |
77 | 78 |
78 // Helper for safely writing pref data. | 79 // Helper for safely writing pref data. |
79 ImportantFileWriter writer_; | 80 base::ImportantFileWriter writer_; |
80 | 81 |
81 ObserverList<PrefStore::Observer, true> observers_; | 82 ObserverList<PrefStore::Observer, true> observers_; |
82 | 83 |
83 scoped_ptr<ReadErrorDelegate> error_delegate_; | 84 scoped_ptr<ReadErrorDelegate> error_delegate_; |
84 | 85 |
85 bool initialized_; | 86 bool initialized_; |
86 PrefReadError read_error_; | 87 PrefReadError read_error_; |
87 | 88 |
88 std::set<std::string> keys_need_empty_value_; | 89 std::set<std::string> keys_need_empty_value_; |
89 | 90 |
90 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); | 91 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); |
91 }; | 92 }; |
92 | 93 |
93 #endif // BASE_PREFS_JSON_PREF_STORE_H_ | 94 #endif // BASE_PREFS_JSON_PREF_STORE_H_ |
OLD | NEW |