Commit d817e6f6 authored by Julian Pastarmov's avatar Julian Pastarmov Committed by Commit Bot

Clean up comments and style for the getDeviceInfo API for Windows

Fixing comments on the already submitted
https://chromium-review.googlesource.com/c/chromium/src/+/1952324.

BUG=none

Change-Id: Ic8037c6e3d8b51944ba39d2782f78a9d068c9c20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2027414
Auto-Submit: Julian Pastarmov <pastarmovj@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736420}
parent 0c24ea68
......@@ -71,9 +71,6 @@ base::Optional<bool> GetConsoleLockStatus() {
if (!::GetSystemPowerStatus(&sps))
return status;
auto const power_read_current_value =
sps.ACLineStatus != 0U ? &PowerReadACValue : &PowerReadDCValue;
LPGUID p_active_policy = nullptr;
// https://docs.microsoft.com/en-us/windows/desktop/api/powersetting/nf-powersetting-powergetactivescheme
// Retrieves the active power scheme and returns a GUID that identifies the
......@@ -87,6 +84,8 @@ base::Optional<bool> GetConsoleLockStatus() {
const GUID active_policy = *p_active_policy;
::LocalFree(p_active_policy);
auto const power_read_current_value_func =
sps.ACLineStatus != 0U ? &PowerReadACValue : &PowerReadDCValue;
ULONG type;
DWORD value;
DWORD value_size = sizeof(value);
......@@ -96,7 +95,7 @@ base::Optional<bool> GetConsoleLockStatus() {
// LPBYTE case is safe and is needed as the function expects generic byte
// array buffer regardless of the exact value read as it is a generic
// interface.
if (power_read_current_value(
if (power_read_current_value_func(
nullptr, &active_policy, &NO_SUBGROUP_GUID, &kConsoleLock, &type,
reinterpret_cast<LPBYTE>(&value), &value_size) == ERROR_SUCCESS) {
status = value != 0U;
......@@ -124,8 +123,7 @@ enterprise_reporting_private::SettingValue GetScreenlockSecured() {
return enterprise_reporting_private::SETTING_VALUE_UNKNOWN;
}
// Writes the volume where the Windows OS is installed in |out_volume|. Returns
// false if there was an error retrieving the volume.
// Returns the volume where the Windows OS is installed.
base::Optional<std::wstring> GetOsVolume() {
base::Optional<std::wstring> volume;
base::FilePath windows_dir;
......@@ -180,7 +178,7 @@ bool GetPropVariantAsInt64(PROPVARIANT variant, int64_t* out_value) {
// The values given in the BitLockerStatus enum contain the relevant values
// for the shell property. I also directly validated them.
enterprise_reporting_private::SettingValue GetDiskEncrypted() {
// It has to be a |wstring| because |SHCreateItemFromParsingName| only
// |volume| has to be a |wstring| because SHCreateItemFromParsingName() only
// accepts |PCWSTR| which is |wchar_t*|.
base::Optional<std::wstring> volume = GetOsVolume();
if (!volume.has_value())
......@@ -192,9 +190,6 @@ enterprise_reporting_private::SettingValue GetDiskEncrypted() {
if (FAILED(property_key_result))
return enterprise_reporting_private::SETTING_VALUE_UNKNOWN;
// This class inherits from IUnknown, which is essentially a pointer to
// a reference counted object. The reference should be released explicitly
// calling item->Release().
Microsoft::WRL::ComPtr<IShellItem2> item;
const HRESULT create_item_result = SHCreateItemFromParsingName(
volume.value().c_str(), nullptr, IID_IShellItem2, &item);
......
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