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

Side by Side Diff: components/policy/core/common/policy_map.cc

Issue 108603005: Update uses of Value in chromeos/, cloud_print/, components/, content/ to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 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 | Annotate | Revision Log
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/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 30 matching lines...) Expand all
41 const PolicyMap::Entry& other) const { 41 const PolicyMap::Entry& other) const {
42 if (level == other.level) 42 if (level == other.level)
43 return scope > other.scope; 43 return scope > other.scope;
44 else 44 else
45 return level > other.level; 45 return level > other.level;
46 } 46 }
47 47
48 bool PolicyMap::Entry::Equals(const PolicyMap::Entry& other) const { 48 bool PolicyMap::Entry::Equals(const PolicyMap::Entry& other) const {
49 return level == other.level && 49 return level == other.level &&
50 scope == other.scope && 50 scope == other.scope &&
51 Value::Equals(value, other.value) && 51 base::Value::Equals(value, other.value) &&
52 ExternalDataFetcher::Equals(external_data_fetcher, 52 ExternalDataFetcher::Equals(external_data_fetcher,
53 other.external_data_fetcher); 53 other.external_data_fetcher);
54 } 54 }
55 55
56 PolicyMap::PolicyMap() { 56 PolicyMap::PolicyMap() {
57 } 57 }
58 58
59 PolicyMap::~PolicyMap() { 59 PolicyMap::~PolicyMap() {
60 Clear(); 60 Clear();
61 } 61 }
62 62
63 const PolicyMap::Entry* PolicyMap::Get(const std::string& policy) const { 63 const PolicyMap::Entry* PolicyMap::Get(const std::string& policy) const {
64 PolicyMapType::const_iterator entry = map_.find(policy); 64 PolicyMapType::const_iterator entry = map_.find(policy);
65 return entry == map_.end() ? NULL : &entry->second; 65 return entry == map_.end() ? NULL : &entry->second;
66 } 66 }
67 67
68 const Value* PolicyMap::GetValue(const std::string& policy) const { 68 const base::Value* PolicyMap::GetValue(const std::string& policy) const {
69 PolicyMapType::const_iterator entry = map_.find(policy); 69 PolicyMapType::const_iterator entry = map_.find(policy);
70 return entry == map_.end() ? NULL : entry->second.value; 70 return entry == map_.end() ? NULL : entry->second.value;
71 } 71 }
72 72
73 void PolicyMap::Set(const std::string& policy, 73 void PolicyMap::Set(const std::string& policy,
74 PolicyLevel level, 74 PolicyLevel level,
75 PolicyScope scope, 75 PolicyScope scope,
76 Value* value, 76 base::Value* value,
77 ExternalDataFetcher* external_data_fetcher) { 77 ExternalDataFetcher* external_data_fetcher) {
78 Entry& entry = map_[policy]; 78 Entry& entry = map_[policy];
79 entry.DeleteOwnedMembers(); 79 entry.DeleteOwnedMembers();
80 entry.level = level; 80 entry.level = level;
81 entry.scope = scope; 81 entry.scope = scope;
82 entry.value = value; 82 entry.value = value;
83 entry.external_data_fetcher = external_data_fetcher; 83 entry.external_data_fetcher = external_data_fetcher;
84 } 84 }
85 85
86 void PolicyMap::Erase(const std::string& policy) { 86 void PolicyMap::Erase(const std::string& policy) {
(...skipping 30 matching lines...) Expand all
117 if (!entry || it->second.has_higher_priority_than(*entry)) { 117 if (!entry || it->second.has_higher_priority_than(*entry)) {
118 Set(it->first, it->second.level, it->second.scope, 118 Set(it->first, it->second.level, it->second.scope,
119 it->second.value->DeepCopy(), it->second.external_data_fetcher ? 119 it->second.value->DeepCopy(), it->second.external_data_fetcher ?
120 new ExternalDataFetcher(*it->second.external_data_fetcher) : 120 new ExternalDataFetcher(*it->second.external_data_fetcher) :
121 NULL); 121 NULL);
122 } 122 }
123 } 123 }
124 } 124 }
125 125
126 void PolicyMap::LoadFrom( 126 void PolicyMap::LoadFrom(
127 const DictionaryValue* policies, 127 const base::DictionaryValue* policies,
128 PolicyLevel level, 128 PolicyLevel level,
129 PolicyScope scope) { 129 PolicyScope scope) {
130 for (DictionaryValue::Iterator it(*policies); !it.IsAtEnd(); it.Advance()) 130 for (base::DictionaryValue::Iterator it(*policies);
131 !it.IsAtEnd(); it.Advance()) {
131 Set(it.key(), level, scope, it.value().DeepCopy(), NULL); 132 Set(it.key(), level, scope, it.value().DeepCopy(), NULL);
133 }
132 } 134 }
133 135
134 void PolicyMap::GetDifferingKeys(const PolicyMap& other, 136 void PolicyMap::GetDifferingKeys(const PolicyMap& other,
135 std::set<std::string>* differing_keys) const { 137 std::set<std::string>* differing_keys) const {
136 // Walk over the maps in lockstep, adding everything that is different. 138 // Walk over the maps in lockstep, adding everything that is different.
137 const_iterator iter_this(begin()); 139 const_iterator iter_this(begin());
138 const_iterator iter_other(other.begin()); 140 const_iterator iter_other(other.begin());
139 while (iter_this != end() && iter_other != other.end()) { 141 while (iter_this != end() && iter_other != other.end()) {
140 const int diff = iter_this->first.compare(iter_other->first); 142 const int diff = iter_this->first.compare(iter_other->first);
141 if (diff == 0) { 143 if (diff == 0) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 map_.clear(); 200 map_.clear();
199 } 201 }
200 202
201 // static 203 // static
202 bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a, 204 bool PolicyMap::MapEntryEquals(const PolicyMap::PolicyMapType::value_type& a,
203 const PolicyMap::PolicyMapType::value_type& b) { 205 const PolicyMap::PolicyMapType::value_type& b) {
204 return a.first == b.first && a.second.Equals(b.second); 206 return a.first == b.first && a.second.Equals(b.second);
205 } 207 }
206 208
207 } // namespace policy 209 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698