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

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 memory leaks by introducing PolicyMap 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
Mattias Nissler (ping if slow) 2011/02/17 09:27:20 excess whitespace
Jakob Kummerow 2011/02/17 09:47:14 Done.
5
6 #ifndef CHROME_BROWSER_POLICY_POLICY_MAP_H_
7 #define CHROME_BROWSER_POLICY_POLICY_MAP_H_
8
9 #include <map>
10
11 #include "base/values.h"
12 #include "policy/configuration_policy_type.h"
13
14 namespace policy {
15
16 // Wrapper class around a std::map<ConfigurationPolicyType, Value*> that
17 // properly cleans up after itself when going out of scope (similar to a
18 // scoped_ptr). Exposes interesting methods of the underlying std::map.
Mattias Nissler (ping if slow) 2011/02/17 09:27:20 I feel the scoped_ptr reference here creates more
Jakob Kummerow 2011/02/17 09:47:14 Done (removed it).
19 class PolicyMap {
20 public:
21 typedef std::map<ConfigurationPolicyType, Value*> PolicyMapType;
22 typedef PolicyMapType::const_iterator const_iterator;
23
24 PolicyMap();
25 virtual ~PolicyMap();
26
27 const Value* Get(ConfigurationPolicyType policy) const;
Mattias Nissler (ping if slow) 2011/02/17 09:27:20 Please mention ownership handling in a comment to
Jakob Kummerow 2011/02/17 09:47:14 Done.
28 void Set(ConfigurationPolicyType policy, Value* value);
29 void Erase(ConfigurationPolicyType policy);
30
31 void Swap(PolicyMap* other);
32
33 bool Equals(const PolicyMap& other) const;
34 bool empty() const;
35 size_t size() const;
36
37 const_iterator begin() const;
38 const_iterator end() const;
39 void clear();
Mattias Nissler (ping if slow) 2011/02/17 09:27:20 By the style guide, this should be named Clear(),
Jakob Kummerow 2011/02/17 09:47:14 Done.
40
41 private:
42 // Helper function for Equals(...).
43 static bool MapEntryEquals(const PolicyMapType::value_type& a,
44 const PolicyMapType::value_type& b);
45
46 PolicyMapType map_;
47
48 DISALLOW_COPY_AND_ASSIGN(PolicyMap);
49 };
50
51 } // namespace policy
52
53 #endif // CHROME_BROWSER_POLICY_POLICY_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698