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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // doesn't exist and |pref_alternate_filename| does, |pref_alternate_filename| | 60 // doesn't exist and |pref_alternate_filename| does, |pref_alternate_filename| |
61 // will be moved to |pref_filename| before the read occurs. | 61 // will be moved to |pref_filename| before the read occurs. |
62 JsonPrefStore( | 62 JsonPrefStore( |
63 const base::FilePath& pref_filename, | 63 const base::FilePath& pref_filename, |
64 const base::FilePath& pref_alternate_filename, | 64 const base::FilePath& pref_alternate_filename, |
65 const scoped_refptr<base::SequencedTaskRunner>& sequenced_task_runner, | 65 const scoped_refptr<base::SequencedTaskRunner>& sequenced_task_runner, |
66 scoped_ptr<PrefFilter> pref_filter); | 66 scoped_ptr<PrefFilter> pref_filter); |
67 | 67 |
68 // PrefStore overrides: | 68 // PrefStore overrides: |
69 virtual bool GetValue(const std::string& key, | 69 virtual bool GetValue(const std::string& key, |
70 const base::Value** result) const OVERRIDE; | 70 const base::Value** result) const override; |
71 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; | 71 virtual void AddObserver(PrefStore::Observer* observer) override; |
72 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; | 72 virtual void RemoveObserver(PrefStore::Observer* observer) override; |
73 virtual bool HasObservers() const OVERRIDE; | 73 virtual bool HasObservers() const override; |
74 virtual bool IsInitializationComplete() const OVERRIDE; | 74 virtual bool IsInitializationComplete() const override; |
75 | 75 |
76 // PersistentPrefStore overrides: | 76 // PersistentPrefStore overrides: |
77 virtual bool GetMutableValue(const std::string& key, | 77 virtual bool GetMutableValue(const std::string& key, |
78 base::Value** result) OVERRIDE; | 78 base::Value** result) override; |
79 virtual void SetValue(const std::string& key, base::Value* value) OVERRIDE; | 79 virtual void SetValue(const std::string& key, base::Value* value) override; |
80 virtual void SetValueSilently(const std::string& key, | 80 virtual void SetValueSilently(const std::string& key, |
81 base::Value* value) OVERRIDE; | 81 base::Value* value) override; |
82 virtual void RemoveValue(const std::string& key) OVERRIDE; | 82 virtual void RemoveValue(const std::string& key) override; |
83 virtual bool ReadOnly() const OVERRIDE; | 83 virtual bool ReadOnly() const override; |
84 virtual PrefReadError GetReadError() const OVERRIDE; | 84 virtual PrefReadError GetReadError() const override; |
85 // Note this method may be asynchronous if this instance has a |pref_filter_| | 85 // Note this method may be asynchronous if this instance has a |pref_filter_| |
86 // in which case it will return PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE. | 86 // in which case it will return PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE. |
87 // See details in pref_filter.h. | 87 // See details in pref_filter.h. |
88 virtual PrefReadError ReadPrefs() OVERRIDE; | 88 virtual PrefReadError ReadPrefs() override; |
89 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) OVERRIDE; | 89 virtual void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override; |
90 virtual void CommitPendingWrite() OVERRIDE; | 90 virtual void CommitPendingWrite() override; |
91 virtual void ReportValueChanged(const std::string& key) OVERRIDE; | 91 virtual void ReportValueChanged(const std::string& key) override; |
92 | 92 |
93 // Just like RemoveValue(), but doesn't notify observers. Used when doing some | 93 // Just like RemoveValue(), but doesn't notify observers. Used when doing some |
94 // cleanup that shouldn't otherwise alert observers. | 94 // cleanup that shouldn't otherwise alert observers. |
95 void RemoveValueSilently(const std::string& key); | 95 void RemoveValueSilently(const std::string& key); |
96 | 96 |
97 // Registers |on_next_successful_write| to be called once, on the next | 97 // Registers |on_next_successful_write| to be called once, on the next |
98 // successful write event of |writer_|. | 98 // successful write event of |writer_|. |
99 void RegisterOnNextSuccessfulWriteCallback( | 99 void RegisterOnNextSuccessfulWriteCallback( |
100 const base::Closure& on_next_successful_write); | 100 const base::Closure& on_next_successful_write); |
101 | 101 |
102 private: | 102 private: |
103 virtual ~JsonPrefStore(); | 103 virtual ~JsonPrefStore(); |
104 | 104 |
105 // This method is called after the JSON file has been read. It then hands | 105 // This method is called after the JSON file has been read. It then hands |
106 // |value| (or an empty dictionary in some read error cases) to the | 106 // |value| (or an empty dictionary in some read error cases) to the |
107 // |pref_filter| if one is set. It also gives a callback pointing at | 107 // |pref_filter| if one is set. It also gives a callback pointing at |
108 // FinalizeFileRead() to that |pref_filter_| which is then responsible for | 108 // FinalizeFileRead() to that |pref_filter_| which is then responsible for |
109 // invoking it when done. If there is no |pref_filter_|, FinalizeFileRead() | 109 // invoking it when done. If there is no |pref_filter_|, FinalizeFileRead() |
110 // is invoked directly. | 110 // is invoked directly. |
111 void OnFileRead(scoped_ptr<ReadResult> read_result); | 111 void OnFileRead(scoped_ptr<ReadResult> read_result); |
112 | 112 |
113 // ImportantFileWriter::DataSerializer overrides: | 113 // ImportantFileWriter::DataSerializer overrides: |
114 virtual bool SerializeData(std::string* output) OVERRIDE; | 114 virtual bool SerializeData(std::string* output) override; |
115 | 115 |
116 // This method is called after the JSON file has been read and the result has | 116 // This method is called after the JSON file has been read and the result has |
117 // potentially been intercepted and modified by |pref_filter_|. | 117 // potentially been intercepted and modified by |pref_filter_|. |
118 // |initialization_successful| is pre-determined by OnFileRead() and should | 118 // |initialization_successful| is pre-determined by OnFileRead() and should |
119 // be used when reporting OnInitializationCompleted(). | 119 // be used when reporting OnInitializationCompleted(). |
120 // |schedule_write| indicates whether a write should be immediately scheduled | 120 // |schedule_write| indicates whether a write should be immediately scheduled |
121 // (typically because the |pref_filter_| has already altered the |prefs|) -- | 121 // (typically because the |pref_filter_| has already altered the |prefs|) -- |
122 // this will be ignored if this store is read-only. | 122 // this will be ignored if this store is read-only. |
123 void FinalizeFileRead(bool initialization_successful, | 123 void FinalizeFileRead(bool initialization_successful, |
124 scoped_ptr<base::DictionaryValue> prefs, | 124 scoped_ptr<base::DictionaryValue> prefs, |
(...skipping 18 matching lines...) Expand all Loading... |
143 bool initialized_; | 143 bool initialized_; |
144 bool filtering_in_progress_; | 144 bool filtering_in_progress_; |
145 PrefReadError read_error_; | 145 PrefReadError read_error_; |
146 | 146 |
147 std::set<std::string> keys_need_empty_value_; | 147 std::set<std::string> keys_need_empty_value_; |
148 | 148 |
149 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); | 149 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); |
150 }; | 150 }; |
151 | 151 |
152 #endif // BASE_PREFS_JSON_PREF_STORE_H_ | 152 #endif // BASE_PREFS_JSON_PREF_STORE_H_ |
OLD | NEW |