summaryrefslogtreecommitdiffstats
path: root/chrome/browser/policy/policy_map.h
diff options
context:
space:
mode:
authorjkummerow@chromium.org <jkummerow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-17 13:25:23 +0000
committerjkummerow@chromium.org <jkummerow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-17 13:25:23 +0000
commitf8636972b3e1d3a9bbf7f86b6708c0f5d66571ae (patch)
tree1cc358fe9fc57efd09b612b261d484ad359bf1fe /chrome/browser/policy/policy_map.h
parentd20e0b986707dd49ae7a2cad347f4e50140ec86e (diff)
downloadchromium_src-f8636972b3e1d3a9bbf7f86b6708c0f5d66571ae.zip
chromium_src-f8636972b3e1d3a9bbf7f86b6708c0f5d66571ae.tar.gz
chromium_src-f8636972b3e1d3a9bbf7f86b6708c0f5d66571ae.tar.bz2
New policy protobuf protocol.
(Third attempt to land http://codereview.chromium.org/6409040/ -- now without memory leaks) - cloud_policy.proto autogenerated from policy_templates.json - C++ method decoding the protobuf also autogenerated from policy_templates.json - changed policy fetching mechanism to fetch new-style policy protobufs BUG=68309, chromium-os:11253, chromium-os:11255 TEST=CloudPolicyCacheTest.*; also manual test against python testserver Review URL: http://codereview.chromium.org/6532019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75259 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/policy/policy_map.h')
-rw-r--r--chrome/browser/policy/policy_map.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/chrome/browser/policy/policy_map.h b/chrome/browser/policy/policy_map.h
new file mode 100644
index 0000000..c9e3d03
--- /dev/null
+++ b/chrome/browser/policy/policy_map.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_POLICY_POLICY_MAP_H_
+#define CHROME_BROWSER_POLICY_POLICY_MAP_H_
+
+#include <map>
+
+#include "base/values.h"
+#include "policy/configuration_policy_type.h"
+
+namespace policy {
+
+// Wrapper class around a std::map<ConfigurationPolicyType, Value*> that
+// properly cleans up after itself when going out of scope.
+// Exposes interesting methods of the underlying std::map.
+class PolicyMap {
+ public:
+ typedef std::map<ConfigurationPolicyType, Value*> PolicyMapType;
+ typedef PolicyMapType::const_iterator const_iterator;
+
+ PolicyMap();
+ virtual ~PolicyMap();
+
+ // Returns a weak reference to the value currently stored for key |policy|.
+ // Ownership is retained by PolicyMap; callers should use Value::DeepCopy
+ // if they need a copy that they own themselves.
+ // Returns NULL if the map does not contain a value for |policy|.
+ const Value* Get(ConfigurationPolicyType policy) const;
+ // Takes ownership of |value|. Overwrites any existing value stored in the
+ // map for the key |policy|.
+ void Set(ConfigurationPolicyType policy, Value* value);
+ void Erase(ConfigurationPolicyType policy);
+
+ void Swap(PolicyMap* other);
+
+ bool Equals(const PolicyMap& other) const;
+ bool empty() const;
+ size_t size() const;
+
+ const_iterator begin() const;
+ const_iterator end() const;
+ void Clear();
+
+ private:
+ // Helper function for Equals(...).
+ static bool MapEntryEquals(const PolicyMapType::value_type& a,
+ const PolicyMapType::value_type& b);
+
+ PolicyMapType map_;
+
+ DISALLOW_COPY_AND_ASSIGN(PolicyMap);
+};
+
+} // namespace policy
+
+#endif // CHROME_BROWSER_POLICY_POLICY_MAP_H_