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

Unified Diff: components/prefs/pref_service.h

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 | « chrome/browser/ui/webui/prefs_internals_source.cc ('k') | components/prefs/pref_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/prefs/pref_service.h
diff --git a/components/prefs/pref_service.h b/components/prefs/pref_service.h
index e08e361c40b618da1637b995323745dfc1e0052f..a08d7f8515a5b296fe2fd4e5f56517acb96a5dbf 100644
--- a/components/prefs/pref_service.h
+++ b/components/prefs/pref_service.h
@@ -60,6 +60,11 @@ class COMPONENTS_PREFS_EXPORT PrefService : public base::NonThreadSafe {
INITIALIZATION_STATUS_ERROR
};
+ enum IncludeDefaults {
+ INCLUDE_DEFAULTS,
+ EXCLUDE_DEFAULTS,
+ };
+
// A helper class to store all the information associated with a preference.
class COMPONENTS_PREFS_EXPORT Preference {
public:
@@ -250,23 +255,22 @@ class COMPONENTS_PREFS_EXPORT PrefService : public base::NonThreadSafe {
// this checks if a value exists for the path.
bool HasPrefPath(const std::string& path) const;
- // Returns a dictionary with effective preference values.
- std::unique_ptr<base::DictionaryValue> GetPreferenceValues() const;
-
- // Returns a dictionary with effective preference values, omitting prefs that
- // are at their default values.
- std::unique_ptr<base::DictionaryValue> GetPreferenceValuesOmitDefaults()
- const;
-
- // Returns a dictionary with effective preference values. Contrary to
- // GetPreferenceValues(), the paths of registered preferences are not split on
- // '.' characters. If a registered preference stores a dictionary, however,
- // the hierarchical structure inside the preference will be preserved.
- // For example, if "foo.bar" is a registered preference, the result could look
- // like this:
- // {"foo.bar": {"a": {"b": true}}}.
- std::unique_ptr<base::DictionaryValue>
- GetPreferenceValuesWithoutPathExpansion() const;
+ // Issues a callback for every preference value. The preferences must not be
+ // mutated during iteration.
+ void IteratePreferenceValues(
+ base::RepeatingCallback<void(const std::string& key,
+ const base::Value& value)> callback) const;
+
+ // Returns a dictionary with effective preference values. This is an expensive
+ // operation which does a deep copy. Use only if you really need the results
+ // in a base::Value (for example, for JSON serialization). Otherwise use
+ // IteratePreferenceValues above to avoid the copies.
+ //
+ // If INCLUDE_DEFAULTS is requested, preferences set to their default values
+ // will be included. Otherwise, these will be omitted from the returned
+ // dictionary.
+ std::unique_ptr<base::DictionaryValue> GetPreferenceValues(
+ IncludeDefaults include_defaults) const;
bool ReadOnly() const;
« no previous file with comments | « chrome/browser/ui/webui/prefs_internals_source.cc ('k') | components/prefs/pref_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698