Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Side by Side Diff: base/prefs/json_pref_store.h

Issue 1136983004: Revert of Implement lossy pref behavior for JsonPrefStore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@prefs-fix-flags
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/prefs/json_pref_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11 matching lines...) Expand all
22 #include "base/prefs/persistent_pref_store.h" 22 #include "base/prefs/persistent_pref_store.h"
23 #include "base/threading/non_thread_safe.h" 23 #include "base/threading/non_thread_safe.h"
24 24
25 class PrefFilter; 25 class PrefFilter;
26 26
27 namespace base { 27 namespace base {
28 class Clock; 28 class Clock;
29 class DictionaryValue; 29 class DictionaryValue;
30 class FilePath; 30 class FilePath;
31 class HistogramBase; 31 class HistogramBase;
32 class JsonPrefStoreLossyWriteTest;
33 class SequencedTaskRunner; 32 class SequencedTaskRunner;
34 class SequencedWorkerPool; 33 class SequencedWorkerPool;
35 class Value; 34 class Value;
36 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestBasic); 35 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestBasic);
37 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestSinglePeriod); 36 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestSinglePeriod);
38 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestMultiplePeriods); 37 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestMultiplePeriods);
39 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestPeriodWithGaps); 38 FORWARD_DECLARE_TEST(JsonPrefStoreTest, WriteCountHistogramTestPeriodWithGaps);
40 } 39 }
41 40
42 // A writable PrefStore implementation that is used for user preferences. 41 // A writable PrefStore implementation that is used for user preferences.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 }; 158 };
160 159
161 FRIEND_TEST_ALL_PREFIXES(base::JsonPrefStoreTest, 160 FRIEND_TEST_ALL_PREFIXES(base::JsonPrefStoreTest,
162 WriteCountHistogramTestBasic); 161 WriteCountHistogramTestBasic);
163 FRIEND_TEST_ALL_PREFIXES(base::JsonPrefStoreTest, 162 FRIEND_TEST_ALL_PREFIXES(base::JsonPrefStoreTest,
164 WriteCountHistogramTestSinglePeriod); 163 WriteCountHistogramTestSinglePeriod);
165 FRIEND_TEST_ALL_PREFIXES(base::JsonPrefStoreTest, 164 FRIEND_TEST_ALL_PREFIXES(base::JsonPrefStoreTest,
166 WriteCountHistogramTestMultiplePeriods); 165 WriteCountHistogramTestMultiplePeriods);
167 FRIEND_TEST_ALL_PREFIXES(base::JsonPrefStoreTest, 166 FRIEND_TEST_ALL_PREFIXES(base::JsonPrefStoreTest,
168 WriteCountHistogramTestPeriodWithGaps); 167 WriteCountHistogramTestPeriodWithGaps);
169 friend class base::JsonPrefStoreLossyWriteTest;
170 168
171 ~JsonPrefStore() override; 169 ~JsonPrefStore() override;
172 170
173 // This method is called after the JSON file has been read. It then hands 171 // This method is called after the JSON file has been read. It then hands
174 // |value| (or an empty dictionary in some read error cases) to the 172 // |value| (or an empty dictionary in some read error cases) to the
175 // |pref_filter| if one is set. It also gives a callback pointing at 173 // |pref_filter| if one is set. It also gives a callback pointing at
176 // FinalizeFileRead() to that |pref_filter_| which is then responsible for 174 // FinalizeFileRead() to that |pref_filter_| which is then responsible for
177 // invoking it when done. If there is no |pref_filter_|, FinalizeFileRead() 175 // invoking it when done. If there is no |pref_filter_|, FinalizeFileRead()
178 // is invoked directly. 176 // is invoked directly.
179 void OnFileRead(scoped_ptr<ReadResult> read_result); 177 void OnFileRead(scoped_ptr<ReadResult> read_result);
180 178
181 // ImportantFileWriter::DataSerializer overrides: 179 // ImportantFileWriter::DataSerializer overrides:
182 bool SerializeData(std::string* output) override; 180 bool SerializeData(std::string* output) override;
183 181
184 // This method is called after the JSON file has been read and the result has 182 // This method is called after the JSON file has been read and the result has
185 // potentially been intercepted and modified by |pref_filter_|. 183 // potentially been intercepted and modified by |pref_filter_|.
186 // |initialization_successful| is pre-determined by OnFileRead() and should 184 // |initialization_successful| is pre-determined by OnFileRead() and should
187 // be used when reporting OnInitializationCompleted(). 185 // be used when reporting OnInitializationCompleted().
188 // |schedule_write| indicates whether a write should be immediately scheduled 186 // |schedule_write| indicates whether a write should be immediately scheduled
189 // (typically because the |pref_filter_| has already altered the |prefs|) -- 187 // (typically because the |pref_filter_| has already altered the |prefs|) --
190 // this will be ignored if this store is read-only. 188 // this will be ignored if this store is read-only.
191 void FinalizeFileRead(bool initialization_successful, 189 void FinalizeFileRead(bool initialization_successful,
192 scoped_ptr<base::DictionaryValue> prefs, 190 scoped_ptr<base::DictionaryValue> prefs,
193 bool schedule_write); 191 bool schedule_write);
194 192
195 // Schedule a write with the file writer as long as |flags| doesn't contain
196 // WriteablePrefStore::LOSSY_PREF_WRITE_FLAG.
197 void ScheduleWrite(uint32 flags);
198
199 const base::FilePath path_; 193 const base::FilePath path_;
200 const base::FilePath alternate_path_; 194 const base::FilePath alternate_path_;
201 const scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_; 195 const scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_;
202 196
203 scoped_ptr<base::DictionaryValue> prefs_; 197 scoped_ptr<base::DictionaryValue> prefs_;
204 198
205 bool read_only_; 199 bool read_only_;
206 200
207 // Helper for safely writing pref data. 201 // Helper for safely writing pref data.
208 base::ImportantFileWriter writer_; 202 base::ImportantFileWriter writer_;
209 203
210 scoped_ptr<PrefFilter> pref_filter_; 204 scoped_ptr<PrefFilter> pref_filter_;
211 ObserverList<PrefStore::Observer, true> observers_; 205 ObserverList<PrefStore::Observer, true> observers_;
212 206
213 scoped_ptr<ReadErrorDelegate> error_delegate_; 207 scoped_ptr<ReadErrorDelegate> error_delegate_;
214 208
215 bool initialized_; 209 bool initialized_;
216 bool filtering_in_progress_; 210 bool filtering_in_progress_;
217 bool pending_lossy_write_;
218 PrefReadError read_error_; 211 PrefReadError read_error_;
219 212
220 std::set<std::string> keys_need_empty_value_; 213 std::set<std::string> keys_need_empty_value_;
221 214
222 WriteCountHistogram write_count_histogram_; 215 WriteCountHistogram write_count_histogram_;
223 216
224 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); 217 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore);
225 }; 218 };
226 219
227 #endif // BASE_PREFS_JSON_PREF_STORE_H_ 220 #endif // BASE_PREFS_JSON_PREF_STORE_H_
OLDNEW
« no previous file with comments | « no previous file | base/prefs/json_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698