| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/installer/util/set_reg_value_work_item.h" | 5 #include "chrome/installer/util/set_reg_value_work_item.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/win/registry.h" | 9 #include "base/win/registry.h" |
| 10 #include "chrome/installer/util/logging_installer.h" | 10 #include "chrome/installer/util/logging_installer.h" |
| 11 | 11 |
| 12 SetRegValueWorkItem::~SetRegValueWorkItem() { | 12 SetRegValueWorkItem::~SetRegValueWorkItem() { |
| 13 } | 13 } |
| 14 | 14 |
| 15 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, | 15 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, |
| 16 const std::wstring& key_path, | 16 const std::wstring& key_path, |
| 17 const std::wstring& value_name, | 17 const std::wstring& value_name, |
| 18 const std::wstring& value_data, | 18 const std::wstring& value_data, |
| 19 bool overwrite) | 19 bool overwrite, |
| 20 RegWow64ViewOption reg_wow64_option) |
| 20 : predefined_root_(predefined_root), | 21 : predefined_root_(predefined_root), |
| 21 key_path_(key_path), | 22 key_path_(key_path), |
| 22 value_name_(value_name), | 23 value_name_(value_name), |
| 23 overwrite_(overwrite), | 24 overwrite_(overwrite), |
| 25 reg_wow64_option_(reg_wow64_option), |
| 24 status_(SET_VALUE), | 26 status_(SET_VALUE), |
| 25 type_(REG_SZ), | 27 type_(REG_SZ), |
| 26 previous_type_(0) { | 28 previous_type_(0) { |
| 27 const uint8* data = reinterpret_cast<const uint8*>(value_data.c_str()); | 29 const uint8* data = reinterpret_cast<const uint8*>(value_data.c_str()); |
| 28 value_.assign(data, data + (value_data.length() + 1) * sizeof(wchar_t)); | 30 value_.assign(data, data + (value_data.length() + 1) * sizeof(wchar_t)); |
| 29 } | 31 } |
| 30 | 32 |
| 31 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, | 33 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, |
| 32 const std::wstring& key_path, | 34 const std::wstring& key_path, |
| 33 const std::wstring& value_name, | 35 const std::wstring& value_name, |
| 34 DWORD value_data, | 36 DWORD value_data, |
| 35 bool overwrite) | 37 bool overwrite, |
| 38 RegWow64ViewOption reg_wow64_option) |
| 36 : predefined_root_(predefined_root), | 39 : predefined_root_(predefined_root), |
| 37 key_path_(key_path), | 40 key_path_(key_path), |
| 38 value_name_(value_name), | 41 value_name_(value_name), |
| 39 overwrite_(overwrite), | 42 overwrite_(overwrite), |
| 43 reg_wow64_option_(reg_wow64_option), |
| 40 status_(SET_VALUE), | 44 status_(SET_VALUE), |
| 41 type_(REG_DWORD), | 45 type_(REG_DWORD), |
| 42 previous_type_(0) { | 46 previous_type_(0) { |
| 43 const uint8* data = reinterpret_cast<const uint8*>(&value_data); | 47 const uint8* data = reinterpret_cast<const uint8*>(&value_data); |
| 44 value_.assign(data, data + sizeof(value_data)); | 48 value_.assign(data, data + sizeof(value_data)); |
| 45 } | 49 } |
| 46 | 50 |
| 47 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, | 51 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, |
| 48 const std::wstring& key_path, | 52 const std::wstring& key_path, |
| 49 const std::wstring& value_name, | 53 const std::wstring& value_name, |
| 50 int64 value_data, | 54 int64 value_data, |
| 51 bool overwrite) | 55 bool overwrite, |
| 56 RegWow64ViewOption reg_wow64_option) |
| 52 : predefined_root_(predefined_root), | 57 : predefined_root_(predefined_root), |
| 53 key_path_(key_path), | 58 key_path_(key_path), |
| 54 value_name_(value_name), | 59 value_name_(value_name), |
| 55 overwrite_(overwrite), | 60 overwrite_(overwrite), |
| 61 reg_wow64_option_(reg_wow64_option), |
| 56 status_(SET_VALUE), | 62 status_(SET_VALUE), |
| 57 type_(REG_QWORD), | 63 type_(REG_QWORD), |
| 58 previous_type_(0) { | 64 previous_type_(0) { |
| 59 const uint8* data = reinterpret_cast<const uint8*>(&value_data); | 65 const uint8* data = reinterpret_cast<const uint8*>(&value_data); |
| 60 value_.assign(data, data + sizeof(value_data)); | 66 value_.assign(data, data + sizeof(value_data)); |
| 61 } | 67 } |
| 62 | 68 |
| 63 bool SetRegValueWorkItem::Do() { | 69 bool SetRegValueWorkItem::Do() { |
| 64 LONG result = ERROR_SUCCESS; | 70 LONG result = ERROR_SUCCESS; |
| 65 base::win::RegKey key; | 71 base::win::RegKey key; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 result = key.WriteValue(value_name_.c_str(), previous_value, | 148 result = key.WriteValue(value_name_.c_str(), previous_value, |
| 143 static_cast<DWORD>(previous_value_.size()), | 149 static_cast<DWORD>(previous_value_.size()), |
| 144 previous_type_); | 150 previous_type_); |
| 145 VLOG(1) << "rollback: restoring " << value_name_ << " error: " << result; | 151 VLOG(1) << "rollback: restoring " << value_name_ << " error: " << result; |
| 146 } else { | 152 } else { |
| 147 NOTREACHED(); | 153 NOTREACHED(); |
| 148 } | 154 } |
| 149 | 155 |
| 150 status_ = VALUE_ROLL_BACK; | 156 status_ = VALUE_ROLL_BACK; |
| 151 } | 157 } |
| OLD | NEW |