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

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

Issue 226633002: Commit changes after a reset. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't commit, just schedule. 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/pref_hash_filter.h" 5 #include "chrome/browser/prefs/pref_hash_filter.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 const std::string& initialized_path = it->first; 145 const std::string& initialized_path = it->first;
146 const TrackedPreference* initialized_preference = it->second; 146 const TrackedPreference* initialized_preference = it->second;
147 const base::Value* value = NULL; 147 const base::Value* value = NULL;
148 pref_store.GetValue(initialized_path, &value); 148 pref_store.GetValue(initialized_path, &value);
149 initialized_preference->OnNewValue(value, hash_store_transaction.get()); 149 initialized_preference->OnNewValue(value, hash_store_transaction.get());
150 } 150 }
151 } 151 }
152 152
153 // Validates loaded preference values according to stored hashes, reports 153 // Validates loaded preference values according to stored hashes, reports
154 // validation results via UMA, and updates hashes in case of mismatch. 154 // validation results via UMA, and updates hashes in case of mismatch.
155 void PrefHashFilter::FilterOnLoad(base::DictionaryValue* pref_store_contents) { 155 bool PrefHashFilter::FilterOnLoad(base::DictionaryValue* pref_store_contents) {
156 DCHECK(pref_store_contents); 156 DCHECK(pref_store_contents);
157 base::TimeTicks checkpoint = base::TimeTicks::Now(); 157 base::TimeTicks checkpoint = base::TimeTicks::Now();
158 158
159 bool did_reset = false; 159 bool did_reset = false;
160 { 160 {
161 scoped_ptr<PrefHashStoreTransaction> hash_store_transaction( 161 scoped_ptr<PrefHashStoreTransaction> hash_store_transaction(
162 pref_hash_store_->BeginTransaction()); 162 pref_hash_store_->BeginTransaction());
163 for (TrackedPreferencesMap::const_iterator it = tracked_paths_.begin(); 163 for (TrackedPreferencesMap::const_iterator it = tracked_paths_.begin();
164 it != tracked_paths_.end(); ++it) { 164 it != tracked_paths_.end(); ++it) {
165 if (it->second->EnforceAndReport(pref_store_contents, 165 if (it->second->EnforceAndReport(pref_store_contents,
166 hash_store_transaction.get())) { 166 hash_store_transaction.get())) {
167 did_reset = true; 167 did_reset = true;
168 } 168 }
169 } 169 }
170 } 170 }
171 171
172 if (did_reset) { 172 if (did_reset) {
173 pref_store_contents->Set(prefs::kPreferenceResetTime, 173 pref_store_contents->Set(prefs::kPreferenceResetTime,
174 new base::StringValue(base::Int64ToString( 174 new base::StringValue(base::Int64ToString(
175 base::Time::Now().ToInternalValue()))); 175 base::Time::Now().ToInternalValue())));
176 } 176 }
177 177
178 // TODO(gab): Remove this histogram by Feb 21 2014; after sufficient timing 178 // TODO(gab): Remove this histogram by Feb 21 2014; after sufficient timing
179 // data has been gathered from the wild to be confident this doesn't 179 // data has been gathered from the wild to be confident this doesn't
180 // significantly affect startup. 180 // significantly affect startup.
181 UMA_HISTOGRAM_TIMES("Settings.FilterOnLoadTime", 181 UMA_HISTOGRAM_TIMES("Settings.FilterOnLoadTime",
182 base::TimeTicks::Now() - checkpoint); 182 base::TimeTicks::Now() - checkpoint);
183
184 return did_reset;
183 } 185 }
184 186
185 // Marks |path| has having changed if it is part of |tracked_paths_|. A new hash 187 // Marks |path| has having changed if it is part of |tracked_paths_|. A new hash
186 // will be stored for it the next time FilterSerializeData() is invoked. 188 // will be stored for it the next time FilterSerializeData() is invoked.
187 void PrefHashFilter::FilterUpdate(const std::string& path) { 189 void PrefHashFilter::FilterUpdate(const std::string& path) {
188 TrackedPreferencesMap::const_iterator it = tracked_paths_.find(path); 190 TrackedPreferencesMap::const_iterator it = tracked_paths_.find(path);
189 if (it != tracked_paths_.end()) 191 if (it != tracked_paths_.end())
190 changed_paths_.insert(std::make_pair(path, it->second)); 192 changed_paths_.insert(std::make_pair(path, it->second));
191 } 193 }
192 194
(...skipping 17 matching lines...) Expand all
210 } 212 }
211 changed_paths_.clear(); 213 changed_paths_.clear();
212 } 214 }
213 // TODO(gab): Remove this histogram by Feb 21 2014; after sufficient timing 215 // TODO(gab): Remove this histogram by Feb 21 2014; after sufficient timing
214 // data has been gathered from the wild to be confident this doesn't 216 // data has been gathered from the wild to be confident this doesn't
215 // significantly affect performance on the UI thread. 217 // significantly affect performance on the UI thread.
216 UMA_HISTOGRAM_TIMES("Settings.FilterSerializeDataTime", 218 UMA_HISTOGRAM_TIMES("Settings.FilterSerializeDataTime",
217 base::TimeTicks::Now() - checkpoint); 219 base::TimeTicks::Now() - checkpoint);
218 } 220 }
219 } 221 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_hash_filter.h ('k') | chrome/browser/prefs/pref_hash_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698