| OLD | NEW |
| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 entry.source = source; | 82 entry.source = source; |
| 83 entry.value = std::move(value); | 83 entry.value = std::move(value); |
| 84 entry.external_data_fetcher = std::move(external_data_fetcher); | 84 entry.external_data_fetcher = std::move(external_data_fetcher); |
| 85 Set(policy, std::move(entry)); | 85 Set(policy, std::move(entry)); |
| 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::SetSourceForAll(PolicySource source) { |
| 93 for (auto& it : map_) { |
| 94 it.second.source = source; |
| 95 } |
| 96 } |
| 97 |
| 92 void PolicyMap::Erase(const std::string& policy) { | 98 void PolicyMap::Erase(const std::string& policy) { |
| 93 map_.erase(policy); | 99 map_.erase(policy); |
| 94 } | 100 } |
| 95 | 101 |
| 96 void PolicyMap::EraseMatching( | 102 void PolicyMap::EraseMatching( |
| 97 const base::Callback<bool(const const_iterator)>& filter) { | 103 const base::Callback<bool(const const_iterator)>& filter) { |
| 98 FilterErase(filter, true); | 104 FilterErase(filter, true); |
| 99 } | 105 } |
| 100 | 106 |
| 101 void PolicyMap::EraseNonmatching( | 107 void PolicyMap::EraseNonmatching( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 while (iter != map_.end()) { | 210 while (iter != map_.end()) { |
| 205 if (filter.Run(iter) == deletion_value) { | 211 if (filter.Run(iter) == deletion_value) { |
| 206 map_.erase(iter++); | 212 map_.erase(iter++); |
| 207 } else { | 213 } else { |
| 208 ++iter; | 214 ++iter; |
| 209 } | 215 } |
| 210 } | 216 } |
| 211 } | 217 } |
| 212 | 218 |
| 213 } // namespace policy | 219 } // namespace policy |
| OLD | NEW |