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

Unified Diff: components/policy/core/common/policy_map.cc

Issue 2414663002: Fix log spew for "_comment..." policies. (Closed)
Patch Set: Rename EraseGeneric() to FilterErase(). Created 4 years, 2 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/policy/core/common/policy_map.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/policy_map.cc
diff --git a/components/policy/core/common/policy_map.cc b/components/policy/core/common/policy_map.cc
index 55114d76b5adca2f5965f859295fb62056c0b9aa..cac8e3b3e67d5ef2bf575bb38112fbe999ac1748 100644
--- a/components/policy/core/common/policy_map.cc
+++ b/components/policy/core/common/policy_map.cc
@@ -93,16 +93,14 @@ void PolicyMap::Erase(const std::string& policy) {
map_.erase(policy);
}
+void PolicyMap::EraseMatching(
+ const base::Callback<bool(const const_iterator)>& filter) {
+ FilterErase(filter, true);
+}
+
void PolicyMap::EraseNonmatching(
const base::Callback<bool(const const_iterator)>& filter) {
- PolicyMapType::iterator iter(map_.begin());
- while (iter != map_.end()) {
- if (!filter.Run(iter)) {
- map_.erase(iter++);
- } else {
- ++iter;
- }
- }
+ FilterErase(filter, false);
}
void PolicyMap::Swap(PolicyMap* other) {
@@ -199,4 +197,17 @@ bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a,
return a.first == b.first && a.second.Equals(b.second);
}
+void PolicyMap::FilterErase(
+ const base::Callback<bool(const const_iterator)>& filter,
+ bool deletion_value) {
+ PolicyMapType::iterator iter(map_.begin());
+ while (iter != map_.end()) {
+ if (filter.Run(iter) == deletion_value) {
+ map_.erase(iter++);
+ } else {
+ ++iter;
+ }
+ }
+}
+
} // namespace policy
« no previous file with comments | « components/policy/core/common/policy_map.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698