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

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

Issue 23528008: Don't use path expansion for profile dictionaries in LocalState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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/pref_metrics_service.h ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/pref_metrics_service.cc
diff --git a/chrome/browser/prefs/pref_metrics_service.cc b/chrome/browser/prefs/pref_metrics_service.cc
index fa290296c75b6ac2f26a3609416bb0e6c2e07d10..c57bea5c99c65f53a0bb9ccc8be7bb9532fbae3b 100644
--- a/chrome/browser/prefs/pref_metrics_service.cc
+++ b/chrome/browser/prefs/pref_metrics_service.cc
@@ -284,7 +284,8 @@ void PrefMetricsService::CheckTrackedPreferences() {
// Get the hashed prefs dictionary if it exists. If it doesn't, it will be
// created if we set preference values below.
const base::DictionaryValue* hashed_prefs = NULL;
- pref_hash_dicts->GetDictionary(profile_name_, &hashed_prefs);
+ pref_hash_dicts->GetDictionaryWithoutPathExpansion(profile_name_,
battre 2013/09/12 08:38:47 This is pretty error prone. Can you please update
michaelpg 2013/09/14 18:18:32 Done.
+ &hashed_prefs);
for (int i = 0; i < tracked_pref_path_count_; ++i) {
// Skip prefs that haven't been registered.
if (!prefs_->FindPreference(tracked_pref_paths_[i]))
@@ -344,8 +345,16 @@ void PrefMetricsService::UpdateTrackedPreference(const char* path) {
const base::Value* value = prefs_->GetUserPrefValue(path);
if (value) {
DictionaryPrefUpdate update(local_state_, prefs::kProfilePreferenceHashes);
- update->SetString(GetHashedPrefPath(path),
- GetHashedPrefValue(path, value));
+ DictionaryValue* child_dictionary = NULL;
+
+ // Get the dictionary corresponding to the profile name,
+ // which may have a .
xiyuan 2013/09/12 16:18:37 nit: which may have a '.'.
michaelpg 2013/09/14 18:18:32 Done.
+ if (!update->GetDictionaryWithoutPathExpansion(profile_name_,
+ &child_dictionary)) {
+ child_dictionary = new DictionaryValue;
+ update->SetWithoutPathExpansion(profile_name_, child_dictionary);
+ }
+ child_dictionary->SetString(path, GetHashedPrefValue(path, value));
} else {
RemoveTrackedPreference(path);
}
@@ -353,14 +362,13 @@ void PrefMetricsService::UpdateTrackedPreference(const char* path) {
bool PrefMetricsService::RemoveTrackedPreference(const char* path) {
DictionaryPrefUpdate update(local_state_, prefs::kProfilePreferenceHashes);
- return update->Remove(GetHashedPrefPath(path), NULL);
-}
+ DictionaryValue* child_dictionary = NULL;
-std::string PrefMetricsService::GetHashedPrefPath(const char* path) {
- std::string hash_pref_path(profile_name_);
- hash_pref_path.append(".");
- hash_pref_path.append(path);
- return hash_pref_path;
+ if (!update->GetDictionaryWithoutPathExpansion(profile_name_,
+ &child_dictionary)) {
+ return false;
+ }
+ return child_dictionary->Remove(path, NULL);
}
std::string PrefMetricsService::GetHashedPrefValue(
« no previous file with comments | « chrome/browser/prefs/pref_metrics_service.h ('k') | chrome/browser/profiles/profile_info_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698