OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/policy/policy_error_map.h" | |
6 | |
7 #include <algorithm> | |
8 | |
9 #include "base/stl_util.h" | |
10 | |
11 namespace policy { | |
12 | |
13 PolicyErrorMap::PolicyErrorMap() { | |
14 } | |
15 | |
16 PolicyErrorMap::~PolicyErrorMap() { | |
17 Clear(); | |
18 } | |
19 | |
20 void PolicyErrorMap::AddError(ConfigurationPolicyType policy, | |
21 StringValue* error_message) { | |
22 map_.insert( | |
23 std::pair<ConfigurationPolicyType, StringValue*>(policy, error_message)); | |
24 } | |
25 | |
26 ListValue* PolicyErrorMap::GetErrors( | |
27 ConfigurationPolicyType policy) const { | |
28 std::pair<const_iterator, const_iterator> range = map_.equal_range(policy); | |
29 | |
30 if (range.first == range.second) | |
31 return NULL; | |
32 | |
33 const_iterator it = range.first; | |
Mattias Nissler (ping if slow)
2011/09/20 13:12:25
move int loop initializer below?
simo
2011/09/22 11:43:26
Done.
| |
34 ListValue* list = new ListValue(); | |
35 for ( ; it != range.second; ++it) { | |
Mattias Nissler (ping if slow)
2011/09/20 13:12:25
no need for curlies
simo
2011/09/22 11:43:26
Done.
| |
36 list->Append(it->second->DeepCopy()); | |
37 } | |
38 | |
39 return list; | |
40 } | |
41 | |
42 bool PolicyErrorMap::empty() const { | |
43 return map_.empty(); | |
44 } | |
45 | |
46 size_t PolicyErrorMap::size() const { | |
47 return map_.size(); | |
48 } | |
49 | |
50 PolicyErrorMap::const_iterator PolicyErrorMap::begin() const { | |
51 return map_.begin(); | |
52 } | |
53 | |
54 PolicyErrorMap::const_iterator PolicyErrorMap::end() const { | |
55 return map_.end(); | |
56 } | |
57 | |
58 void PolicyErrorMap::Clear() { | |
59 STLDeleteValues(&map_); | |
60 } | |
61 | |
62 } // namespace policy | |
OLD | NEW |