OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/prefs/profile_pref_store_manager.h" | 5 #include "chrome/browser/prefs/profile_pref_store_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" |
8 #include "base/file_util.h" | 9 #include "base/file_util.h" |
9 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
12 #include "base/prefs/json_pref_store.h" | 13 #include "base/prefs/json_pref_store.h" |
13 #include "base/prefs/persistent_pref_store.h" | 14 #include "base/prefs/persistent_pref_store.h" |
14 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
15 #include "chrome/browser/prefs/pref_hash_store_impl.h" | 16 #include "chrome/browser/prefs/pref_hash_store_impl.h" |
16 #include "chrome/browser/prefs/tracked/pref_service_hash_store_contents.h" | 17 #include "chrome/browser/prefs/tracked/pref_service_hash_store_contents.h" |
17 #include "chrome/browser/prefs/tracked/segregated_pref_store.h" | 18 #include "chrome/browser/prefs/tracked/segregated_pref_store.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return PrefHashFilter::GetResetTime(pref_service); | 75 return PrefHashFilter::GetResetTime(pref_service); |
75 } | 76 } |
76 | 77 |
77 // static | 78 // static |
78 void ProfilePrefStoreManager::ClearResetTime(PrefService* pref_service) { | 79 void ProfilePrefStoreManager::ClearResetTime(PrefService* pref_service) { |
79 PrefHashFilter::ClearResetTime(pref_service); | 80 PrefHashFilter::ClearResetTime(pref_service); |
80 } | 81 } |
81 | 82 |
82 PersistentPrefStore* ProfilePrefStoreManager::CreateProfilePrefStore( | 83 PersistentPrefStore* ProfilePrefStoreManager::CreateProfilePrefStore( |
83 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, | 84 const scoped_refptr<base::SequencedTaskRunner>& io_task_runner, |
| 85 const base::Closure& on_reset_on_load, |
84 TrackedPreferenceValidationDelegate* validation_delegate) { | 86 TrackedPreferenceValidationDelegate* validation_delegate) { |
85 scoped_ptr<PrefFilter> pref_filter; | 87 scoped_ptr<PrefFilter> pref_filter; |
86 if (!kPlatformSupportsPreferenceTracking) { | 88 if (!kPlatformSupportsPreferenceTracking) { |
87 return new JsonPrefStore(GetPrefFilePathFromProfilePath(profile_path_), | 89 return new JsonPrefStore(GetPrefFilePathFromProfilePath(profile_path_), |
88 io_task_runner, | 90 io_task_runner, |
89 scoped_ptr<PrefFilter>()); | 91 scoped_ptr<PrefFilter>()); |
90 } | 92 } |
91 | 93 |
92 std::vector<PrefHashFilter::TrackedPreferenceMetadata> | 94 std::vector<PrefHashFilter::TrackedPreferenceMetadata> |
93 unprotected_configuration; | 95 unprotected_configuration; |
(...skipping 10 matching lines...) Expand all Loading... |
104 protected_pref_names.insert(it->name); | 106 protected_pref_names.insert(it->name); |
105 } else { | 107 } else { |
106 unprotected_configuration.push_back(*it); | 108 unprotected_configuration.push_back(*it); |
107 unprotected_pref_names.insert(it->name); | 109 unprotected_pref_names.insert(it->name); |
108 } | 110 } |
109 } | 111 } |
110 | 112 |
111 scoped_ptr<PrefHashFilter> unprotected_pref_hash_filter( | 113 scoped_ptr<PrefHashFilter> unprotected_pref_hash_filter( |
112 new PrefHashFilter(GetPrefHashStore(false), | 114 new PrefHashFilter(GetPrefHashStore(false), |
113 unprotected_configuration, | 115 unprotected_configuration, |
| 116 base::Closure(), |
114 validation_delegate, | 117 validation_delegate, |
115 reporting_ids_count_, | 118 reporting_ids_count_, |
116 false)); | 119 false)); |
117 scoped_ptr<PrefHashFilter> protected_pref_hash_filter( | 120 scoped_ptr<PrefHashFilter> protected_pref_hash_filter( |
118 new PrefHashFilter(GetPrefHashStore(true), | 121 new PrefHashFilter(GetPrefHashStore(true), |
119 protected_configuration, | 122 protected_configuration, |
| 123 on_reset_on_load, |
120 validation_delegate, | 124 validation_delegate, |
121 reporting_ids_count_, | 125 reporting_ids_count_, |
122 true)); | 126 true)); |
123 | 127 |
124 PrefHashFilter* raw_unprotected_pref_hash_filter = | 128 PrefHashFilter* raw_unprotected_pref_hash_filter = |
125 unprotected_pref_hash_filter.get(); | 129 unprotected_pref_hash_filter.get(); |
126 PrefHashFilter* raw_protected_pref_hash_filter = | 130 PrefHashFilter* raw_protected_pref_hash_filter = |
127 protected_pref_hash_filter.get(); | 131 protected_pref_hash_filter.get(); |
128 | 132 |
129 scoped_refptr<JsonPrefStore> unprotected_pref_store( | 133 scoped_refptr<JsonPrefStore> unprotected_pref_store( |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 return false; | 172 return false; |
169 | 173 |
170 const base::DictionaryValue* to_serialize = &master_prefs; | 174 const base::DictionaryValue* to_serialize = &master_prefs; |
171 scoped_ptr<base::DictionaryValue> copy; | 175 scoped_ptr<base::DictionaryValue> copy; |
172 | 176 |
173 if (kPlatformSupportsPreferenceTracking) { | 177 if (kPlatformSupportsPreferenceTracking) { |
174 copy.reset(master_prefs.DeepCopy()); | 178 copy.reset(master_prefs.DeepCopy()); |
175 to_serialize = copy.get(); | 179 to_serialize = copy.get(); |
176 PrefHashFilter(GetPrefHashStore(false), | 180 PrefHashFilter(GetPrefHashStore(false), |
177 tracking_configuration_, | 181 tracking_configuration_, |
| 182 base::Closure(), |
178 NULL, | 183 NULL, |
179 reporting_ids_count_, | 184 reporting_ids_count_, |
180 false).Initialize(copy.get()); | 185 false).Initialize(copy.get()); |
181 } | 186 } |
182 | 187 |
183 // This will write out to a single combined file which will be immediately | 188 // This will write out to a single combined file which will be immediately |
184 // migrated to two files on load. | 189 // migrated to two files on load. |
185 JSONFileValueSerializer serializer( | 190 JSONFileValueSerializer serializer( |
186 GetPrefFilePathFromProfilePath(profile_path_)); | 191 GetPrefFilePathFromProfilePath(profile_path_)); |
187 | 192 |
(...skipping 14 matching lines...) Expand all Loading... |
202 scoped_ptr<PrefFilter> pref_filter; | 207 scoped_ptr<PrefFilter> pref_filter; |
203 if (kPlatformSupportsPreferenceTracking) { | 208 if (kPlatformSupportsPreferenceTracking) { |
204 scoped_ptr<PrefHashStoreImpl> pref_hash_store_impl( | 209 scoped_ptr<PrefHashStoreImpl> pref_hash_store_impl( |
205 new PrefHashStoreImpl(seed_, device_id_, true)); | 210 new PrefHashStoreImpl(seed_, device_id_, true)); |
206 pref_hash_store_impl->set_legacy_hash_store_contents( | 211 pref_hash_store_impl->set_legacy_hash_store_contents( |
207 scoped_ptr<HashStoreContents>(new PrefServiceHashStoreContents( | 212 scoped_ptr<HashStoreContents>(new PrefServiceHashStoreContents( |
208 profile_path_.AsUTF8Unsafe(), local_state_))); | 213 profile_path_.AsUTF8Unsafe(), local_state_))); |
209 pref_filter.reset( | 214 pref_filter.reset( |
210 new PrefHashFilter(pref_hash_store_impl.PassAs<PrefHashStore>(), | 215 new PrefHashFilter(pref_hash_store_impl.PassAs<PrefHashStore>(), |
211 tracking_configuration_, | 216 tracking_configuration_, |
| 217 base::Closure(), |
212 NULL, | 218 NULL, |
213 reporting_ids_count_, | 219 reporting_ids_count_, |
214 false)); | 220 false)); |
215 } | 221 } |
216 return new JsonPrefStore(GetPrefFilePathFromProfilePath(profile_path_), | 222 return new JsonPrefStore(GetPrefFilePathFromProfilePath(profile_path_), |
217 io_task_runner, | 223 io_task_runner, |
218 pref_filter.Pass()); | 224 pref_filter.Pass()); |
219 } | 225 } |
220 | 226 |
221 scoped_ptr<PrefHashStore> ProfilePrefStoreManager::GetPrefHashStore( | 227 scoped_ptr<PrefHashStore> ProfilePrefStoreManager::GetPrefHashStore( |
222 bool use_super_mac) { | 228 bool use_super_mac) { |
223 DCHECK(kPlatformSupportsPreferenceTracking); | 229 DCHECK(kPlatformSupportsPreferenceTracking); |
224 | 230 |
225 return scoped_ptr<PrefHashStore>(new PrefHashStoreImpl( | 231 return scoped_ptr<PrefHashStore>(new PrefHashStoreImpl( |
226 seed_, | 232 seed_, |
227 device_id_, | 233 device_id_, |
228 use_super_mac)); | 234 use_super_mac)); |
229 } | 235 } |
OLD | NEW |