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

Side by Side Diff: chrome/browser/policy/policy_map.h

Issue 6532019: New policy protobuf protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix one more leak Created 9 years, 10 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
(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 #ifndef CHROME_BROWSER_POLICY_POLICY_MAP_H_
6 #define CHROME_BROWSER_POLICY_POLICY_MAP_H_
7
8 #include <map>
9
10 #include "base/values.h"
11 #include "policy/configuration_policy_type.h"
12
13 namespace policy {
14
15 // Wrapper class around a std::map<ConfigurationPolicyType, Value*> that
16 // properly cleans up after itself when going out of scope.
17 // Exposes interesting methods of the underlying std::map.
18 class PolicyMap {
19 public:
20 typedef std::map<ConfigurationPolicyType, Value*> PolicyMapType;
21 typedef PolicyMapType::const_iterator const_iterator;
22
23 PolicyMap();
24 virtual ~PolicyMap();
25
26 // Returns a weak reference to the value currently stored for key |policy|.
27 // Ownership is retained by PolicyMap; callers should use Value::DeepCopy
28 // if they need a copy that they own themselves.
29 // Returns NULL if the map does not contain a value for |policy|.
30 const Value* Get(ConfigurationPolicyType policy) const;
31 // Takes ownership of |value|. Overwrites any existing value stored in the
32 // map for the key |policy|.
33 void Set(ConfigurationPolicyType policy, Value* value);
34 void Erase(ConfigurationPolicyType policy);
35
36 void Swap(PolicyMap* other);
37
38 bool Equals(const PolicyMap& other) const;
39 bool empty() const;
40 size_t size() const;
41
42 const_iterator begin() const;
43 const_iterator end() const;
44 void Clear();
45
46 private:
47 // Helper function for Equals(...).
48 static bool MapEntryEquals(const PolicyMapType::value_type& a,
49 const PolicyMapType::value_type& b);
50
51 PolicyMapType map_;
52
53 DISALLOW_COPY_AND_ASSIGN(PolicyMap);
54 };
55
56 } // namespace policy
57
58 #endif // CHROME_BROWSER_POLICY_POLICY_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698