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

Side by Side Diff: base/win/registry.h

Issue 2963783002: Remove unsafe registry APIs from base::win::RegKey
Patch Set: half-fix remoting Created 3 years, 5 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
« no previous file with comments | « no previous file | base/win/registry.cc » ('j') | base/win/registry.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 BASE_WIN_REGISTRY_H_ 5 #ifndef BASE_WIN_REGISTRY_H_
6 #define BASE_WIN_REGISTRY_H_ 6 #define BASE_WIN_REGISTRY_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 #include <string> 10 #include <string>
(...skipping 15 matching lines...) Expand all
26 // * ReadValue family of functions guarantee that the out-parameter 26 // * ReadValue family of functions guarantee that the out-parameter
27 // is not touched in case of failure. 27 // is not touched in case of failure.
28 // * Functions returning LONG indicate success as ERROR_SUCCESS or an 28 // * Functions returning LONG indicate success as ERROR_SUCCESS or an
29 // error as a (non-zero) win32 error code. 29 // error as a (non-zero) win32 error code.
30 class BASE_EXPORT RegKey { 30 class BASE_EXPORT RegKey {
31 public: 31 public:
32 // Called from the MessageLoop when the key changes. 32 // Called from the MessageLoop when the key changes.
33 typedef base::Callback<void()> ChangeCallback; 33 typedef base::Callback<void()> ChangeCallback;
34 34
35 RegKey(); 35 RegKey();
36 explicit RegKey(HKEY key); 36 explicit RegKey(HKEY rootkey);
37 RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access); 37 RegKey(HKEY rootkey, const wchar_t* subkey, REGSAM access);
38 ~RegKey(); 38 ~RegKey();
39 39
40 RegKey(RegKey&&);
41 RegKey& operator=(RegKey&&);
42
40 LONG Create(HKEY rootkey, const wchar_t* subkey, REGSAM access); 43 LONG Create(HKEY rootkey, const wchar_t* subkey, REGSAM access);
41 44
42 LONG CreateWithDisposition(HKEY rootkey, const wchar_t* subkey, 45 LONG CreateWithDisposition(HKEY rootkey, const wchar_t* subkey,
43 DWORD* disposition, REGSAM access); 46 DWORD* disposition, REGSAM access);
44 47
45 // Creates a subkey or open it if it already exists. 48 // Creates a subkey or open it if it already exists.
46 LONG CreateKey(const wchar_t* name, REGSAM access); 49 LONG CreateKey(const wchar_t* name, REGSAM access);
47 50
48 // Opens an existing reg key. 51 // Opens an existing reg key.
49 LONG Open(HKEY rootkey, const wchar_t* subkey, REGSAM access); 52 LONG Open(HKEY rootkey, const wchar_t* subkey, REGSAM access);
50 53
51 // Opens an existing reg key, given the relative key name. 54 // Opens an existing reg key, given the relative key name.
52 LONG OpenKey(const wchar_t* relative_key_name, REGSAM access); 55 LONG OpenKey(const wchar_t* relative_key_name, REGSAM access);
53 56
54 // Closes this reg key. 57 // Closes this reg key.
55 void Close(); 58 void Close();
56 59
57 // Replaces the handle of the registry key and takes ownership of the handle.
58 void Set(HKEY key);
59
60 // Transfers ownership away from this object.
61 HKEY Take();
62
63 // Returns false if this key does not have the specified value, or if an error 60 // Returns false if this key does not have the specified value, or if an error
64 // occurrs while attempting to access it. 61 // occurrs while attempting to access it.
65 bool HasValue(const wchar_t* value_name) const; 62 bool HasValue(const wchar_t* value_name) const;
66 63
67 // Returns the number of values for this key, or 0 if the number cannot be 64 // Returns the number of values for this key, or 0 if the number cannot be
68 // determined. 65 // determined.
69 DWORD GetValueCount() const; 66 DWORD GetValueCount() const;
70 67
71 // Determines the nth value's name. 68 // Determines the nth value's name.
72 LONG GetValueNameAt(int index, std::wstring* name) const; 69 LONG GetValueNameAt(int index, std::wstring* name) const;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 249
253 wchar_t name_[MAX_PATH]; 250 wchar_t name_[MAX_PATH];
254 251
255 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator); 252 DISALLOW_COPY_AND_ASSIGN(RegistryKeyIterator);
256 }; 253 };
257 254
258 } // namespace win 255 } // namespace win
259 } // namespace base 256 } // namespace base
260 257
261 #endif // BASE_WIN_REGISTRY_H_ 258 #endif // BASE_WIN_REGISTRY_H_
OLDNEW
« no previous file with comments | « no previous file | base/win/registry.cc » ('j') | base/win/registry.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698