Chromium Code Reviews| Index: base/win/registry.cc |
| diff --git a/base/win/registry.cc b/base/win/registry.cc |
| index a6cb9ae89f789a78461e7d611374e603f492b724..28249bf0058df3e948a6d614ed4b6685d30c6bf0 100644 |
| --- a/base/win/registry.cc |
| +++ b/base/win/registry.cc |
| @@ -487,10 +487,26 @@ LONG RegKey::RegDelRecurse(HKEY root_key, |
| // RegistryValueIterator ------------------------------------------------------ |
| RegistryValueIterator::RegistryValueIterator(HKEY root_key, |
| + const wchar_t* folder_key, |
| + REGSAM wow64access) |
| + : name_(MAX_PATH, L'\0'), |
| + value_(MAX_PATH, L'\0') { |
| + Initialize(root_key, folder_key, wow64access); |
| +} |
| + |
| +RegistryValueIterator::RegistryValueIterator(HKEY root_key, |
| const wchar_t* folder_key) |
| : name_(MAX_PATH, L'\0'), |
| value_(MAX_PATH, L'\0') { |
| - LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_); |
| + Initialize(root_key, folder_key, 0); |
| +} |
| + |
| +void RegistryValueIterator::Initialize(HKEY root_key, |
| + const wchar_t* folder_key, |
| + REGSAM wow64access) { |
| + DCHECK(!wow64access || wow64access & kWow64AccessMask); |
|
grt (UTC plus 2)
2014/10/07 15:47:10
is DCHECK_EQ((wow64Access & ~kWow64AccessMask), st
Will Harris
2014/10/07 17:16:14
Done.
|
| + LONG result = |
| + RegOpenKeyEx(root_key, folder_key, 0, KEY_READ | wow64access, &key_); |
| if (result != ERROR_SUCCESS) { |
| key_ = NULL; |
| } else { |
| @@ -577,23 +593,13 @@ bool RegistryValueIterator::Read() { |
| RegistryKeyIterator::RegistryKeyIterator(HKEY root_key, |
| const wchar_t* folder_key) { |
| - LONG result = RegOpenKeyEx(root_key, folder_key, 0, KEY_READ, &key_); |
| - if (result != ERROR_SUCCESS) { |
| - key_ = NULL; |
| - } else { |
| - DWORD count = 0; |
| - LONG result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL, |
| - NULL, NULL, NULL, NULL, NULL); |
| - |
| - if (result != ERROR_SUCCESS) { |
| - ::RegCloseKey(key_); |
| - key_ = NULL; |
| - } else { |
| - index_ = count - 1; |
| - } |
| - } |
| + Initialize(root_key, folder_key, 0); |
| +} |
| - Read(); |
| +RegistryKeyIterator::RegistryKeyIterator(HKEY root_key, |
| + const wchar_t* folder_key, |
| + REGSAM wow64access) { |
| + Initialize(root_key, folder_key, wow64access); |
| } |
| RegistryKeyIterator::~RegistryKeyIterator() { |
| @@ -634,5 +640,29 @@ bool RegistryKeyIterator::Read() { |
| return false; |
| } |
| +void RegistryKeyIterator::Initialize(HKEY root_key, |
| + const wchar_t* folder_key, |
| + REGSAM wow64access) { |
| + DCHECK(!wow64access || wow64access & kWow64AccessMask); |
| + LONG result = |
| + RegOpenKeyEx(root_key, folder_key, 0, KEY_READ | wow64access, &key_); |
| + if (result != ERROR_SUCCESS) { |
| + key_ = NULL; |
| + } else { |
| + DWORD count = 0; |
| + LONG result = ::RegQueryInfoKey(key_, NULL, 0, NULL, &count, NULL, NULL, |
| + NULL, NULL, NULL, NULL, NULL); |
| + |
| + if (result != ERROR_SUCCESS) { |
| + ::RegCloseKey(key_); |
| + key_ = NULL; |
| + } else { |
| + index_ = count - 1; |
| + } |
| + } |
| + |
| + Read(); |
| +} |
| + |
| } // namespace win |
| } // namespace base |