summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-07 17:55:14 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-07 17:55:14 +0000
commit3cc8a9881a086b30707c356b84aef8b046b39e67 (patch)
treea7020154995f546bf71271f9d810deea1ab96660
parentf7b732f4903f01394ab486d352b2a3efbf0e1652 (diff)
downloadchromium_src-3cc8a9881a086b30707c356b84aef8b046b39e67.zip
chromium_src-3cc8a9881a086b30707c356b84aef8b046b39e67.tar.gz
chromium_src-3cc8a9881a086b30707c356b84aef8b046b39e67.tar.bz2
Making a few RegKey methods that only read data, const.
This is so that we can make methods that don't alter the contained HKEY or the data it represents accept const references of RegKey. TEST=none BUG=none Review URL: http://codereview.chromium.org/5623004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68489 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/win/registry.cc10
-rw-r--r--base/win/registry.h13
2 files changed, 12 insertions, 11 deletions
diff --git a/base/win/registry.cc b/base/win/registry.cc
index 3372cf4..f8e05a7 100644
--- a/base/win/registry.cc
+++ b/base/win/registry.cc
@@ -244,7 +244,7 @@ bool RegKey::OpenKey(const wchar_t* name, REGSAM access) {
return (result == ERROR_SUCCESS);
}
-DWORD RegKey::ValueCount() {
+DWORD RegKey::ValueCount() const {
base::ThreadRestrictions::AssertIOAllowed();
DWORD count = 0;
HRESULT result = RegQueryInfoKey(key_, NULL, 0, NULL, NULL, NULL,
@@ -252,7 +252,7 @@ DWORD RegKey::ValueCount() {
return (result != ERROR_SUCCESS) ? 0 : count;
}
-bool RegKey::ReadName(int index, std::wstring* name) {
+bool RegKey::ReadName(int index, std::wstring* name) const {
base::ThreadRestrictions::AssertIOAllowed();
wchar_t buf[256];
DWORD bufsize = arraysize(buf);
@@ -274,7 +274,7 @@ bool RegKey::ValueExists(const wchar_t* name) {
}
bool RegKey::ReadValue(const wchar_t* name, void* data,
- DWORD* dsize, DWORD* dtype) {
+ DWORD* dsize, DWORD* dtype) const {
base::ThreadRestrictions::AssertIOAllowed();
if (!key_)
return false;
@@ -283,7 +283,7 @@ bool RegKey::ReadValue(const wchar_t* name, void* data,
return (result == ERROR_SUCCESS);
}
-bool RegKey::ReadValue(const wchar_t* name, std::wstring* value) {
+bool RegKey::ReadValue(const wchar_t* name, std::wstring* value) const {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(value);
const size_t kMaxStringLength = 1024; // This is after expansion.
@@ -312,7 +312,7 @@ bool RegKey::ReadValue(const wchar_t* name, std::wstring* value) {
return false;
}
-bool RegKey::ReadValueDW(const wchar_t* name, DWORD* value) {
+bool RegKey::ReadValueDW(const wchar_t* name, DWORD* value) const {
DCHECK(value);
DWORD type = REG_DWORD;
DWORD size = sizeof(DWORD);
diff --git a/base/win/registry.h b/base/win/registry.h
index d1ef25b..96a2bb3 100644
--- a/base/win/registry.h
+++ b/base/win/registry.h
@@ -38,10 +38,10 @@ class RegKey {
void Close();
- DWORD ValueCount();
+ DWORD ValueCount() const;
// Determine the nth value's name.
- bool ReadName(int index, std::wstring* name);
+ bool ReadName(int index, std::wstring* name) const;
// True while the key is valid.
bool Valid() const { return key_ != NULL; }
@@ -55,9 +55,10 @@ class RegKey {
bool ValueExists(const wchar_t* name);
- bool ReadValue(const wchar_t* name, void* data, DWORD* dsize, DWORD* dtype);
- bool ReadValue(const wchar_t* name, std::wstring* value);
- bool ReadValueDW(const wchar_t* name, DWORD* value);
+ bool ReadValue(const wchar_t* name, void* data, DWORD* dsize,
+ DWORD* dtype) const;
+ bool ReadValue(const wchar_t* name, std::wstring* value) const;
+ bool ReadValueDW(const wchar_t* name, DWORD* value) const;
bool WriteValue(const wchar_t* name, const void* data, DWORD dsize,
DWORD dtype);
@@ -65,7 +66,7 @@ class RegKey {
bool WriteValue(const wchar_t* name, DWORD value);
// Starts watching the key to see if any of its values have changed.
- // The key must have been opened with the KEY_NOTIFY access privelege.
+ // The key must have been opened with the KEY_NOTIFY access privilege.
bool StartWatching();
// If StartWatching hasn't been called, always returns false.