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..886ec0950e3fcc12bb61ddd733fd519168f426d9 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,36 @@ 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(); |
+ for (TrackedPreferencesMap::const_iterator it = tracked_paths_.begin(); |
+ it != tracked_paths_.end(); |
+ ++it) { |
+ if (!destination->GetValue(it->first, NULL)) { |
+ const base::Value* source_value = NULL; |
+ base::DictionaryValue temp_dictionary; |
+ if (source->GetValue(it->first, &source_value)) |
robertshield
2014/03/25 03:05:12
if this fails, can we skip the rest of this loop i
erikwright (departed)
2014/03/25 20:28:26
No. We want to check if NULL is what was expected,
|
+ temp_dictionary.Set(it->first, source_value->DeepCopy()); |
+ it->second->EnforceAndReport(&temp_dictionary, transaction.get()); |
robertshield
2014/03/25 03:05:12
this line needs a comment stating that it validate
erikwright (departed)
2014/03/25 20:28:26
Done.
|
+ 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(); |
+ // If we crash here, we will just delete the values from |source| in a future |
+ // run. |
robertshield
2014/03/25 03:05:12
".. in a future run when MigrateValues() is called
erikwright (departed)
2014/03/25 20:28:26
Done.
|
+ source->CommitPendingWrite(); |
+} |
+ |
void PrefHashFilter::Initialize(const PrefStore& pref_store) { |
scoped_ptr<PrefHashStoreTransaction> hash_store_transaction( |
pref_hash_store_->BeginTransaction()); |