| OLD | NEW |
| 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 #include "rlz/win/lib/rlz_value_store_registry.h" | 5 #include "rlz/win/lib/rlz_value_store_registry.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/win/registry.h" | 9 #include "base/win/registry.h" |
| 10 #include "rlz/lib/assert.h" | 10 #include "rlz/lib/assert.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // TODO: Move this to a registry_utils file and add unittest. | 135 // TODO: Move this to a registry_utils file and add unittest. |
| 136 bool DeleteKeyIfEmpty(HKEY root_key, const wchar_t* key_name) { | 136 bool DeleteKeyIfEmpty(HKEY root_key, const wchar_t* key_name) { |
| 137 if (!key_name) { | 137 if (!key_name) { |
| 138 ASSERT_STRING("DeleteKeyIfEmpty: key_name is NULL"); | 138 ASSERT_STRING("DeleteKeyIfEmpty: key_name is NULL"); |
| 139 return false; | 139 return false; |
| 140 } else { // Scope needed for RegKey | 140 } else { // Scope needed for RegKey |
| 141 base::win::RegKey key(root_key, key_name, KEY_READ); | 141 base::win::RegKey key(root_key, key_name, KEY_READ); |
| 142 if (!key.Valid()) | 142 if (!key.Valid()) |
| 143 return true; // Key does not exist - nothing to do. | 143 return true; // Key does not exist - nothing to do. |
| 144 | 144 |
| 145 base::win::RegistryKeyIterator key_iter(root_key, key_name); | 145 base::win::RegistryKeyIterator key_iter(root_key, key_name, 0); |
| 146 if (key_iter.SubkeyCount() > 0) | 146 if (key_iter.SubkeyCount() > 0) |
| 147 return true; // Not empty, so nothing to do | 147 return true; // Not empty, so nothing to do |
| 148 | 148 |
| 149 base::win::RegistryValueIterator value_iter(root_key, key_name); | 149 base::win::RegistryValueIterator value_iter(root_key, key_name, 0); |
| 150 if (value_iter.ValueCount() > 0) | 150 if (value_iter.ValueCount() > 0) |
| 151 return true; // Not empty, so nothing to do | 151 return true; // Not empty, so nothing to do |
| 152 } | 152 } |
| 153 | 153 |
| 154 // The key is empty - delete it now. | 154 // The key is empty - delete it now. |
| 155 base::win::RegKey key(root_key, L"", KEY_WRITE); | 155 base::win::RegKey key(root_key, L"", KEY_WRITE); |
| 156 return key.DeleteKey(key_name) == ERROR_SUCCESS; | 156 return key.DeleteKey(key_name) == ERROR_SUCCESS; |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace | 159 } // namespace |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 } | 377 } |
| 378 | 378 |
| 379 ScopedRlzValueStoreLock::~ScopedRlzValueStoreLock() { | 379 ScopedRlzValueStoreLock::~ScopedRlzValueStoreLock() { |
| 380 } | 380 } |
| 381 | 381 |
| 382 RlzValueStore* ScopedRlzValueStoreLock::GetStore() { | 382 RlzValueStore* ScopedRlzValueStoreLock::GetStore() { |
| 383 return store_.get(); | 383 return store_.get(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 } // namespace rlz_lib | 386 } // namespace rlz_lib |
| OLD | NEW |