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

Unified Diff: chrome/browser/prefs/tracked/segregated_pref_store.cc

Issue 220203011: Changes requested by gab for previously committed CLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't commit if we didn't make any changes. 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
« no previous file with comments | « chrome/browser/prefs/tracked/segregated_pref_store.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/tracked/segregated_pref_store.cc
diff --git a/chrome/browser/prefs/tracked/segregated_pref_store.cc b/chrome/browser/prefs/tracked/segregated_pref_store.cc
index 13d5ecfaeedfa598de4bf57b29f3c87eb2897512..a430d3035a8dfb2c3ad2d9edb8a3e8c5618356a7 100644
--- a/chrome/browser/prefs/tracked/segregated_pref_store.cc
+++ b/chrome/browser/prefs/tracked/segregated_pref_store.cc
@@ -35,7 +35,6 @@ void SegregatedPrefStore::AggregatingObserver::OnInitializationCompleted(
DCHECK_LE(failed_sub_initializations_ + successful_sub_initializations_, 2);
if (failed_sub_initializations_ + successful_sub_initializations_ == 2) {
-
if (!outer_->on_initialization_.is_null())
outer_->on_initialization_.Run();
@@ -151,8 +150,8 @@ SegregatedPrefStore::~SegregatedPrefStore() {
selected_pref_store_->RemoveObserver(&aggregating_observer_);
}
-const PersistentPrefStore*
-SegregatedPrefStore::StoreForKey(const std::string& key) const {
+const PersistentPrefStore* SegregatedPrefStore::StoreForKey(
+ const std::string& key) const {
if (ContainsKey(selected_preference_names_, key) ||
selected_pref_store_->GetValue(key, NULL)) {
return selected_pref_store_.get();
@@ -170,12 +169,14 @@ PersistentPrefStore* SegregatedPrefStore::StoreForKey(const std::string& key) {
// permit us to enumerate its contents.
const base::Value* value = NULL;
if (selected_pref_store_->GetValue(key, &value)) {
- scoped_ptr<base::Value> migrated_value(value->DeepCopy());
- value = NULL;
- default_pref_store_->SetValue(key, migrated_value.release());
+ default_pref_store_->SetValue(key, value->DeepCopy());
+ // Commit |default_pref_store_| to guarantee that the migrated value is
+ // flushed to disk before the removal from |selected_pref_store_| is
+ // eventually flushed to disk.
default_pref_store_->CommitPendingWrite();
+
+ value = NULL;
selected_pref_store_->RemoveValue(key);
- selected_pref_store_->CommitPendingWrite();
}
return default_pref_store_.get();
« no previous file with comments | « chrome/browser/prefs/tracked/segregated_pref_store.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698