Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: chrome/installer/util/set_reg_value_work_item.cc

Issue 1548153002: Switch to standard integer types in chrome/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/installer/util/set_reg_value_work_item.h ('k') | chrome/installer/util/shell_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 namespace { 12 namespace {
13 13
14 // Transforms |str_value| into the byte-by-byte representation of its underlying 14 // Transforms |str_value| into the byte-by-byte representation of its underlying
15 // string, stores the result in |binary_data|. 15 // string, stores the result in |binary_data|.
16 void StringToBinaryData(const std::wstring& str_value, 16 void StringToBinaryData(const std::wstring& str_value,
17 std::vector<uint8>* binary_data) { 17 std::vector<uint8_t>* binary_data) {
18 DCHECK(binary_data); 18 DCHECK(binary_data);
19 const uint8* data = reinterpret_cast<const uint8*>(str_value.c_str()); 19 const uint8_t* data = reinterpret_cast<const uint8_t*>(str_value.c_str());
20 binary_data->assign(data, data + (str_value.length() + 1) * sizeof(wchar_t)); 20 binary_data->assign(data, data + (str_value.length() + 1) * sizeof(wchar_t));
21 } 21 }
22 22
23 // Transforms |binary_data| into its wstring representation (assuming 23 // Transforms |binary_data| into its wstring representation (assuming
24 // |binary_data| is a sequence of wchar_t's). 24 // |binary_data| is a sequence of wchar_t's).
25 void BinaryDataToString(const std::vector<uint8>& binary_data, 25 void BinaryDataToString(const std::vector<uint8_t>& binary_data,
26 std::wstring* str_value) { 26 std::wstring* str_value) {
27 DCHECK(str_value); 27 DCHECK(str_value);
28 if (binary_data.size() < sizeof(wchar_t)) { 28 if (binary_data.size() < sizeof(wchar_t)) {
29 str_value->clear(); 29 str_value->clear();
30 return; 30 return;
31 } 31 }
32 32
33 str_value->assign(reinterpret_cast<const wchar_t*>(&binary_data[0]), 33 str_value->assign(reinterpret_cast<const wchar_t*>(&binary_data[0]),
34 binary_data.size() / sizeof(wchar_t)); 34 binary_data.size() / sizeof(wchar_t));
35 35
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 key_path_(key_path), 76 key_path_(key_path),
77 value_name_(value_name), 77 value_name_(value_name),
78 overwrite_(overwrite), 78 overwrite_(overwrite),
79 wow64_access_(wow64_access), 79 wow64_access_(wow64_access),
80 type_(REG_DWORD), 80 type_(REG_DWORD),
81 previous_type_(0), 81 previous_type_(0),
82 status_(SET_VALUE) { 82 status_(SET_VALUE) {
83 DCHECK(wow64_access == 0 || 83 DCHECK(wow64_access == 0 ||
84 wow64_access == KEY_WOW64_32KEY || 84 wow64_access == KEY_WOW64_32KEY ||
85 wow64_access == KEY_WOW64_64KEY); 85 wow64_access == KEY_WOW64_64KEY);
86 const uint8* data = reinterpret_cast<const uint8*>(&value_data); 86 const uint8_t* data = reinterpret_cast<const uint8_t*>(&value_data);
87 value_.assign(data, data + sizeof(value_data)); 87 value_.assign(data, data + sizeof(value_data));
88 } 88 }
89 89
90 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root, 90 SetRegValueWorkItem::SetRegValueWorkItem(HKEY predefined_root,
91 const std::wstring& key_path, 91 const std::wstring& key_path,
92 REGSAM wow64_access, 92 REGSAM wow64_access,
93 const std::wstring& value_name, 93 const std::wstring& value_name,
94 int64 value_data, 94 int64_t value_data,
95 bool overwrite) 95 bool overwrite)
96 : predefined_root_(predefined_root), 96 : predefined_root_(predefined_root),
97 key_path_(key_path), 97 key_path_(key_path),
98 value_name_(value_name), 98 value_name_(value_name),
99 overwrite_(overwrite), 99 overwrite_(overwrite),
100 wow64_access_(wow64_access), 100 wow64_access_(wow64_access),
101 type_(REG_QWORD), 101 type_(REG_QWORD),
102 previous_type_(0), 102 previous_type_(0),
103 status_(SET_VALUE) { 103 status_(SET_VALUE) {
104 DCHECK(wow64_access == 0 || 104 DCHECK(wow64_access == 0 ||
105 wow64_access == KEY_WOW64_32KEY || 105 wow64_access == KEY_WOW64_32KEY ||
106 wow64_access == KEY_WOW64_64KEY); 106 wow64_access == KEY_WOW64_64KEY);
107 const uint8* data = reinterpret_cast<const uint8*>(&value_data); 107 const uint8_t* data = reinterpret_cast<const uint8_t*>(&value_data);
108 value_.assign(data, data + sizeof(value_data)); 108 value_.assign(data, data + sizeof(value_data));
109 } 109 }
110 110
111 SetRegValueWorkItem::SetRegValueWorkItem( 111 SetRegValueWorkItem::SetRegValueWorkItem(
112 HKEY predefined_root, 112 HKEY predefined_root,
113 const std::wstring& key_path, 113 const std::wstring& key_path,
114 REGSAM wow64_access, 114 REGSAM wow64_access,
115 const std::wstring& value_name, 115 const std::wstring& value_name,
116 const GetValueFromExistingCallback& get_value_callback) 116 const GetValueFromExistingCallback& get_value_callback)
117 : predefined_root_(predefined_root), 117 : predefined_root_(predefined_root),
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 result = key.WriteValue(value_name_.c_str(), previous_value, 228 result = key.WriteValue(value_name_.c_str(), previous_value,
229 static_cast<DWORD>(previous_value_.size()), 229 static_cast<DWORD>(previous_value_.size()),
230 previous_type_); 230 previous_type_);
231 VLOG(1) << "rollback: restoring " << value_name_ << " error: " << result; 231 VLOG(1) << "rollback: restoring " << value_name_ << " error: " << result;
232 } else { 232 } else {
233 NOTREACHED(); 233 NOTREACHED();
234 } 234 }
235 235
236 status_ = VALUE_ROLL_BACK; 236 status_ = VALUE_ROLL_BACK;
237 } 237 }
OLDNEW
« no previous file with comments | « chrome/installer/util/set_reg_value_work_item.h ('k') | chrome/installer/util/shell_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698