OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_COMMON_JSON_PREF_STORE_H_ | 5 #ifndef CHROME_COMMON_JSON_PREF_STORE_H_ |
6 #define CHROME_COMMON_JSON_PREF_STORE_H_ | 6 #define CHROME_COMMON_JSON_PREF_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
22 class DictionaryValue; | 22 class DictionaryValue; |
23 class FilePath; | 23 class FilePath; |
24 class Value; | 24 class Value; |
25 | 25 |
26 // A writable PrefStore implementation that is used for user preferences. | 26 // A writable PrefStore implementation that is used for user preferences. |
27 class JsonPrefStore : public PersistentPrefStore, | 27 class JsonPrefStore : public PersistentPrefStore, |
28 public ImportantFileWriter::DataSerializer { | 28 public ImportantFileWriter::DataSerializer { |
29 public: | 29 public: |
30 // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which | 30 // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which |
31 // file I/O can be done. | 31 // file I/O can be done. |
32 // |source| is source to be used for sending PREF_COMMMITTED notification. | |
32 JsonPrefStore(const FilePath& pref_filename, | 33 JsonPrefStore(const FilePath& pref_filename, |
33 base::MessageLoopProxy* file_message_loop_proxy); | 34 base::MessageLoopProxy* file_message_loop_proxy); |
34 virtual ~JsonPrefStore(); | 35 virtual ~JsonPrefStore(); |
35 | 36 |
36 // PrefStore overrides: | 37 // PrefStore overrides: |
37 virtual ReadResult GetValue(const std::string& key, Value** result) const; | 38 virtual ReadResult GetValue(const std::string& key, Value** result) const; |
38 virtual void AddObserver(PrefStore::Observer* observer); | 39 virtual void AddObserver(PrefStore::Observer* observer); |
39 virtual void RemoveObserver(PrefStore::Observer* observer); | 40 virtual void RemoveObserver(PrefStore::Observer* observer); |
40 | 41 |
41 // PersistentPrefStore overrides: | 42 // PersistentPrefStore overrides: |
42 virtual void SetValue(const std::string& key, Value* value); | 43 virtual void SetValue(const std::string& key, Value* value); |
43 virtual void SetValueSilently(const std::string& key, Value* value); | 44 virtual void SetValueSilently(const std::string& key, Value* value); |
44 virtual void RemoveValue(const std::string& key); | 45 virtual void RemoveValue(const std::string& key); |
45 virtual bool ReadOnly() const; | 46 virtual bool ReadOnly() const; |
46 virtual PrefReadError ReadPrefs(); | 47 virtual PrefReadError ReadPrefs(); |
47 virtual bool WritePrefs(); | 48 virtual bool WritePrefs(); |
48 virtual void ScheduleWritePrefs(); | 49 virtual void ScheduleWritePrefs(); |
50 virtual void CommitPendingWrite(); | |
51 void SetNotificationSource(const NotificationSource& source); | |
Mattias Nissler (ping if slow)
2011/03/23 15:12:37
This is not well-defined. Note that a PrefStore ca
| |
49 // TODO(battre) remove this function | 52 // TODO(battre) remove this function |
50 virtual void ReportValueChanged(const std::string& key); | 53 virtual void ReportValueChanged(const std::string& key); |
51 | 54 |
52 private: | 55 private: |
53 // ImportantFileWriter::DataSerializer overrides: | 56 // ImportantFileWriter::DataSerializer overrides: |
54 virtual bool SerializeData(std::string* output); | 57 virtual bool SerializeData(std::string* output); |
55 | 58 |
56 FilePath path_; | 59 FilePath path_; |
57 | 60 |
58 scoped_ptr<DictionaryValue> prefs_; | 61 scoped_ptr<DictionaryValue> prefs_; |
59 | 62 |
60 bool read_only_; | 63 bool read_only_; |
61 | 64 |
62 // Helper for safely writing pref data. | 65 // Helper for safely writing pref data. |
63 ImportantFileWriter writer_; | 66 ImportantFileWriter writer_; |
64 | 67 |
68 // Source for PREF_COMMITTED notification. | |
69 NotificationSource source_; | |
70 | |
65 ObserverList<PrefStore::Observer, true> observers_; | 71 ObserverList<PrefStore::Observer, true> observers_; |
66 | 72 |
67 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); | 73 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); |
68 }; | 74 }; |
69 | 75 |
70 #endif // CHROME_COMMON_JSON_PREF_STORE_H_ | 76 #endif // CHROME_COMMON_JSON_PREF_STORE_H_ |
OLD | NEW |