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

Unified Diff: components/policy/core/common/policy_map.h

Issue 1940153002: Use std::unique_ptr to express ownership of base::Value in PolicyMap::Entry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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: components/policy/core/common/policy_map.h
diff --git a/components/policy/core/common/policy_map.h b/components/policy/core/common/policy_map.h
index 9960531f64e1dea99dbb3baaaf922c44de7632e1..5b527adb867f7dace8ff37e9a3e30a7371bbd88f 100644
--- a/components/policy/core/common/policy_map.h
+++ b/components/policy/core/common/policy_map.h
@@ -28,19 +28,20 @@ class POLICY_EXPORT PolicyMap {
struct POLICY_EXPORT Entry {
PolicyLevel level;
PolicyScope scope;
- base::Value* value;
- ExternalDataFetcher* external_data_fetcher;
+ std::unique_ptr<base::Value> value;
+ std::unique_ptr<ExternalDataFetcher> external_data_fetcher;
// For debugging and displaying only. Set by provider delivering the policy.
PolicySource source;
Entry();
+ ~Entry();
- // Deletes all members owned by |this|.
- void DeleteOwnedMembers();
+ Entry(Entry&&);
+ Entry& operator=(Entry&&);
// Returns a copy of |this|.
- std::unique_ptr<Entry> DeepCopy() const;
+ Entry DeepCopy() const;
// Returns true if |this| has higher priority than |other|.
bool has_higher_priority_than(const Entry& other) const;
@@ -64,14 +65,14 @@ class POLICY_EXPORT PolicyMap {
// This is equivalent to Get(policy)->value, when it doesn't return NULL.
const base::Value* GetValue(const std::string& policy) const;
- // Takes ownership of |value| and |external_data_fetcher|. Overwrites any
- // existing information stored in the map for the key |policy|.
+ // Overwrites any existing information stored in the map for the key |policy|.
void Set(const std::string& policy,
PolicyLevel level,
PolicyScope scope,
PolicySource source,
- base::Value* value,
- ExternalDataFetcher* external_data_fetcher);
+ std::unique_ptr<base::Value> value,
+ std::unique_ptr<ExternalDataFetcher> external_data_fetcher);
+ void Set(const std::string& policy, Entry entry);
// Erase the given |policy|, if it exists in this map.
void Erase(const std::string& policy);

Powered by Google App Engine
This is Rietveld 408576698