From e06f4d5c6bd7bad162c45784e39cd0114635eb42 Mon Sep 17 00:00:00 2001 From: "amit@chromium.org" Date: Wed, 19 Jan 2011 07:28:46 +0000 Subject: Regkey functions return error code instead of bool Change the Regkey helper to consistently use and return LONG instead of bool. Fix RegKey usage all over the code base and get rid of workarounds due to lack of return value. Reviewers: brettw: everything (skip parts for other reviewers if you wish) robertshield,grt: chrome_frame, installer siggi: ceee BUG=none TEST=covered by existing tests Review URL: http://codereview.chromium.org/6090006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71768 0039d316-1c4b-4281-b951-d872f2087c98 --- .../internal/registry_ready_mode_state.cc | 42 +++++++++------------- 1 file changed, 17 insertions(+), 25 deletions(-) (limited to 'chrome_frame/ready_mode') diff --git a/chrome_frame/ready_mode/internal/registry_ready_mode_state.cc b/chrome_frame/ready_mode/internal/registry_ready_mode_state.cc index 244d63f5..880fd51 100644 --- a/chrome_frame/ready_mode/internal/registry_ready_mode_state.cc +++ b/chrome_frame/ready_mode/internal/registry_ready_mode_state.cc @@ -34,9 +34,11 @@ HANDLE LaunchCommandDirectly(const std::wstring& command_field) { for (int i = 0; i < arraysize(roots); i++) { base::win::RegKey version_key; - if (version_key.Open(roots[i], version_key_name.c_str(), KEY_QUERY_VALUE)) { + if (version_key.Open(roots[i], version_key_name.c_str(), + KEY_QUERY_VALUE) == ERROR_SUCCESS) { std::wstring command_line; - if (version_key.ReadValue(command_field.c_str(), &command_line)) { + if (version_key.ReadValue(command_field.c_str(), + &command_line) == ERROR_SUCCESS) { HANDLE launched_process = NULL; if (base::LaunchApp(command_line, false, true, &launched_process)) { return launched_process; @@ -186,34 +188,24 @@ bool RegistryReadyModeState::GetValue(int64* value, bool* exists) { *exists = false; *value = 0; - HKEY roots[] = {HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE}; - + HKEY roots[] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE }; + LONG result = ERROR_SUCCESS; for (int i = 0; i < arraysize(roots); i++) { base::win::RegKey config_key; - - if (config_key.Open(roots[i], key_name_.c_str(), KEY_QUERY_VALUE)) { - if (config_key.ValueExists(installer::kChromeFrameReadyModeField)) { - int64 temp; - DWORD value_size = sizeof(temp); - DWORD type = 0; - if (!config_key.ReadValue(installer::kChromeFrameReadyModeField, - &temp, &value_size, &type)) { - DLOG(ERROR) << "Failed to read from registry key " << key_name_ - << " and value " << installer::kChromeFrameReadyModeField; - return false; - } - - if (value_size != sizeof(temp) || type != REG_QWORD) { - DLOG(ERROR) << "Unexpected state found under registry key " - << key_name_ << " and value " - << installer::kChromeFrameReadyModeField; - return false; - } - - *value = temp; + result = config_key.Open(roots[i], key_name_.c_str(), KEY_QUERY_VALUE); + if (result == ERROR_SUCCESS) { + result = config_key.ReadInt64(installer::kChromeFrameReadyModeField, + value); + if (result == ERROR_SUCCESS) { *exists = true; return true; } + if (result != ERROR_FILE_NOT_FOUND) { + DLOG(ERROR) << "Failed to read from registry key " << key_name_ + << " and value " << installer::kChromeFrameReadyModeField + << " error: " << result; + return false; + } } } -- cgit v1.1