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 REGSAM wow64_access, | 17 REGSAM wow64_access, |
18 const std::wstring& value_name, | 18 const std::wstring& value_name, |
19 const std::wstring& value_data, | 19 const std::wstring& value_data, |
20 bool overwrite) | 20 bool overwrite) |
21 : predefined_root_(predefined_root), | 21 : predefined_root_(predefined_root), |
22 key_path_(key_path), | 22 key_path_(key_path), |
23 value_name_(value_name), | 23 value_name_(value_name), |
24 overwrite_(overwrite), | 24 overwrite_(overwrite), |
25 wow64_access_(wow64_access), | 25 wow64_access_(wow64_access), |
26 status_(SET_VALUE), | |
27 type_(REG_SZ), | 26 type_(REG_SZ), |
28 previous_type_(0) { | 27 previous_type_(0), |
| 28 status_(SET_VALUE) { |
29 DCHECK(wow64_access == 0 || | 29 DCHECK(wow64_access == 0 || |
30 wow64_access == KEY_WOW64_32KEY || | 30 wow64_access == KEY_WOW64_32KEY || |
31 wow64_access == KEY_WOW64_64KEY); | 31 wow64_access == KEY_WOW64_64KEY); |
32 const uint8* data = reinterpret_cast<const uint8*>(value_data.c_str()); | 32 const uint8* data = reinterpret_cast<const uint8*>(value_data.c_str()); |
33 value_.assign(data, data + (value_data.length() + 1) * sizeof(wchar_t)); | 33 value_.assign(data, data + (value_data.length() + 1) * sizeof(wchar_t)); |
34 } | 34 } |
35 | 35 |
36 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, | 36 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, |
37 const std::wstring& key_path, | 37 const std::wstring& key_path, |
38 REGSAM wow64_access, | 38 REGSAM wow64_access, |
39 const std::wstring& value_name, | 39 const std::wstring& value_name, |
40 DWORD value_data, | 40 DWORD value_data, |
41 bool overwrite) | 41 bool overwrite) |
42 : predefined_root_(predefined_root), | 42 : predefined_root_(predefined_root), |
43 key_path_(key_path), | 43 key_path_(key_path), |
44 value_name_(value_name), | 44 value_name_(value_name), |
45 overwrite_(overwrite), | 45 overwrite_(overwrite), |
46 wow64_access_(wow64_access), | 46 wow64_access_(wow64_access), |
47 status_(SET_VALUE), | |
48 type_(REG_DWORD), | 47 type_(REG_DWORD), |
49 previous_type_(0) { | 48 previous_type_(0), |
| 49 status_(SET_VALUE) { |
50 DCHECK(wow64_access == 0 || | 50 DCHECK(wow64_access == 0 || |
51 wow64_access == KEY_WOW64_32KEY || | 51 wow64_access == KEY_WOW64_32KEY || |
52 wow64_access == KEY_WOW64_64KEY); | 52 wow64_access == KEY_WOW64_64KEY); |
53 const uint8* data = reinterpret_cast<const uint8*>(&value_data); | 53 const uint8* data = reinterpret_cast<const uint8*>(&value_data); |
54 value_.assign(data, data + sizeof(value_data)); | 54 value_.assign(data, data + sizeof(value_data)); |
55 } | 55 } |
56 | 56 |
57 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, | 57 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, |
58 const std::wstring& key_path, | 58 const std::wstring& key_path, |
59 REGSAM wow64_access, | 59 REGSAM wow64_access, |
60 const std::wstring& value_name, | 60 const std::wstring& value_name, |
61 int64 value_data, | 61 int64 value_data, |
62 bool overwrite) | 62 bool overwrite) |
63 : predefined_root_(predefined_root), | 63 : predefined_root_(predefined_root), |
64 key_path_(key_path), | 64 key_path_(key_path), |
65 value_name_(value_name), | 65 value_name_(value_name), |
66 overwrite_(overwrite), | 66 overwrite_(overwrite), |
67 wow64_access_(wow64_access), | 67 wow64_access_(wow64_access), |
68 status_(SET_VALUE), | |
69 type_(REG_QWORD), | 68 type_(REG_QWORD), |
70 previous_type_(0) { | 69 previous_type_(0), |
| 70 status_(SET_VALUE) { |
71 DCHECK(wow64_access == 0 || | 71 DCHECK(wow64_access == 0 || |
72 wow64_access == KEY_WOW64_32KEY || | 72 wow64_access == KEY_WOW64_32KEY || |
73 wow64_access == KEY_WOW64_64KEY); | 73 wow64_access == KEY_WOW64_64KEY); |
74 const uint8* data = reinterpret_cast<const uint8*>(&value_data); | 74 const uint8* data = reinterpret_cast<const uint8*>(&value_data); |
75 value_.assign(data, data + sizeof(value_data)); | 75 value_.assign(data, data + sizeof(value_data)); |
76 } | 76 } |
77 | 77 |
78 bool SetRegValueWorkItem::Do() { | 78 bool SetRegValueWorkItem::Do() { |
79 LONG result = ERROR_SUCCESS; | 79 LONG result = ERROR_SUCCESS; |
80 base::win::RegKey key; | 80 base::win::RegKey key; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 result = key.WriteValue(value_name_.c_str(), previous_value, | 159 result = key.WriteValue(value_name_.c_str(), previous_value, |
160 static_cast<DWORD>(previous_value_.size()), | 160 static_cast<DWORD>(previous_value_.size()), |
161 previous_type_); | 161 previous_type_); |
162 VLOG(1) << "rollback: restoring " << value_name_ << " error: " << result; | 162 VLOG(1) << "rollback: restoring " << value_name_ << " error: " << result; |
163 } else { | 163 } else { |
164 NOTREACHED(); | 164 NOTREACHED(); |
165 } | 165 } |
166 | 166 |
167 status_ = VALUE_ROLL_BACK; | 167 status_ = VALUE_ROLL_BACK; |
168 } | 168 } |
OLD | NEW |