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

Unified Diff: rlz/win/lib/rlz_value_store_registry.cc

Issue 768973003: Cleanup: Get rid of base::ASCIIToWide(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix build Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « rlz/win/lib/registry_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: rlz/win/lib/rlz_value_store_registry.cc
diff --git a/rlz/win/lib/rlz_value_store_registry.cc b/rlz/win/lib/rlz_value_store_registry.cc
index 2b50767a4a85a551221c5daa08fd5c07ffa1b98e..4a133ebc7d4e2e5e6285d09e75e424a82360a553 100644
--- a/rlz/win/lib/rlz_value_store_registry.cc
+++ b/rlz/win/lib/rlz_value_store_registry.cc
@@ -13,7 +13,7 @@
#include "rlz/lib/string_utils.h"
#include "rlz/win/lib/registry_util.h"
-using base::ASCIIToWide;
+using base::ASCIIToUTF16;
namespace rlz_lib {
@@ -47,7 +47,7 @@ const char kStatefulEventsSubkeyName[] = "StatefulEvents";
const char kPingTimesSubkeyName[] = "PTimes";
std::wstring GetWideProductName(Product product) {
- return ASCIIToWide(GetProductName(product));
+ return ASCIIToUTF16(GetProductName(product));
}
void AppendBrandToString(std::string* str) {
@@ -61,16 +61,13 @@ bool GetRegKey(const char* name, REGSAM access, base::win::RegKey* key) {
std::string key_location;
base::StringAppendF(&key_location, "%s\\%s", kLibKeyName, name);
AppendBrandToString(&key_location);
+ base::string16 key_location16 = ASCIIToUTF16(key_location);
- LONG ret = ERROR_SUCCESS;
- if (access & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_CREATE_LINK)) {
- ret = key->Create(HKEY_CURRENT_USER, ASCIIToWide(key_location).c_str(),
- access);
- } else {
- ret = key->Open(HKEY_CURRENT_USER, ASCIIToWide(key_location).c_str(),
- access);
- }
-
+ LONG ret;
+ if (access & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_CREATE_LINK))
+ ret = key->Create(HKEY_CURRENT_USER, key_location16.c_str(), access);
+ else
+ ret = key->Open(HKEY_CURRENT_USER, key_location16.c_str(), access);
return ret == ERROR_SUCCESS;
}
@@ -94,16 +91,13 @@ bool GetEventsRegKey(const char* event_type,
base::StringAppendF(&key_location, "\\%s", product_name.c_str());
}
+ base::string16 key_location16 = ASCIIToUTF16(key_location);
- LONG ret = ERROR_SUCCESS;
- if (access & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_CREATE_LINK)) {
- ret = key->Create(HKEY_CURRENT_USER, ASCIIToWide(key_location).c_str(),
- access);
- } else {
- ret = key->Open(HKEY_CURRENT_USER, ASCIIToWide(key_location).c_str(),
- access);
- }
-
+ LONG ret;
+ if (access & (KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_CREATE_LINK))
+ ret = key->Create(HKEY_CURRENT_USER, key_location16.c_str(), access);
+ else
+ ret = key->Open(HKEY_CURRENT_USER, key_location16.c_str(), access);
return ret == ERROR_SUCCESS;
}
@@ -160,7 +154,7 @@ bool DeleteKeyIfEmpty(HKEY root_key, const wchar_t* key_name) {
// static
std::wstring RlzValueStoreRegistry::GetWideLibKeyName() {
- return ASCIIToWide(kLibKeyName);
+ return ASCIIToUTF16(kLibKeyName);
}
bool RlzValueStoreRegistry::HasAccess(AccessType type) {
@@ -207,11 +201,11 @@ bool RlzValueStoreRegistry::WriteAccessPointRlz(AccessPoint access_point,
if (!access_point_name)
return false;
- std::wstring access_point_name_wide(ASCIIToWide(access_point_name));
+ base::string16 access_point_name16(ASCIIToUTF16(access_point_name));
base::win::RegKey key;
GetAccessPointRlzsRegKey(KEY_WRITE, &key);
- if (!RegKeyWriteValue(key, access_point_name_wide.c_str(), new_rlz)) {
+ if (!RegKeyWriteValue(&key, access_point_name16.c_str(), new_rlz)) {
ASSERT_STRING("SetAccessPointRlz: Could not write the new RLZ value");
return false;
}
@@ -228,8 +222,8 @@ bool RlzValueStoreRegistry::ReadAccessPointRlz(AccessPoint access_point,
size_t size = rlz_size;
base::win::RegKey key;
GetAccessPointRlzsRegKey(KEY_READ, &key);
- if (!RegKeyReadValue(key, ASCIIToWide(access_point_name).c_str(),
- rlz, &size)) {
+ base::string16 access_point_name16 = ASCIIToUTF16(access_point_name);
+ if (!RegKeyReadValue(key, access_point_name16.c_str(), rlz, &size)) {
rlz[0] = 0;
if (size > rlz_size) {
ASSERT_STRING("GetAccessPointRlz: Insufficient buffer size");
@@ -244,16 +238,15 @@ bool RlzValueStoreRegistry::ClearAccessPointRlz(AccessPoint access_point) {
if (!access_point_name)
return false;
- std::wstring access_point_name_wide(ASCIIToWide(access_point_name));
+ base::string16 access_point_name16(ASCIIToUTF16(access_point_name));
base::win::RegKey key;
GetAccessPointRlzsRegKey(KEY_WRITE, &key);
- key.DeleteValue(access_point_name_wide.c_str());
+ key.DeleteValue(access_point_name16.c_str());
// Verify deletion.
DWORD value;
- if (key.ReadValueDW(access_point_name_wide.c_str(), &value) ==
- ERROR_SUCCESS) {
+ if (key.ReadValueDW(access_point_name16.c_str(), &value) == ERROR_SUCCESS) {
ASSERT_STRING("SetAccessPointRlz: Could not clear the RLZ value.");
return false;
}
@@ -262,10 +255,10 @@ bool RlzValueStoreRegistry::ClearAccessPointRlz(AccessPoint access_point) {
bool RlzValueStoreRegistry::AddProductEvent(Product product,
const char* event_rlz) {
- std::wstring event_rlz_wide(ASCIIToWide(event_rlz));
+ base::string16 event_rlz16(ASCIIToUTF16(event_rlz));
base::win::RegKey reg_key;
GetEventsRegKey(kEventsSubkeyName, &product, KEY_WRITE, &reg_key);
- if (reg_key.WriteValue(event_rlz_wide.c_str(), 1) != ERROR_SUCCESS) {
+ if (reg_key.WriteValue(event_rlz16.c_str(), 1) != ERROR_SUCCESS) {
ASSERT_STRING("AddProductEvent: Could not write the new event value");
return false;
}
@@ -301,14 +294,14 @@ bool RlzValueStoreRegistry::ReadProductEvents(Product product,
bool RlzValueStoreRegistry::ClearProductEvent(Product product,
const char* event_rlz) {
- std::wstring event_rlz_wide(ASCIIToWide(event_rlz));
+ base::string16 event_rlz16(ASCIIToUTF16(event_rlz));
base::win::RegKey key;
GetEventsRegKey(kEventsSubkeyName, &product, KEY_WRITE, &key);
- key.DeleteValue(event_rlz_wide.c_str());
+ key.DeleteValue(event_rlz16.c_str());
// Verify deletion.
DWORD value;
- if (key.ReadValueDW(event_rlz_wide.c_str(), &value) == ERROR_SUCCESS) {
+ if (key.ReadValueDW(event_rlz16.c_str(), &value) == ERROR_SUCCESS) {
ASSERT_STRING("ClearProductEvent: Could not delete the event value.");
return false;
}
@@ -323,9 +316,9 @@ bool RlzValueStoreRegistry::ClearAllProductEvents(Product product) {
bool RlzValueStoreRegistry::AddStatefulEvent(Product product,
const char* event_rlz) {
base::win::RegKey key;
- std::wstring event_rlz_wide(ASCIIToWide(event_rlz));
+ base::string16 event_rlz16(ASCIIToUTF16(event_rlz));
if (!GetEventsRegKey(kStatefulEventsSubkeyName, &product, KEY_WRITE, &key) ||
- key.WriteValue(event_rlz_wide.c_str(), 1) != ERROR_SUCCESS) {
+ key.WriteValue(event_rlz16.c_str(), 1) != ERROR_SUCCESS) {
ASSERT_STRING(
"AddStatefulEvent: Could not write the new stateful event");
return false;
@@ -339,8 +332,8 @@ bool RlzValueStoreRegistry::IsStatefulEvent(Product product,
DWORD value;
base::win::RegKey key;
GetEventsRegKey(kStatefulEventsSubkeyName, &product, KEY_READ, &key);
- std::wstring event_rlz_wide(ASCIIToWide(event_rlz));
- return key.ReadValueDW(event_rlz_wide.c_str(), &value) == ERROR_SUCCESS;
+ base::string16 event_rlz16(ASCIIToUTF16(event_rlz));
+ return key.ReadValueDW(event_rlz16.c_str(), &value) == ERROR_SUCCESS;
}
bool RlzValueStoreRegistry::ClearAllStatefulEvents(Product product) {
@@ -349,7 +342,7 @@ bool RlzValueStoreRegistry::ClearAllStatefulEvents(Product product) {
void RlzValueStoreRegistry::CollectGarbage() {
// Delete each of the known subkeys if empty.
- const char* subkeys[] = {
+ const char* const subkeys[] = {
kRlzsSubkeyName,
kEventsSubkeyName,
kStatefulEventsSubkeyName,
@@ -360,9 +353,9 @@ void RlzValueStoreRegistry::CollectGarbage() {
std::string subkey_name;
base::StringAppendF(&subkey_name, "%s\\%s", kLibKeyName, subkeys[i]);
AppendBrandToString(&subkey_name);
+ base::string16 subkey_name16 = ASCIIToUTF16(subkey_name);
- VERIFY(DeleteKeyIfEmpty(HKEY_CURRENT_USER,
- ASCIIToWide(subkey_name).c_str()));
+ VERIFY(DeleteKeyIfEmpty(HKEY_CURRENT_USER, subkey_name16.c_str()));
}
// Delete the library key and its parents too now if empty.
« no previous file with comments | « rlz/win/lib/registry_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698