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

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

Issue 347793002: Expand the JsonPrefStore's interface to allow for an alternate filename to be specified. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/prefs/json_pref_store.cc » ('j') | chrome/common/chrome_constants.h » ('J')
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 25 matching lines...) Expand all
36 : public PersistentPrefStore, 36 : public PersistentPrefStore,
37 public base::ImportantFileWriter::DataSerializer, 37 public base::ImportantFileWriter::DataSerializer,
38 public base::SupportsWeakPtr<JsonPrefStore> { 38 public base::SupportsWeakPtr<JsonPrefStore> {
39 public: 39 public:
40 // Returns instance of SequencedTaskRunner which guarantees that file 40 // Returns instance of SequencedTaskRunner which guarantees that file
41 // operations on the same file will be executed in sequenced order. 41 // operations on the same file will be executed in sequenced order.
42 static scoped_refptr<base::SequencedTaskRunner> GetTaskRunnerForFile( 42 static scoped_refptr<base::SequencedTaskRunner> GetTaskRunnerForFile(
43 const base::FilePath& pref_filename, 43 const base::FilePath& pref_filename,
44 base::SequencedWorkerPool* worker_pool); 44 base::SequencedWorkerPool* worker_pool);
45 45
46 // |sequenced_task_runner| is must be a shutdown-blocking task runner, ideally 46 // Same as the constructor below with no alternate filename.
47 // created by GetTaskRunnerForFile() method above.
48 JsonPrefStore(const base::FilePath& pref_filename, 47 JsonPrefStore(const base::FilePath& pref_filename,
49 base::SequencedTaskRunner* sequenced_task_runner, 48 base::SequencedTaskRunner* sequenced_task_runner,
50 scoped_ptr<PrefFilter> pref_filter); 49 scoped_ptr<PrefFilter> pref_filter);
51 50
51 // |sequenced_task_runner| must be a shutdown-blocking task runner, ideally
52 // created by the GetTaskRunnerForFile() method above.
53 // |pref_filename| is the path to the file to read prefs from.
54 // |pref_alternate_filename| is the path to an alternate file which prefs
55 // could be read from. If |pref_filename| exists, |pref_alternate_filename|
Bernhard Bauer 2014/06/19 15:38:09 Why do we delete the alternate pref file if the pr
gab 2014/06/19 16:03:51 The alternate pref file is the old name of the fil
Bernhard Bauer 2014/06/19 17:20:20 Yeah, I'm just a bit wary of deleting a file that
gab 2014/06/19 17:50:10 I'm not really worried of this assumption being in
Bernhard Bauer 2014/06/20 14:16:28 See, my immediate reaction to that would be to tou
gab 2014/06/20 14:48:28 Thanks, as discussed this shouldn't happen in norm
56 // will be deleted; otherwise, |pref_alternate_filename| will be moved to
57 // |pref_filename| before the read occurs.
58 JsonPrefStore(const base::FilePath& pref_filename,
59 const base::FilePath& pref_alternate_filename,
60 base::SequencedTaskRunner* sequenced_task_runner,
61 scoped_ptr<PrefFilter> pref_filter);
62
52 // PrefStore overrides: 63 // PrefStore overrides:
53 virtual bool GetValue(const std::string& key, 64 virtual bool GetValue(const std::string& key,
54 const base::Value** result) const OVERRIDE; 65 const base::Value** result) const OVERRIDE;
55 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; 66 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE;
56 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; 67 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE;
57 virtual bool HasObservers() const OVERRIDE; 68 virtual bool HasObservers() const OVERRIDE;
58 virtual bool IsInitializationComplete() const OVERRIDE; 69 virtual bool IsInitializationComplete() const OVERRIDE;
59 70
60 // PersistentPrefStore overrides: 71 // PersistentPrefStore overrides:
61 virtual bool GetMutableValue(const std::string& key, 72 virtual bool GetMutableValue(const std::string& key,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // potentially been intercepted and modified by |pref_filter_|. 119 // potentially been intercepted and modified by |pref_filter_|.
109 // |initialization_successful| is pre-determined by OnFileRead() and should 120 // |initialization_successful| is pre-determined by OnFileRead() and should
110 // be used when reporting OnInitializationCompleted(). 121 // be used when reporting OnInitializationCompleted().
111 // |schedule_write| indicates whether a write should be immediately scheduled 122 // |schedule_write| indicates whether a write should be immediately scheduled
112 // (typically because the |pref_filter_| has already altered the |prefs|) -- 123 // (typically because the |pref_filter_| has already altered the |prefs|) --
113 // this will be ignored if this store is read-only. 124 // this will be ignored if this store is read-only.
114 void FinalizeFileRead(bool initialization_successful, 125 void FinalizeFileRead(bool initialization_successful,
115 scoped_ptr<base::DictionaryValue> prefs, 126 scoped_ptr<base::DictionaryValue> prefs,
116 bool schedule_write); 127 bool schedule_write);
117 128
118 base::FilePath path_; 129 const base::FilePath path_;
130 const base::FilePath alternate_path_;
119 const scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_; 131 const scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner_;
120 132
121 scoped_ptr<base::DictionaryValue> prefs_; 133 scoped_ptr<base::DictionaryValue> prefs_;
122 134
123 bool read_only_; 135 bool read_only_;
124 136
125 // Helper for safely writing pref data. 137 // Helper for safely writing pref data.
126 base::ImportantFileWriter writer_; 138 base::ImportantFileWriter writer_;
127 139
128 scoped_ptr<PrefFilter> pref_filter_; 140 scoped_ptr<PrefFilter> pref_filter_;
129 ObserverList<PrefStore::Observer, true> observers_; 141 ObserverList<PrefStore::Observer, true> observers_;
130 142
131 scoped_ptr<ReadErrorDelegate> error_delegate_; 143 scoped_ptr<ReadErrorDelegate> error_delegate_;
132 144
133 bool initialized_; 145 bool initialized_;
134 bool filtering_in_progress_; 146 bool filtering_in_progress_;
135 PrefReadError read_error_; 147 PrefReadError read_error_;
136 148
137 std::set<std::string> keys_need_empty_value_; 149 std::set<std::string> keys_need_empty_value_;
138 150
139 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore); 151 DISALLOW_COPY_AND_ASSIGN(JsonPrefStore);
140 }; 152 };
141 153
142 #endif // BASE_PREFS_JSON_PREF_STORE_H_ 154 #endif // BASE_PREFS_JSON_PREF_STORE_H_
OLDNEW
« no previous file with comments | « no previous file | base/prefs/json_pref_store.cc » ('j') | chrome/common/chrome_constants.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698