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

Unified Diff: base/prefs/json_pref_store.h

Issue 1127963002: 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 side-by-side diff with in-line comments
Download patch
Index: base/prefs/json_pref_store.h
diff --git a/base/prefs/json_pref_store.h b/base/prefs/json_pref_store.h
index 2ad546da613df9386fdc6735c80761b2d399e3bb..7c7f2ceb779050f46579cfea4479b69284f2c4dd 100644
--- a/base/prefs/json_pref_store.h
+++ b/base/prefs/json_pref_store.h
@@ -72,6 +72,15 @@ class BASE_PREFS_EXPORT JsonPrefStore
const scoped_refptr<base::SequencedTaskRunner>& sequenced_task_runner,
scoped_ptr<PrefFilter> pref_filter);
+ // Constructor for testing which allows an ImportantFileWriter to be
+ // specified.
+ JsonPrefStore(
+ const base::FilePath& pref_filename,
+ const base::FilePath& pref_alternate_filename,
+ const scoped_refptr<base::SequencedTaskRunner>& sequenced_task_runner,
+ scoped_ptr<base::ImportantFileWriter> file_writer,
+ scoped_ptr<PrefFilter> pref_filter);
+
// PrefStore overrides:
bool GetValue(const std::string& key,
const base::Value** result) const override;
@@ -190,6 +199,10 @@ class BASE_PREFS_EXPORT JsonPrefStore
scoped_ptr<base::DictionaryValue> prefs,
bool schedule_write);
+ // Schedule a write with the file writer as long as |flags| doesn't contain
+ // WriteablePrefStore::LOSSY_PREF_WRITE_FLAG.
+ void ScheduleWrite(uint32 flags);
+
const base::FilePath path_;
const base::FilePath alternate_path_;
const scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_;
@@ -199,7 +212,7 @@ class BASE_PREFS_EXPORT JsonPrefStore
bool read_only_;
// Helper for safely writing pref data.
- base::ImportantFileWriter writer_;
+ scoped_ptr<base::ImportantFileWriter> writer_;
scoped_ptr<PrefFilter> pref_filter_;
ObserverList<PrefStore::Observer, true> observers_;
@@ -208,6 +221,7 @@ class BASE_PREFS_EXPORT JsonPrefStore
bool initialized_;
bool filtering_in_progress_;
+ bool pending_lossy_write_;
PrefReadError read_error_;
std::set<std::string> keys_need_empty_value_;

Powered by Google App Engine
This is Rietveld 408576698