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

Side by Side Diff: components/user_prefs/tracked/segregated_pref_store.cc

Issue 2704133006: Revert of Add PrefStore::GetValues (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/user_prefs/tracked/segregated_pref_store.h" 5 #include "components/user_prefs/tracked/segregated_pref_store.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 bool SegregatedPrefStore::IsInitializationComplete() const { 76 bool SegregatedPrefStore::IsInitializationComplete() const {
77 return default_pref_store_->IsInitializationComplete() && 77 return default_pref_store_->IsInitializationComplete() &&
78 selected_pref_store_->IsInitializationComplete(); 78 selected_pref_store_->IsInitializationComplete();
79 } 79 }
80 80
81 bool SegregatedPrefStore::GetValue(const std::string& key, 81 bool SegregatedPrefStore::GetValue(const std::string& key,
82 const base::Value** result) const { 82 const base::Value** result) const {
83 return StoreForKey(key)->GetValue(key, result); 83 return StoreForKey(key)->GetValue(key, result);
84 } 84 }
85 85
86 std::unique_ptr<base::DictionaryValue> SegregatedPrefStore::GetValues() const {
87 auto values = default_pref_store_->GetValues();
88 auto selected_pref_store_values = selected_pref_store_->GetValues();
89 for (const auto& key : selected_preference_names_) {
90 const base::Value* value = nullptr;
91 if (selected_pref_store_values->Get(key, &value)) {
92 values->Set(key, value->CreateDeepCopy());
93 } else {
94 values->Remove(key, nullptr);
95 }
96 }
97 return values;
98 }
99
100 void SegregatedPrefStore::SetValue(const std::string& key, 86 void SegregatedPrefStore::SetValue(const std::string& key,
101 std::unique_ptr<base::Value> value, 87 std::unique_ptr<base::Value> value,
102 uint32_t flags) { 88 uint32_t flags) {
103 StoreForKey(key)->SetValue(key, std::move(value), flags); 89 StoreForKey(key)->SetValue(key, std::move(value), flags);
104 } 90 }
105 91
106 void SegregatedPrefStore::RemoveValue(const std::string& key, uint32_t flags) { 92 void SegregatedPrefStore::RemoveValue(const std::string& key, uint32_t flags) {
107 StoreForKey(key)->RemoveValue(key, flags); 93 StoreForKey(key)->RemoveValue(key, flags);
108 } 94 }
109 95
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 .get(); 171 .get();
186 } 172 }
187 173
188 const PersistentPrefStore* SegregatedPrefStore::StoreForKey( 174 const PersistentPrefStore* SegregatedPrefStore::StoreForKey(
189 const std::string& key) const { 175 const std::string& key) const {
190 return (base::ContainsKey(selected_preference_names_, key) 176 return (base::ContainsKey(selected_preference_names_, key)
191 ? selected_pref_store_ 177 ? selected_pref_store_
192 : default_pref_store_) 178 : default_pref_store_)
193 .get(); 179 .get();
194 } 180 }
OLDNEW
« no previous file with comments | « components/user_prefs/tracked/segregated_pref_store.h ('k') | components/user_prefs/tracked/segregated_pref_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698