| 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
|
|
|