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

Unified Diff: chrome/browser/prefs/pref_hash_filter.cc

Issue 205813002: Separate storage for protected preferences into Protected Preferences file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pp4_profile_pref_store
Patch Set: Pre-review. Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
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());

Powered by Google App Engine
This is Rietveld 408576698