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

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

Issue 2414663002: Fix log spew for "_comment..." policies. (Closed)
Patch Set: Fix nullptr dereference. 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
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..6c656a2a989e78c16482740fd8d0e087828e4890 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) {
+ EraseGeneric(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;
- }
- }
+ EraseGeneric(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::EraseGeneric(
+ 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
« components/policy/core/common/policy_map.h ('K') | « 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