Index: chrome/installer/util/set_reg_value_work_item.cc |
=================================================================== |
--- chrome/installer/util/set_reg_value_work_item.cc (revision 70414) |
+++ chrome/installer/util/set_reg_value_work_item.cc (working copy) |
@@ -50,65 +50,54 @@ |
} |
base::win::RegKey key; |
- if (!key.Open(predefined_root_, key_path_.c_str(), |
- KEY_READ | KEY_SET_VALUE)) { |
- LOG(ERROR) << "can not open " << key_path_; |
+ LONG result = key.Open(predefined_root_, key_path_.c_str(), |
+ KEY_READ | KEY_SET_VALUE); |
+ if (result != ERROR_SUCCESS) { |
+ LOG(ERROR) << "can not open " << key_path_ << " error: " << result; |
grt (UTC plus 2)
2011/01/11 03:51:30
com::LogWe here and everywhere
|
status_ = VALUE_UNCHANGED; |
return false; |
} |
- bool result = false; |
if (key.ValueExists(value_name_.c_str())) { |
if (overwrite_) { |
- bool success = true; |
// Read previous value for rollback and write new value |
if (is_str_type_) { |
- std::wstring data; |
- if (key.ReadValue(value_name_.c_str(), &data)) { |
- previous_value_str_.assign(data); |
- } |
- success = key.WriteValue(value_name_.c_str(), value_data_str_.c_str()); |
+ key.ReadValue(value_name_.c_str(), &previous_value_str_); |
+ result = key.WriteValue(value_name_.c_str(), value_data_str_.c_str()); |
} else { |
- DWORD data; |
- if (key.ReadValueDW(value_name_.c_str(), &data)) { |
- previous_value_dword_ = data; |
- } |
- success = key.WriteValue(value_name_.c_str(), value_data_dword_); |
+ key.ReadValueDW(value_name_.c_str(), &previous_value_dword_); |
+ result = key.WriteValue(value_name_.c_str(), value_data_dword_); |
} |
- if (success) { |
+ if (result == ERROR_SUCCESS) { |
VLOG(1) << "overwritten value for " << value_name_; |
status_ = VALUE_OVERWRITTEN; |
- result = true; |
} else { |
- LOG(ERROR) << "failed to overwrite value for " << value_name_; |
+ LOG(ERROR) << "failed to overwrite value for " << value_name_ |
+ << " error: " << result; |
status_ = VALUE_UNCHANGED; |
- result = false; |
} |
} else { |
VLOG(1) << value_name_ << " exists. not changed "; |
status_ = VALUE_UNCHANGED; |
- result = true; |
} |
} else { |
- bool success = true; |
if (is_str_type_) { |
- success = key.WriteValue(value_name_.c_str(), value_data_str_.c_str()); |
+ result = key.WriteValue(value_name_.c_str(), value_data_str_.c_str()); |
} else { |
- success = key.WriteValue(value_name_.c_str(), value_data_dword_); |
+ result = key.WriteValue(value_name_.c_str(), value_data_dword_); |
} |
- if (success) { |
+ if (result == ERROR_SUCCESS) { |
VLOG(1) << "created value for " << value_name_; |
status_ = NEW_VALUE_CREATED; |
- result = true; |
} else { |
- LOG(ERROR) << "failed to create value for " << value_name_; |
+ LOG(ERROR) << "failed to create value for " << value_name_ |
+ << " error: " << result; |
status_ = VALUE_UNCHANGED; |
- result = false; |
} |
} |
key.Close(); |
- return result; |
+ return result == ERROR_SUCCESS; |
} |
void SetRegValueWorkItem::Rollback() { |
@@ -122,32 +111,28 @@ |
} |
base::win::RegKey key; |
- if (!key.Open(predefined_root_, key_path_.c_str(), |
- KEY_READ | KEY_SET_VALUE)) { |
+ LONG result = key.Open(predefined_root_, key_path_.c_str(), |
+ KEY_READ | KEY_SET_VALUE); |
+ if (result != ERROR_SUCCESS) { |
status_ = VALUE_ROLL_BACK; |
- VLOG(1) << "rollback: can not open " << key_path_; |
+ VLOG(1) << "rollback: can not open " << key_path_ << " error: " << result; |
return; |
} |
- std::wstring result_str(L" failed"); |
if (status_ == NEW_VALUE_CREATED) { |
- if (key.DeleteValue(value_name_.c_str())) |
- result_str.assign(L" succeeded"); |
- VLOG(1) << "rollback: deleting " << value_name_ << result_str; |
+ result = key.DeleteValue(value_name_.c_str()); |
+ VLOG(1) << "rollback: deleting " << value_name_ << " error: " << result; |
} else if (status_ == VALUE_OVERWRITTEN) { |
// try restore the previous value |
- bool success = true; |
if (is_str_type_) { |
- success = key.WriteValue(value_name_.c_str(), |
- previous_value_str_.c_str()); |
+ result = key.WriteValue(value_name_.c_str(), previous_value_str_.c_str()); |
} else { |
- success = key.WriteValue(value_name_.c_str(), previous_value_dword_); |
+ result = key.WriteValue(value_name_.c_str(), previous_value_dword_); |
} |
- if (success) |
- result_str.assign(L" succeeded"); |
- VLOG(1) << "rollback: restoring " << value_name_ << result_str; |
+ VLOG(1) << "rollback: restoring " << value_name_ << " error: " << result; |
} else { |
// Not reached. |
+ NOTREACHED(); |
} |
status_ = VALUE_ROLL_BACK; |