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

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

Issue 6074003: Handle policy refresh internally in ConfigurationPolicyPrefStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nit Created 10 years 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
Index: chrome/browser/prefs/pref_value_map.cc
diff --git a/chrome/browser/prefs/pref_value_map.cc b/chrome/browser/prefs/pref_value_map.cc
index ff270499e270924c3450859bf1d201fb330371b6..6e7bf79e160ab9683d37126976f089ef88a5ee3b 100644
--- a/chrome/browser/prefs/pref_value_map.cc
+++ b/chrome/browser/prefs/pref_value_map.cc
@@ -57,3 +57,51 @@ void PrefValueMap::Clear() {
STLDeleteValues(&prefs_);
prefs_.clear();
}
+
+bool PrefValueMap::GetBoolean(const std::string& key,
+ bool* value) const {
+ Value* stored_value = NULL;
+ return GetValue(key, &stored_value) && stored_value->GetAsBoolean(value);
+}
+
+bool PrefValueMap::GetString(const std::string& key,
+ std::string* value) const {
+ Value* stored_value = NULL;
+ return GetValue(key, &stored_value) && stored_value->GetAsString(value);
+}
+
+void PrefValueMap::SetString(const std::string& key,
+ const std::string& value) {
+ SetValue(key, Value::CreateStringValue(value));
+}
+
+void PrefValueMap::GetDifferingKeys(
+ const PrefValueMap* other,
+ std::vector<std::string>* differing_keys) const {
+ differing_keys->clear();
+
+ // Walk over the maps in lockstep, adding everything that is different.
+ Map::const_iterator this_pref(prefs_.begin());
+ Map::const_iterator other_pref(other->prefs_.begin());
+ while (this_pref != prefs_.end() && other_pref != other->prefs_.end()) {
+ const int diff = this_pref->first.compare(other_pref->first);
+ if (diff == 0) {
+ if (!this_pref->second->Equals(other_pref->second))
+ differing_keys->push_back(this_pref->first);
+ ++this_pref;
+ ++other_pref;
+ } else if (diff < 0) {
+ differing_keys->push_back(this_pref->first);
+ ++this_pref;
+ } else if (diff > 0) {
+ differing_keys->push_back(other_pref->first);
+ ++other_pref;
+ }
+ }
+
+ // Add the remaining entries.
+ for ( ; this_pref != prefs_.end(); ++this_pref)
+ differing_keys->push_back(this_pref->first);
+ for ( ; other_pref != other->prefs_.end(); ++other_pref)
+ differing_keys->push_back(other_pref->first);
+}

Powered by Google App Engine
This is Rietveld 408576698