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

Side by Side Diff: components/policy/core/common/registry_dict_win.h

Issue 1902633006: Convert //components/policy from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and use namespace alias 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_ 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory>
11 #include <string> 12 #include <string>
12 13
13 #include "base/macros.h" 14 #include "base/macros.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "components/policy/policy_export.h" 16 #include "components/policy/policy_export.h"
17 17
18 namespace base { 18 namespace base {
19 class Value; 19 class Value;
20 } 20 }
21 21
22 namespace policy { 22 namespace policy {
23 23
24 class Schema; 24 class Schema;
(...skipping 13 matching lines...) Expand all
38 typedef std::map<std::string, base::Value*, 38 typedef std::map<std::string, base::Value*,
39 CaseInsensitiveStringCompare> ValueMap; 39 CaseInsensitiveStringCompare> ValueMap;
40 40
41 RegistryDict(); 41 RegistryDict();
42 ~RegistryDict(); 42 ~RegistryDict();
43 43
44 // Returns a pointer to an existing key, NULL if not present. 44 // Returns a pointer to an existing key, NULL if not present.
45 RegistryDict* GetKey(const std::string& name); 45 RegistryDict* GetKey(const std::string& name);
46 const RegistryDict* GetKey(const std::string& name) const; 46 const RegistryDict* GetKey(const std::string& name) const;
47 // Sets a key. If |dict| is NULL, clears that key. 47 // Sets a key. If |dict| is NULL, clears that key.
48 void SetKey(const std::string& name, scoped_ptr<RegistryDict> dict); 48 void SetKey(const std::string& name, std::unique_ptr<RegistryDict> dict);
49 // Removes a key. If the key doesn't exist, NULL is returned. 49 // Removes a key. If the key doesn't exist, NULL is returned.
50 scoped_ptr<RegistryDict> RemoveKey(const std::string& name); 50 std::unique_ptr<RegistryDict> RemoveKey(const std::string& name);
51 // Clears all keys. 51 // Clears all keys.
52 void ClearKeys(); 52 void ClearKeys();
53 53
54 // Returns a pointer to a value, NULL if not present. 54 // Returns a pointer to a value, NULL if not present.
55 base::Value* GetValue(const std::string& name); 55 base::Value* GetValue(const std::string& name);
56 const base::Value* GetValue(const std::string& name) const; 56 const base::Value* GetValue(const std::string& name) const;
57 // Sets a value. If |value| is NULL, removes the value. 57 // Sets a value. If |value| is NULL, removes the value.
58 void SetValue(const std::string& name, scoped_ptr<base::Value> value); 58 void SetValue(const std::string& name, std::unique_ptr<base::Value> value);
59 // Removes a value. If the value doesn't exist, NULL is returned. 59 // Removes a value. If the value doesn't exist, NULL is returned.
60 scoped_ptr<base::Value> RemoveValue(const std::string& name); 60 std::unique_ptr<base::Value> RemoveValue(const std::string& name);
61 // Clears all values. 61 // Clears all values.
62 void ClearValues(); 62 void ClearValues();
63 63
64 // Merge keys and values from |other|, giving precedence to |other|. 64 // Merge keys and values from |other|, giving precedence to |other|.
65 void Merge(const RegistryDict& other); 65 void Merge(const RegistryDict& other);
66 66
67 // Swap with |other|. 67 // Swap with |other|.
68 void Swap(RegistryDict* other); 68 void Swap(RegistryDict* other);
69 69
70 // Read a Windows registry subtree into this registry dictionary object. 70 // Read a Windows registry subtree into this registry dictionary object.
71 void ReadRegistry(HKEY hive, const base::string16& root); 71 void ReadRegistry(HKEY hive, const base::string16& root);
72 72
73 // Converts the dictionary to base::Value representation. For key/value name 73 // Converts the dictionary to base::Value representation. For key/value name
74 // collisions, the key wins. |schema| is used to determine the expected type 74 // collisions, the key wins. |schema| is used to determine the expected type
75 // for each policy. 75 // for each policy.
76 // The returned object is either a base::DictionaryValue or a base::ListValue. 76 // The returned object is either a base::DictionaryValue or a base::ListValue.
77 scoped_ptr<base::Value> ConvertToJSON(const Schema& schema) const; 77 std::unique_ptr<base::Value> ConvertToJSON(const Schema& schema) const;
78 78
79 const KeyMap& keys() const { return keys_; } 79 const KeyMap& keys() const { return keys_; }
80 const ValueMap& values() const { return values_; } 80 const ValueMap& values() const { return values_; }
81 81
82 private: 82 private:
83 KeyMap keys_; 83 KeyMap keys_;
84 ValueMap values_; 84 ValueMap values_;
85 85
86 DISALLOW_COPY_AND_ASSIGN(RegistryDict); 86 DISALLOW_COPY_AND_ASSIGN(RegistryDict);
87 }; 87 };
88 88
89 } // namespace policy 89 } // namespace policy
90 90
91 #endif // COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_ 91 #endif // COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_
OLDNEW
« no previous file with comments | « components/policy/core/common/proxy_policy_provider_unittest.cc ('k') | components/policy/core/common/registry_dict_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698