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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « components/policy/core/common/policy_map.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/policy/core/common/policy_map.h" 5 #include "components/policy/core/common/policy_map.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 87
88 void PolicyMap::Set(const std::string& policy, Entry entry) { 88 void PolicyMap::Set(const std::string& policy, Entry entry) {
89 map_[policy] = std::move(entry); 89 map_[policy] = std::move(entry);
90 } 90 }
91 91
92 void PolicyMap::Erase(const std::string& policy) { 92 void PolicyMap::Erase(const std::string& policy) {
93 map_.erase(policy); 93 map_.erase(policy);
94 } 94 }
95 95
96 void PolicyMap::EraseMatching(
97 const base::Callback<bool(const const_iterator)>& filter) {
98 FilterErase(filter, true);
99 }
100
96 void PolicyMap::EraseNonmatching( 101 void PolicyMap::EraseNonmatching(
97 const base::Callback<bool(const const_iterator)>& filter) { 102 const base::Callback<bool(const const_iterator)>& filter) {
98 PolicyMapType::iterator iter(map_.begin()); 103 FilterErase(filter, false);
99 while (iter != map_.end()) {
100 if (!filter.Run(iter)) {
101 map_.erase(iter++);
102 } else {
103 ++iter;
104 }
105 }
106 } 104 }
107 105
108 void PolicyMap::Swap(PolicyMap* other) { 106 void PolicyMap::Swap(PolicyMap* other) {
109 map_.swap(other->map_); 107 map_.swap(other->map_);
110 } 108 }
111 109
112 void PolicyMap::CopyFrom(const PolicyMap& other) { 110 void PolicyMap::CopyFrom(const PolicyMap& other) {
113 Clear(); 111 Clear();
114 for (const auto& it : other) 112 for (const auto& it : other)
115 Set(it.first, it.second.DeepCopy()); 113 Set(it.first, it.second.DeepCopy());
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 void PolicyMap::Clear() { 190 void PolicyMap::Clear() {
193 map_.clear(); 191 map_.clear();
194 } 192 }
195 193
196 // static 194 // static
197 bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a, 195 bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a,
198 const PolicyMap::PolicyMapType::value_type& b) { 196 const PolicyMap::PolicyMapType::value_type& b) {
199 return a.first == b.first && a.second.Equals(b.second); 197 return a.first == b.first && a.second.Equals(b.second);
200 } 198 }
201 199
200 void PolicyMap::FilterErase(
201 const base::Callback<bool(const const_iterator)>& filter,
202 bool deletion_value) {
203 PolicyMapType::iterator iter(map_.begin());
204 while (iter != map_.end()) {
205 if (filter.Run(iter) == deletion_value) {
206 map_.erase(iter++);
207 } else {
208 ++iter;
209 }
210 }
211 }
212
202 } // namespace policy 213 } // namespace policy
OLDNEW
« 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