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

Side by Side Diff: chrome/installer/mini_installer/regkey.cc

Issue 2670133002: Various cleanups. (Closed)
Patch Set: huangs comments Created 3 years, 10 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/mini_installer/mini_installer_constants.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/mini_installer/regkey.h" 5 #include "chrome/installer/mini_installer/regkey.h"
6 6
7 #include "chrome/installer/mini_installer/mini_installer_constants.h" 7 #include "chrome/installer/mini_installer/mini_installer_constants.h"
8 #include "chrome/installer/mini_installer/mini_string.h" 8 #include "chrome/installer/mini_installer/mini_string.h"
9 9
10 namespace mini_installer { 10 namespace mini_installer {
11 11
12 LONG RegKey::Open(HKEY key, const wchar_t* sub_key, REGSAM access) { 12 LONG RegKey::Open(HKEY key, const wchar_t* sub_key, REGSAM access) {
13 Close(); 13 Close();
14 return ::RegOpenKeyEx(key, sub_key, NULL, access, &key_); 14 return ::RegOpenKeyEx(key, sub_key, NULL, access, &key_);
15 } 15 }
16 16
17 LONG RegKey::ReadSZValue(const wchar_t* value_name, 17 LONG RegKey::ReadSZValue(const wchar_t* value_name,
18 wchar_t* value, 18 wchar_t* value,
19 size_t value_size) const { 19 size_t value_size) const {
20 DWORD type = 0; 20 DWORD type = 0;
21 DWORD byte_length = static_cast<DWORD>(value_size * sizeof(wchar_t)); 21 DWORD byte_length = static_cast<DWORD>(value_size * sizeof(wchar_t));
22 LONG result = ::RegQueryValueEx(key_, value_name, NULL, &type, 22 LONG result = ::RegQueryValueEx(key_, value_name, NULL, &type,
23 reinterpret_cast<BYTE*>(value), 23 reinterpret_cast<BYTE*>(value),
24 &byte_length); 24 &byte_length);
25 if (result == ERROR_SUCCESS) { 25 if (result == ERROR_SUCCESS) {
26 if (type != REG_SZ) { 26 if (type != REG_SZ) {
27 result = ERROR_NOT_SUPPORTED; 27 result = ERROR_NOT_SUPPORTED;
28 } else if (byte_length == 0) { 28 } else if (byte_length < 2) {
29 *value = L'\0'; 29 *value = L'\0';
30 } else if (value[byte_length/sizeof(wchar_t) - 1] != L'\0') { 30 } else if (value[byte_length/sizeof(wchar_t) - 1] != L'\0') {
31 if ((byte_length / sizeof(wchar_t)) < value_size) 31 if ((byte_length / sizeof(wchar_t)) < value_size)
32 value[byte_length / sizeof(wchar_t)] = L'\0'; 32 value[byte_length / sizeof(wchar_t)] = L'\0';
33 else 33 else
34 result = ERROR_MORE_DATA; 34 result = ERROR_MORE_DATA;
35 } 35 }
36 } 36 }
37 return result; 37 return result;
38 } 38 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 if (!client_state_key.assign(kClientStateKeyBase)) 105 if (!client_state_key.assign(kClientStateKeyBase))
106 return ERROR_BUFFER_OVERFLOW; 106 return ERROR_BUFFER_OVERFLOW;
107 #if defined(GOOGLE_CHROME_BUILD) 107 #if defined(GOOGLE_CHROME_BUILD)
108 if (!client_state_key.append(app_guid)) 108 if (!client_state_key.append(app_guid))
109 return ERROR_BUFFER_OVERFLOW; 109 return ERROR_BUFFER_OVERFLOW;
110 #endif 110 #endif
111 return key->Open(root_key, client_state_key.get(), access | KEY_WOW64_32KEY); 111 return key->Open(root_key, client_state_key.get(), access | KEY_WOW64_32KEY);
112 } 112 }
113 113
114 } // namespace mini_installer 114 } // namespace mini_installer
OLDNEW
« no previous file with comments | « chrome/installer/mini_installer/mini_installer_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698