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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/policy_map.h
diff --git a/chrome/browser/policy/policy_map.h b/chrome/browser/policy/policy_map.h
new file mode 100644
index 0000000000000000000000000000000000000000..37c761d50db56bd83d58af527815148ecd38fb27
--- /dev/null
+++ b/chrome/browser/policy/policy_map.h
@@ -0,0 +1,53 @@
+// 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.
+
Mattias Nissler (ping if slow) 2011/02/17 09:27:20 excess whitespace
Jakob Kummerow 2011/02/17 09:47:14 Done.
+
+#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 (similar to a
+// 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).
+class PolicyMap {
+ public:
+ typedef std::map<ConfigurationPolicyType, Value*> PolicyMapType;
+ typedef PolicyMapType::const_iterator const_iterator;
+
+ PolicyMap();
+ virtual ~PolicyMap();
+
+ 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.
+ 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();
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.
+
+ 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_

Powered by Google App Engine
This is Rietveld 408576698