| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/policy/policy_map.h" | 5 #include "chrome/browser/policy/policy_map.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "policy/policy_constants.h" | 10 #include "policy/policy_constants.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // Add the remaining entries. | 115 // Add the remaining entries. |
| 116 for ( ; iter_this != end(); ++iter_this) | 116 for ( ; iter_this != end(); ++iter_this) |
| 117 differing_keys->insert(iter_this->first); | 117 differing_keys->insert(iter_this->first); |
| 118 for ( ; iter_other != other.end(); ++iter_other) | 118 for ( ; iter_other != other.end(); ++iter_other) |
| 119 differing_keys->insert(iter_other->first); | 119 differing_keys->insert(iter_other->first); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void PolicyMap::FilterLevel(PolicyLevel level) { | 122 void PolicyMap::FilterLevel(PolicyLevel level) { |
| 123 PolicyMapType::iterator iter(map_.begin()); | 123 PolicyMapType::iterator iter(map_.begin()); |
| 124 while (iter != map_.end()) { | 124 while (iter != map_.end()) { |
| 125 if (iter->second.level != level) | 125 if (iter->second.level != level) { |
| 126 delete iter->second.value; |
| 126 map_.erase(iter++); | 127 map_.erase(iter++); |
| 127 else | 128 } else { |
| 128 ++iter; | 129 ++iter; |
| 130 } |
| 129 } | 131 } |
| 130 } | 132 } |
| 131 | 133 |
| 132 bool PolicyMap::Equals(const PolicyMap& other) const { | 134 bool PolicyMap::Equals(const PolicyMap& other) const { |
| 133 return other.size() == size() && | 135 return other.size() == size() && |
| 134 std::equal(begin(), end(), other.begin(), MapEntryEquals); | 136 std::equal(begin(), end(), other.begin(), MapEntryEquals); |
| 135 } | 137 } |
| 136 | 138 |
| 137 bool PolicyMap::empty() const { | 139 bool PolicyMap::empty() const { |
| 138 return map_.empty(); | 140 return map_.empty(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 156 map_.clear(); | 158 map_.clear(); |
| 157 } | 159 } |
| 158 | 160 |
| 159 // static | 161 // static |
| 160 bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a, | 162 bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a, |
| 161 const PolicyMap::PolicyMapType::value_type& b) { | 163 const PolicyMap::PolicyMapType::value_type& b) { |
| 162 return a.first == b.first && a.second.Equals(b.second); | 164 return a.first == b.first && a.second.Equals(b.second); |
| 163 } | 165 } |
| 164 | 166 |
| 165 } // namespace policy | 167 } // namespace policy |
| OLD | NEW |