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

Side by Side Diff: chrome/browser/prefs/profile_pref_store_manager.cc

Issue 220203011: Changes requested by gab for previously committed CLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
OLDNEW
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/file_util.h" 7 #include "base/file_util.h"
8 #include "base/json/json_file_value_serializer.h" 8 #include "base/json/json_file_value_serializer.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 125
126 private: 126 private:
127 virtual ~DictionaryPrefStore() {} 127 virtual ~DictionaryPrefStore() {}
128 128
129 const base::DictionaryValue* dictionary_; 129 const base::DictionaryValue* dictionary_;
130 130
131 DISALLOW_COPY_AND_ASSIGN(DictionaryPrefStore); 131 DISALLOW_COPY_AND_ASSIGN(DictionaryPrefStore);
132 }; 132 };
133 133
134 } // namespace
135
136 // TODO(erikwright): Enable this on Chrome OS and Android once MACs are moved
137 // out of Local State. This will resolve a race condition on Android and a
138 // privacy issue on ChromeOS. http://crbug.com/349158
139 const bool ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking =
140 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
141 false;
142 #else
143 true;
144 #endif
145
146 // Waits for a PrefStore to be initialized and then initializes the 134 // Waits for a PrefStore to be initialized and then initializes the
147 // corresponding PrefHashStore. 135 // corresponding PrefHashStore.
148 // The observer deletes itself when its work is completed. 136 // The observer deletes itself when its work is completed.
149 class ProfilePrefStoreManager::InitializeHashStoreObserver 137 class InitializeHashStoreObserver : public PrefStore::Observer {
150 : public PrefStore::Observer {
151 public: 138 public:
152 // Creates an observer that will initialize |pref_hash_store| with the 139 // Creates an observer that will initialize |pref_hash_store| with the
153 // contents of |pref_store| when the latter is fully loaded. 140 // contents of |pref_store| when the latter is fully loaded.
154 InitializeHashStoreObserver( 141 InitializeHashStoreObserver(
155 const std::vector<PrefHashFilter::TrackedPreferenceMetadata>& 142 const std::vector<PrefHashFilter::TrackedPreferenceMetadata>&
156 tracking_configuration, 143 tracking_configuration,
157 size_t reporting_ids_count, 144 size_t reporting_ids_count,
158 const scoped_refptr<PrefStore>& pref_store, 145 const scoped_refptr<PrefStore>& pref_store,
159 scoped_ptr<PrefHashStoreImpl> pref_hash_store_impl) 146 scoped_ptr<PrefHashStoreImpl> pref_hash_store_impl)
160 : tracking_configuration_(tracking_configuration), 147 : tracking_configuration_(tracking_configuration),
(...skipping 10 matching lines...) Expand all
171 private: 158 private:
172 const std::vector<PrefHashFilter::TrackedPreferenceMetadata> 159 const std::vector<PrefHashFilter::TrackedPreferenceMetadata>
173 tracking_configuration_; 160 tracking_configuration_;
174 const size_t reporting_ids_count_; 161 const size_t reporting_ids_count_;
175 scoped_refptr<PrefStore> pref_store_; 162 scoped_refptr<PrefStore> pref_store_;
176 scoped_ptr<PrefHashStoreImpl> pref_hash_store_impl_; 163 scoped_ptr<PrefHashStoreImpl> pref_hash_store_impl_;
177 164
178 DISALLOW_COPY_AND_ASSIGN(InitializeHashStoreObserver); 165 DISALLOW_COPY_AND_ASSIGN(InitializeHashStoreObserver);
179 }; 166 };
180 167
181 ProfilePrefStoreManager::InitializeHashStoreObserver:: 168 InitializeHashStoreObserver::~InitializeHashStoreObserver() {}
182 ~InitializeHashStoreObserver() {}
183 169
184 void ProfilePrefStoreManager::InitializeHashStoreObserver::OnPrefValueChanged( 170 void InitializeHashStoreObserver::OnPrefValueChanged(const std::string& key) {}
185 const std::string& key) {}
186 171
187 void 172 void InitializeHashStoreObserver::OnInitializationCompleted(bool succeeded) {
188 ProfilePrefStoreManager::InitializeHashStoreObserver::OnInitializationCompleted(
189 bool succeeded) {
190 // If we successfully loaded the preferences _and_ the PrefHashStoreImpl 173 // If we successfully loaded the preferences _and_ the PrefHashStoreImpl
191 // hasn't been initialized by someone else in the meantime, initialize it now. 174 // hasn't been initialized by someone else in the meantime, initialize it now.
192 const PrefHashStoreImpl::StoreVersion pre_update_version = 175 const PrefHashStoreImpl::StoreVersion pre_update_version =
193 pref_hash_store_impl_->GetCurrentVersion(); 176 pref_hash_store_impl_->GetCurrentVersion();
194 if (succeeded && pre_update_version < PrefHashStoreImpl::VERSION_LATEST) { 177 if (succeeded && pre_update_version < PrefHashStoreImpl::VERSION_LATEST) {
195 PrefHashFilter(pref_hash_store_impl_.PassAs<PrefHashStore>(), 178 PrefHashFilter(pref_hash_store_impl_.PassAs<PrefHashStore>(),
196 tracking_configuration_, 179 tracking_configuration_,
197 reporting_ids_count_).Initialize(*pref_store_); 180 reporting_ids_count_).Initialize(*pref_store_);
198 UMA_HISTOGRAM_ENUMERATION( 181 UMA_HISTOGRAM_ENUMERATION(
199 "Settings.TrackedPreferencesAlternateStoreVersionUpdatedFrom", 182 "Settings.TrackedPreferencesAlternateStoreVersionUpdatedFrom",
200 pre_update_version, 183 pre_update_version,
201 PrefHashStoreImpl::VERSION_LATEST + 1); 184 PrefHashStoreImpl::VERSION_LATEST + 1);
202 } 185 }
203 pref_store_->RemoveObserver(this); 186 pref_store_->RemoveObserver(this);
204 delete this; 187 delete this;
205 } 188 }
206 189
190 } // namespace
191
192 // TODO(erikwright): Enable this on Chrome OS and Android once MACs are moved
193 // out of Local State. This will resolve a race condition on Android and a
194 // privacy issue on ChromeOS. http://crbug.com/349158
195 const bool ProfilePrefStoreManager::kPlatformSupportsPreferenceTracking =
196 #if defined(OS_ANDROID) || defined(OS_CHROMEOS)
197 false;
198 #else
199 true;
200 #endif
201
207 ProfilePrefStoreManager::ProfilePrefStoreManager( 202 ProfilePrefStoreManager::ProfilePrefStoreManager(
208 const base::FilePath& profile_path, 203 const base::FilePath& profile_path,
209 const std::vector<PrefHashFilter::TrackedPreferenceMetadata>& 204 const std::vector<PrefHashFilter::TrackedPreferenceMetadata>&
210 tracking_configuration, 205 tracking_configuration,
211 size_t reporting_ids_count, 206 size_t reporting_ids_count,
212 const std::string& seed, 207 const std::string& seed,
213 const std::string& device_id, 208 const std::string& device_id,
214 PrefService* local_state) 209 PrefService* local_state)
215 : profile_path_(profile_path), 210 : profile_path_(profile_path),
216 tracking_configuration_(tracking_configuration), 211 tracking_configuration_(tracking_configuration),
(...skipping 28 matching lines...) Expand all
245 240
246 // static 241 // static
247 base::Time ProfilePrefStoreManager::GetResetTime(PrefService* pref_service) { 242 base::Time ProfilePrefStoreManager::GetResetTime(PrefService* pref_service) {
248 // It's a bit of a coincidence that this (and ClearResetTime) work(s). The 243 // It's a bit of a coincidence that this (and ClearResetTime) work(s). The
249 // PrefHashFilter attached to the protected pref store will store the reset 244 // PrefHashFilter attached to the protected pref store will store the reset
250 // time directly in the protected pref store without going through the 245 // time directly in the protected pref store without going through the
251 // SegregatedPrefStore. 246 // SegregatedPrefStore.
252 247
253 // PrefHashFilter::GetResetTime will read the value through the pref service, 248 // PrefHashFilter::GetResetTime will read the value through the pref service,
254 // and thus through the SegregatedPrefStore. Even though it's not listed as 249 // and thus through the SegregatedPrefStore. Even though it's not listed as
255 // "protected" it will be read from the protected store prefentially to the 250 // "protected" it will be read from the protected store preferentially to the
256 // (NULL) value in the unprotected pref store. 251 // (NULL) value in the unprotected pref store.
257 return PrefHashFilter::GetResetTime(pref_service); 252 return PrefHashFilter::GetResetTime(pref_service);
258 } 253 }
259 254
260 // static 255 // static
261 void ProfilePrefStoreManager::ClearResetTime(PrefService* pref_service) { 256 void ProfilePrefStoreManager::ClearResetTime(PrefService* pref_service) {
262 // PrefHashFilter::ClearResetTime will clear the value through the pref 257 // PrefHashFilter::ClearResetTime will clear the value through the pref
263 // service, and thus through the SegregatedPrefStore. Since it's not listed as 258 // service, and thus through the SegregatedPrefStore. Since it's not listed as
264 // "protected" it will be migrated from the protected store to the unprotected 259 // "protected" it will be migrated from the protected store to the unprotected
265 // pref store before being deleted from the latter. 260 // pref store before being deleted from the latter.
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 DCHECK(kPlatformSupportsPreferenceTracking); 407 DCHECK(kPlatformSupportsPreferenceTracking);
413 408
414 PrefServiceHashStoreContents real_contents(profile_path_.AsUTF8Unsafe(), 409 PrefServiceHashStoreContents real_contents(profile_path_.AsUTF8Unsafe(),
415 local_state_); 410 local_state_);
416 return scoped_ptr<PrefHashStore>(new PrefHashStoreImpl( 411 return scoped_ptr<PrefHashStore>(new PrefHashStoreImpl(
417 seed_, 412 seed_,
418 device_id_, 413 device_id_,
419 scoped_ptr<HashStoreContents>( 414 scoped_ptr<HashStoreContents>(
420 new DictionaryHashStoreContents(real_contents)))); 415 new DictionaryHashStoreContents(real_contents))));
421 } 416 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698