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

Unified Diff: components/prefs/pref_service.cc

Issue 2799143002: Improve profile stats performace. (Closed)
Patch Set: Use enum Created 3 years, 8 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 | « components/prefs/pref_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/prefs/pref_service.cc
diff --git a/components/prefs/pref_service.cc b/components/prefs/pref_service.cc
index 6858839110b158b139c7e68fed680e5f50ddeb75..4ebea533478d97c4b6fa87b0f41abfae99dd0f61 100644
--- a/components/prefs/pref_service.cc
+++ b/components/prefs/pref_service.cc
@@ -193,37 +193,27 @@ bool PrefService::HasPrefPath(const std::string& path) const {
return pref && !pref->IsDefaultValue();
}
-std::unique_ptr<base::DictionaryValue> PrefService::GetPreferenceValues()
- const {
- DCHECK(CalledOnValidThread());
- std::unique_ptr<base::DictionaryValue> out(new base::DictionaryValue);
- for (const auto& it : *pref_registry_) {
- out->Set(it.first, GetPreferenceValue(it.first)->CreateDeepCopy());
- }
- return out;
-}
-
-std::unique_ptr<base::DictionaryValue>
-PrefService::GetPreferenceValuesOmitDefaults() const {
+void PrefService::IteratePreferenceValues(
+ base::RepeatingCallback<void(const std::string& key,
+ const base::Value& value)> callback) const {
DCHECK(CalledOnValidThread());
- std::unique_ptr<base::DictionaryValue> out(new base::DictionaryValue);
- for (const auto& it : *pref_registry_) {
- const Preference* pref = FindPreference(it.first);
- if (pref->IsDefaultValue())
- continue;
- out->Set(it.first, pref->GetValue()->CreateDeepCopy());
- }
- return out;
+ for (const auto& it : *pref_registry_)
+ callback.Run(it.first, *GetPreferenceValue(it.first));
}
-std::unique_ptr<base::DictionaryValue>
-PrefService::GetPreferenceValuesWithoutPathExpansion() const {
+std::unique_ptr<base::DictionaryValue> PrefService::GetPreferenceValues(
+ IncludeDefaults include_defaults) const {
DCHECK(CalledOnValidThread());
std::unique_ptr<base::DictionaryValue> out(new base::DictionaryValue);
for (const auto& it : *pref_registry_) {
- const base::Value* value = GetPreferenceValue(it.first);
- DCHECK(value);
- out->SetWithoutPathExpansion(it.first, value->CreateDeepCopy());
+ if (include_defaults == INCLUDE_DEFAULTS) {
+ out->Set(it.first, GetPreferenceValue(it.first)->CreateDeepCopy());
+ } else {
+ const Preference* pref = FindPreference(it.first);
+ if (pref->IsDefaultValue())
+ continue;
+ out->Set(it.first, pref->GetValue()->CreateDeepCopy());
+ }
}
return out;
}
« no previous file with comments | « components/prefs/pref_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698