OLD | NEW |
1 // Copyright (c) 2011 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 |
(...skipping 17 matching lines...) Expand all Loading... |
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 JsonPrefStore(const FilePath& pref_filename, | 32 JsonPrefStore(const FilePath& pref_filename, |
33 base::MessageLoopProxy* file_message_loop_proxy); | 33 base::MessageLoopProxy* file_message_loop_proxy); |
34 virtual ~JsonPrefStore(); | 34 virtual ~JsonPrefStore(); |
35 | 35 |
36 // PrefStore overrides: | 36 // PrefStore overrides: |
37 virtual ReadResult GetValue(const std::string& key, | 37 virtual ReadResult GetValue(const std::string& key, |
38 const base::Value** result) const; | 38 const base::Value** result) const OVERRIDE; |
39 virtual void AddObserver(PrefStore::Observer* observer); | 39 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; |
40 virtual void RemoveObserver(PrefStore::Observer* observer); | 40 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; |
41 virtual bool IsInitializationComplete() const; | 41 virtual bool IsInitializationComplete() const OVERRIDE; |
42 | 42 |
43 // PersistentPrefStore overrides: | 43 // PersistentPrefStore overrides: |
44 virtual ReadResult GetMutableValue(const std::string& key, | 44 virtual ReadResult GetMutableValue(const std::string& key, |
45 base::Value** result); | 45 base::Value** result) OVERRIDE; |
46 virtual void SetValue(const std::string& key, base::Value* value); | 46 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; |
47 virtual void SetValueSilently(const std::string& key, base::Value* value); | 47 virtual void SetValueSilently(const std::string& key, |
48 virtual void RemoveValue(const std::string& key); | 48 base::Value* value) OVERRIDE; |
49 virtual bool ReadOnly() const; | 49 virtual void RemoveValue(const std::string& key) OVERRIDE; |
50 virtual PrefReadError ReadPrefs(); | 50 virtual bool ReadOnly() const OVERRIDE; |
51 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate); | 51 virtual PrefReadError ReadPrefs() OVERRIDE; |
52 virtual bool WritePrefs(); | 52 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) OVERRIDE; |
53 virtual void ScheduleWritePrefs(); | 53 virtual bool WritePrefs() OVERRIDE; |
54 virtual void CommitPendingWrite(); | 54 virtual void ScheduleWritePrefs() OVERRIDE; |
55 virtual void ReportValueChanged(const std::string& key); | 55 virtual void CommitPendingWrite() OVERRIDE; |
| 56 virtual void ReportValueChanged(const std::string& key) OVERRIDE; |
56 | 57 |
57 // This method is called after JSON file has been read. Method takes | 58 // This method is called after JSON file has been read. Method takes |
58 // ownership of the |value| pointer. Note, this method is used with | 59 // ownership of the |value| pointer. Note, this method is used with |
59 // asynchronous file reading, so class exposes it only for the internal needs. | 60 // asynchronous file reading, so class exposes it only for the internal needs. |
60 // (read: do not call it manually). | 61 // (read: do not call it manually). |
61 void OnFileRead(base::Value* value_owned, PrefReadError error, bool no_dir); | 62 void OnFileRead(base::Value* value_owned, PrefReadError error, bool no_dir); |
62 | 63 |
63 private: | 64 private: |
64 // ImportantFileWriter::DataSerializer overrides: | 65 // ImportantFileWriter::DataSerializer overrides: |
65 virtual bool SerializeData(std::string* output); | 66 virtual bool SerializeData(std::string* output) OVERRIDE; |
66 | 67 |
67 FilePath path_; | 68 FilePath path_; |
68 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy_; | 69 scoped_refptr<base::MessageLoopProxy> file_message_loop_proxy_; |
69 | 70 |
70 scoped_ptr<base::DictionaryValue> prefs_; | 71 scoped_ptr<base::DictionaryValue> prefs_; |
71 | 72 |
72 bool read_only_; | 73 bool read_only_; |
73 | 74 |
74 // Helper for safely writing pref data. | 75 // Helper for safely writing pref data. |
75 ImportantFileWriter writer_; | 76 ImportantFileWriter writer_; |
76 | 77 |
77 ObserverList<PrefStore::Observer, true> observers_; | 78 ObserverList<PrefStore::Observer, true> observers_; |
78 | 79 |
79 scoped_ptr<ReadErrorDelegate> error_delegate_; | 80 scoped_ptr<ReadErrorDelegate> error_delegate_; |
80 | 81 |
81 bool initialized_; | 82 bool initialized_; |
82 | 83 |
83 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); | 84 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); |
84 }; | 85 }; |
85 | 86 |
86 #endif // CHROME_COMMON_JSON_PREF_STORE_H_ | 87 #endif // CHROME_COMMON_JSON_PREF_STORE_H_ |
OLD | NEW |