Index: chrome/install_static/install_util.cc |
diff --git a/chrome/install_static/install_util.cc b/chrome/install_static/install_util.cc |
index edec76d2e567b011248c619f0f601cedeb09bc7a..fae64aa1b8b15b4eb9ba22fae747c0df60ca5e1f 100644 |
--- a/chrome/install_static/install_util.cc |
+++ b/chrome/install_static/install_util.cc |
@@ -412,16 +412,13 @@ bool GetCollectStatsInSample() { |
bool SetCollectStatsInSample(bool in_sample) { |
std::wstring registry_path = GetChromeInstallRegistryPath(); |
- HANDLE key_handle = INVALID_HANDLE_VALUE; |
- if (!nt::CreateRegKey(nt::HKCU, registry_path.c_str(), |
- KEY_SET_VALUE | KEY_WOW64_32KEY, &key_handle)) { |
+ nt::ScopedRegKeyHANDLE key = nt::CreateRegKey( |
+ nt::HKCU, registry_path.c_str(), KEY_SET_VALUE | KEY_WOW64_32KEY); |
+ if (!key.is_valid()) |
return false; |
- } |
- bool success = nt::SetRegValueDWORD(key_handle, kRegValueChromeStatsSample, |
- in_sample ? 1 : 0); |
- nt::CloseRegKey(key_handle); |
- return success; |
+ return nt::SetRegValueDWORD(key.get(), kRegValueChromeStatsSample, |
+ in_sample ? 1 : 0); |
} |
bool ReportingIsEnforcedByPolicy(bool* crash_reporting_enabled) { |