Commit 55c84fe6 authored by S. Ganesh's avatar S. Ganesh Committed by Commit Bot

Change to key.Open from key.Create in SetServiceName to possibly fix UTs

This is how the code was earlier, but I changed it recently in CL
2071387 to do a Create instead, which is likely causing the side-effect
of leaving a stale key out there.

Bug: 1059314
Change-Id: I48f07e30621b61a7db2b60495c3b0b286323b0a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2095919
Commit-Queue: S. Ganesh <ganesh@chromium.org>
Auto-Submit: S. Ganesh <ganesh@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#748858}
parent 96fbc800
...@@ -341,12 +341,16 @@ bool InstallServiceWorkItemImpl::SetServiceName( ...@@ -341,12 +341,16 @@ bool InstallServiceWorkItemImpl::SetServiceName(
const base::string16& service_name) const { const base::string16& service_name) const {
base::win::RegKey key; base::win::RegKey key;
auto result = key.Create(HKEY_LOCAL_MACHINE, // This assumes that a WorkItem to create the key has already executed before
install_static::GetClientStateKeyPath().c_str(), // this WorkItem. this is generally true since one is added in
KEY_SET_VALUE | KEY_WOW64_32KEY); // AddUninstallShortcutWorkItems.
auto result = key.Open(HKEY_LOCAL_MACHINE,
install_static::GetClientStateKeyPath().c_str(),
KEY_SET_VALUE | KEY_WOW64_32KEY);
DCHECK(result == ERROR_SUCCESS);
if (result != ERROR_SUCCESS) { if (result != ERROR_SUCCESS) {
::SetLastError(result); ::SetLastError(result);
PLOG(ERROR) << "key.Create failed"; PLOG(ERROR) << "key.Open failed";
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment