Index: chrome/browser/prefs/pref_hash_filter.cc |
diff --git a/chrome/browser/prefs/pref_hash_filter.cc b/chrome/browser/prefs/pref_hash_filter.cc |
index b937c358faf770b5f379d1bda8d8698f0f993093..381fbace615328531738d57fd6b13025bba6487c 100644 |
--- a/chrome/browser/prefs/pref_hash_filter.cc |
+++ b/chrome/browser/prefs/pref_hash_filter.cc |
@@ -8,6 +8,7 @@ |
#include "base/logging.h" |
#include "base/metrics/histogram.h" |
+#include "base/prefs/persistent_pref_store.h" |
#include "base/prefs/pref_service.h" |
#include "base/prefs/pref_store.h" |
#include "base/strings/string_number_conversions.h" |
@@ -91,6 +92,42 @@ void PrefHashFilter::ClearResetTime(PrefService* user_prefs) { |
user_prefs->ClearPref(prefs::kPreferenceResetTime); |
} |
+void PrefHashFilter::MigrateValues(PersistentPrefStore* source, |
+ PersistentPrefStore* destination) { |
+ scoped_ptr<PrefHashStoreTransaction> transaction = |
+ pref_hash_store_->BeginTransaction(); |
gab
2014/04/01 18:55:06
Is pref_hash_store_ expected to be the underlying
gab
2014/04/01 19:24:14
Ah, now I understand (from seeing how it's actuall
erikwright (departed)
2014/04/01 19:46:08
The method comment for MigrateValues says, in part
gab
2014/04/02 17:02:03
Perhaps adding something like:
"This PrefHashFilt
|
+ for (TrackedPreferencesMap::const_iterator it = tracked_paths_.begin(); |
+ it != tracked_paths_.end(); |
+ ++it) { |
+ const base::Value* source_value = NULL; |
+ if (source->GetValue(it->first, &source_value) && |
+ !destination->GetValue(it->first, NULL)) { |
+ base::DictionaryValue temp_dictionary; |
+ // Copy the value from |source| into a suitable place for a |
+ // TrackedPreference to act on it. |
+ temp_dictionary.Set(it->first, source_value->DeepCopy()); |
+ // Check whether the value is correct according to our MAC. May remove the |
+ // value from |temp_dictionary|. |
gab
2014/04/01 18:55:06
nit: Remove extra space at beginning of this line.
|
+ it->second->EnforceAndReport(&temp_dictionary, transaction.get()); |
+ // Now take the value as it appears in |temp_dictionary| and put it in |
+ // |destination|. |
+ scoped_ptr<base::Value> checked_value; |
+ if (temp_dictionary.Remove(it->first, &checked_value)) |
+ destination->SetValue(it->first, checked_value.release()); |
+ } |
+ source->RemoveValue(it->first); |
+ } |
+ |
+ // Order these such that a crash at any point is still recoverable. We assume |
+ // that they are configured such that the writes will occur on worker threads |
+ // in the order that we asked for them. |
+ destination->CommitPendingWrite(); |
+ transaction.reset(); |
gab
2014/04/01 18:55:06
This reset() won't actually force a CommitPendingW
erikwright (departed)
2014/04/01 19:46:08
It doesn't matter in practice, not the least becau
|
+ // If we crash here, we will just delete the values from |source| in a future |
+ // invocation of MigrateValues. |
+ source->CommitPendingWrite(); |
+} |
+ |
void PrefHashFilter::Initialize(const PrefStore& pref_store) { |
scoped_ptr<PrefHashStoreTransaction> hash_store_transaction( |
pref_hash_store_->BeginTransaction()); |