From c15100ce1266e52a77f2974ffe9dfb833f5e58b3 Mon Sep 17 00:00:00 2001 From: brettw Date: Thu, 6 Aug 2015 15:54:16 -0700 Subject: [PATCH] Replace StringToLowerASCII with base::ToLowerASCII Standardize on using string pieces and returning strings. Remove in-place version (this was only used in a couple places and they were not performance-critical). De-templatize the character versions of ToUpperASCII/ToLowerASCII. This would lead to bizarre errors if you pass other things (like a string). This is so little code, it's now just duplicated. I renamed StringToLowerASCII to just be ToLowerASCII so you can pass whatever you want to ToLowerASCII and it does the right thing. This seems simpler to me. This replaces all calls of StringToUpperASCII to the new form. The lowercase version is more common and will be done in a separate pass. Review URL: https://codereview.chromium.org/1280473002 Cr-Commit-Position: refs/heads/master@{#342219} --- base/environment.cc | 4 +- base/files/file_util_unittest.cc | 4 +- base/guid_unittest.cc | 4 +- base/strings/string_util.cc | 38 +++++++++++++++++++ base/strings/string_util.h | 34 +++++++++-------- base/strings/string_util_unittest.cc | 36 +++++++++--------- .../input_method/input_method_util.cc | 2 +- chrome/browser/prerender/prerender_manager.cc | 2 +- .../push_messaging_app_identifier.cc | 3 +- .../supervised_user_url_filter.cc | 2 +- chrome/installer/util/l10n_string_util.cc | 4 +- components/autofill/core/browser/address.cc | 2 +- .../autofill/core/browser/autofill_country.cc | 6 +-- .../core/browser/personal_data_manager.cc | 2 +- components/dom_distiller/core/viewer.cc | 2 +- .../cloud/cloud_policy_validator_unittest.cc | 2 +- components/test_runner/event_sender.cc | 3 +- .../language_detection_util.cc | 6 +-- .../input/web_input_event_util.cc | 9 +++-- .../web_application_cache_host_impl.cc | 2 +- .../renderer/android/phone_number_detector.cc | 2 +- .../renderer/runtime_custom_bindings.cc | 4 +- media/base/mime_util.cc | 5 +-- net/http/http_auth_handler_ntlm_portable.cc | 2 +- net/http/http_util_unittest.cc | 6 +-- storage/common/fileapi/file_system_util.cc | 4 +- .../ime/chromeos/input_method_descriptor.cc | 5 +-- 27 files changed, 115 insertions(+), 80 deletions(-) diff --git a/base/environment.cc b/base/environment.cc index 245051d0c18406..11b2bc39a9e060 100644 --- a/base/environment.cc +++ b/base/environment.cc @@ -33,9 +33,9 @@ class EnvironmentImpl : public Environment { char first_char = variable_name[0]; std::string alternate_case_var; if (first_char >= 'a' && first_char <= 'z') - alternate_case_var = StringToUpperASCII(std::string(variable_name)); + alternate_case_var = ToUpperASCII(variable_name); else if (first_char >= 'A' && first_char <= 'Z') - alternate_case_var = StringToLowerASCII(std::string(variable_name)); + alternate_case_var = ToLowerASCII(variable_name); else return false; return GetVarImpl(alternate_case_var.c_str(), result); diff --git a/base/files/file_util_unittest.cc b/base/files/file_util_unittest.cc index 476ed16c0df8bf..4b95dbb4bdf745 100644 --- a/base/files/file_util_unittest.cc +++ b/base/files/file_util_unittest.cc @@ -426,8 +426,8 @@ TEST_F(FileUtilTest, NormalizeFilePathReparsePoints) { TEST_F(FileUtilTest, DevicePathToDriveLetter) { // Get a drive letter. - std::wstring real_drive_letter = temp_dir_.path().value().substr(0, 2); - StringToUpperASCII(&real_drive_letter); + string16 real_drive_letter = + ToUpperASCII(temp_dir_.path().value().substr(0, 2)); if (!isalpha(real_drive_letter[0]) || ':' != real_drive_letter[1]) { LOG(ERROR) << "Can't get a drive letter to test with."; return; diff --git a/base/guid_unittest.cc b/base/guid_unittest.cc index 1485497155fab2..1c5d393c4d8277 100644 --- a/base/guid_unittest.cc +++ b/base/guid_unittest.cc @@ -43,8 +43,8 @@ TEST(GUIDTest, GUIDCorrectlyFormatted) { for (int it = 0; it < kIterations; ++it) { std::string guid = GenerateGUID(); EXPECT_TRUE(IsValidGUID(guid)); - EXPECT_TRUE(IsValidGUID(StringToLowerASCII(guid))); - EXPECT_TRUE(IsValidGUID(StringToUpperASCII(guid))); + EXPECT_TRUE(IsValidGUID(ToLowerASCII(guid))); + EXPECT_TRUE(IsValidGUID(ToUpperASCII(guid))); } } diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc index 725d86da8ac7c6..19c38d593dcc26 100644 --- a/base/strings/string_util.cc +++ b/base/strings/string_util.cc @@ -148,6 +148,44 @@ bool IsWprintfFormatPortable(const wchar_t* format) { return true; } +namespace { + +template +StringType ToLowerASCIIImpl(BasicStringPiece str) { + StringType ret; + ret.reserve(str.size()); + for (size_t i = 0; i < str.size(); i++) + ret.push_back(ToLowerASCII(str[i])); + return ret; +} + +template +StringType ToUpperASCIIImpl(BasicStringPiece str) { + StringType ret; + ret.reserve(str.size()); + for (size_t i = 0; i < str.size(); i++) + ret.push_back(ToUpperASCII(str[i])); + return ret; +} + +} // namespace + +std::string ToLowerASCII(StringPiece str) { + return ToLowerASCIIImpl(str); +} + +string16 ToLowerASCII(StringPiece16 str) { + return ToLowerASCIIImpl(str); +} + +std::string ToUpperASCII(StringPiece str) { + return ToUpperASCIIImpl(str); +} + +string16 ToUpperASCII(StringPiece16 str) { + return ToUpperASCIIImpl(str); +} + template int CompareCaseInsensitiveASCIIT(BasicStringPiece a, BasicStringPiece b) { diff --git a/base/strings/string_util.h b/base/strings/string_util.h index 01dc3fcdddf158..3ec74a5207f49e 100644 --- a/base/strings/string_util.h +++ b/base/strings/string_util.h @@ -93,16 +93,30 @@ BASE_EXPORT bool IsWprintfFormatPortable(const wchar_t* format); // ASCII-specific tolower. The standard library's tolower is locale sensitive, // so we don't want to use it here. -template inline Char ToLowerASCII(Char c) { +inline char ToLowerASCII(char c) { + return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; +} +inline char16 ToLowerASCII(char16 c) { return (c >= 'A' && c <= 'Z') ? (c + ('a' - 'A')) : c; } // ASCII-specific toupper. The standard library's toupper is locale sensitive, // so we don't want to use it here. -template inline Char ToUpperASCII(Char c) { +inline char ToUpperASCII(char c) { + return (c >= 'a' && c <= 'z') ? (c + ('A' - 'a')) : c; +} +inline char16 ToUpperASCII(char16 c) { return (c >= 'a' && c <= 'z') ? (c + ('A' - 'a')) : c; } +// Converts the given string to it's ASCII-lowercase equivalent. +BASE_EXPORT std::string ToLowerASCII(StringPiece str); +BASE_EXPORT string16 ToLowerASCII(StringPiece16 str); + +// Converts the given string to it's ASCII-uppercase equivalent. +BASE_EXPORT std::string ToUpperASCII(StringPiece str); +BASE_EXPORT string16 ToUpperASCII(StringPiece16 str); + // Functor for case-insensitive ASCII comparisons for STL algorithms like // std::search. // @@ -291,11 +305,13 @@ BASE_EXPORT bool IsStringASCII(const std::wstring& str); // Converts the elements of the given string. This version uses a pointer to // clearly differentiate it from the non-pointer variant. +// TODO(brettw) remove this. Callers should use base::ToLowerASCII above. template inline void StringToLowerASCII(str* s) { for (typename str::iterator i = s->begin(); i != s->end(); ++i) *i = ToLowerASCII(*i); } +// TODO(brettw) remove this. Callers should use base::ToLowerASCII above. template inline str StringToLowerASCII(const str& s) { // for std::string and std::wstring str output(s); @@ -303,20 +319,6 @@ template inline str StringToLowerASCII(const str& s) { return output; } -// Converts the elements of the given string. This version uses a pointer to -// clearly differentiate it from the non-pointer variant. -template inline void StringToUpperASCII(str* s) { - for (typename str::iterator i = s->begin(); i != s->end(); ++i) - *i = ToUpperASCII(*i); -} - -template inline str StringToUpperASCII(const str& s) { - // for std::string and std::wstring - str output(s); - StringToUpperASCII(&output); - return output; -} - // Compare the lower-case form of the given string against the given // previously-lower-cased ASCII string (typically a constant). BASE_EXPORT bool LowerCaseEqualsASCII(StringPiece str, diff --git a/base/strings/string_util_unittest.cc b/base/strings/string_util_unittest.cc index eb6cd7ecfc14d8..187e49e6698160 100644 --- a/base/strings/string_util_unittest.cc +++ b/base/strings/string_util_unittest.cc @@ -503,30 +503,30 @@ TEST(StringUtilTest, ConvertASCII) { EXPECT_EQ(0, string_with_nul.compare(narrow_with_nul)); } +TEST(StringUtilTest, ToLowerASCII) { + EXPECT_EQ('c', ToLowerASCII('C')); + EXPECT_EQ('c', ToLowerASCII('c')); + EXPECT_EQ('2', ToLowerASCII('2')); + + EXPECT_EQ(static_cast('c'), ToLowerASCII(static_cast('C'))); + EXPECT_EQ(static_cast('c'), ToLowerASCII(static_cast('c'))); + EXPECT_EQ(static_cast('2'), ToLowerASCII(static_cast('2'))); + + EXPECT_EQ("cc2", ToLowerASCII("Cc2")); + EXPECT_EQ(ASCIIToUTF16("cc2"), ToLowerASCII(ASCIIToUTF16("Cc2"))); +} + TEST(StringUtilTest, ToUpperASCII) { EXPECT_EQ('C', ToUpperASCII('C')); EXPECT_EQ('C', ToUpperASCII('c')); EXPECT_EQ('2', ToUpperASCII('2')); - EXPECT_EQ(L'C', ToUpperASCII(L'C')); - EXPECT_EQ(L'C', ToUpperASCII(L'c')); - EXPECT_EQ(L'2', ToUpperASCII(L'2')); - - std::string in_place_a("Cc2"); - StringToUpperASCII(&in_place_a); - EXPECT_EQ("CC2", in_place_a); - - std::wstring in_place_w(L"Cc2"); - StringToUpperASCII(&in_place_w); - EXPECT_EQ(L"CC2", in_place_w); - - std::string original_a("Cc2"); - std::string upper_a = StringToUpperASCII(original_a); - EXPECT_EQ("CC2", upper_a); + EXPECT_EQ(static_cast('C'), ToUpperASCII(static_cast('C'))); + EXPECT_EQ(static_cast('C'), ToUpperASCII(static_cast('c'))); + EXPECT_EQ(static_cast('2'), ToUpperASCII(static_cast('2'))); - std::wstring original_w(L"Cc2"); - std::wstring upper_w = StringToUpperASCII(original_w); - EXPECT_EQ(L"CC2", upper_w); + EXPECT_EQ("CC2", ToUpperASCII("Cc2")); + EXPECT_EQ(ASCIIToUTF16("CC2"), ToUpperASCII(ASCIIToUTF16("Cc2"))); } TEST(StringUtilTest, LowerCaseEqualsASCII) { diff --git a/chrome/browser/chromeos/input_method/input_method_util.cc b/chrome/browser/chromeos/input_method/input_method_util.cc index d56569e42fd8e0..23baa44a61f6ba 100644 --- a/chrome/browser/chromeos/input_method/input_method_util.cc +++ b/chrome/browser/chromeos/input_method/input_method_util.cc @@ -380,7 +380,7 @@ std::string InputMethodUtil::GetLocalizedDisplayName( if (disp.find("__MSG_") == 0) { const InputMethodNameMap* map = kInputMethodNameMap; size_t map_size = arraysize(kInputMethodNameMap); - std::string name = base::StringToUpperASCII(disp); + std::string name = base::ToUpperASCII(disp); const InputMethodNameMap map_key = {name.c_str(), 0}; const InputMethodNameMap* p = std::lower_bound(map, map + map_size, map_key); diff --git a/chrome/browser/prerender/prerender_manager.cc b/chrome/browser/prerender/prerender_manager.cc index 5834940eab8b55..e5b76b79238961 100644 --- a/chrome/browser/prerender/prerender_manager.cc +++ b/chrome/browser/prerender/prerender_manager.cc @@ -745,7 +745,7 @@ bool PrerenderManager::HasRecentlyBeenNavigatedTo(Origin origin, bool PrerenderManager::IsValidHttpMethod(const std::string& method) { // method has been canonicalized to upper case at this point so we can just // compare them. - DCHECK_EQ(method, base::StringToUpperASCII(method)); + DCHECK_EQ(method, base::ToUpperASCII(method)); for (size_t i = 0; i < arraysize(kValidHttpMethods); ++i) { if (method.compare(kValidHttpMethods[i]) == 0) return true; diff --git a/chrome/browser/push_messaging/push_messaging_app_identifier.cc b/chrome/browser/push_messaging/push_messaging_app_identifier.cc index cfb8c5f1732b1d..d21c50fbbbfe3c 100644 --- a/chrome/browser/push_messaging/push_messaging_app_identifier.cc +++ b/chrome/browser/push_messaging/push_messaging_app_identifier.cc @@ -86,8 +86,7 @@ PushMessagingAppIdentifier PushMessagingAppIdentifier::FindByAppId( DCHECK_EQ(kPushMessagingAppIdentifierPrefix, app_id.substr(0, kPrefixLength)); DCHECK_GE(app_id.size(), kPrefixLength + kGuidLength); DCHECK_EQ(app_id.substr(app_id.size() - kGuidLength), - base::StringToUpperASCII( - app_id.substr(app_id.size() - kGuidLength))); + base::ToUpperASCII(app_id.substr(app_id.size() - kGuidLength))); const base::DictionaryValue* map = profile->GetPrefs()->GetDictionary(prefs::kPushMessagingAppIdentifierMap); diff --git a/chrome/browser/supervised_user/supervised_user_url_filter.cc b/chrome/browser/supervised_user/supervised_user_url_filter.cc index 667fc25069c198..1711b163f1a89a 100644 --- a/chrome/browser/supervised_user/supervised_user_url_filter.cc +++ b/chrome/browser/supervised_user/supervised_user_url_filter.cc @@ -113,7 +113,7 @@ bool FilterBuilder::AddPattern(const std::string& pattern, int site_id) { } void FilterBuilder::AddHostnameHash(const std::string& hash, int site_id) { - contents_->hash_site_map.insert(std::make_pair(base::StringToUpperASCII(hash), + contents_->hash_site_map.insert(std::make_pair(base::ToUpperASCII(hash), site_id)); } diff --git a/chrome/installer/util/l10n_string_util.cc b/chrome/installer/util/l10n_string_util.cc index 71963ce0b2683b..96f2ce70d2c621 100644 --- a/chrome/installer/util/l10n_string_util.cc +++ b/chrome/installer/util/l10n_string_util.cc @@ -72,9 +72,9 @@ std::wstring GetLocalizedEulaResource() { return L""; // The resource names are more or less the upcased language names. - std::wstring language(GetLanguageSelector().selected_translation()); + base::string16 language(GetLanguageSelector().selected_translation()); std::replace(language.begin(), language.end(), L'-', L'_'); - base::StringToUpperASCII(&language); + language = base::ToUpperASCII(language); std::wstring resource(L"IDR_OEMPG_"); resource.append(language).append(L".HTML"); diff --git a/components/autofill/core/browser/address.cc b/components/autofill/core/browser/address.cc index 2cf5f51d2f5a3e..e0c2a9cf560cb0 100644 --- a/components/autofill/core/browser/address.cc +++ b/components/autofill/core/browser/address.cc @@ -161,7 +161,7 @@ bool Address::SetInfo(const AutofillType& type, return false; } - country_code_ = base::StringToUpperASCII(base::UTF16ToASCII(value)); + country_code_ = base::ToUpperASCII(base::UTF16ToASCII(value)); return true; } else if (type.html_type() == HTML_TYPE_FULL_ADDRESS) { // Parsing a full address is too hard. diff --git a/components/autofill/core/browser/autofill_country.cc b/components/autofill/core/browser/autofill_country.cc index 5ed82bd58b20a3..32b2139683945d 100644 --- a/components/autofill/core/browser/autofill_country.cc +++ b/components/autofill/core/browser/autofill_country.cc @@ -937,10 +937,8 @@ CountryNames::~CountryNames() { const std::string CountryNames::GetCountryCode(const base::string16& country, const std::string& locale) { // First, check common country names, including 2- and 3-letter country codes. - std::string country_utf8 = base::UTF16ToUTF8( - base::StringToUpperASCII(country)); - std::map::const_iterator result = - common_names_.find(country_utf8); + std::string country_utf8 = base::UTF16ToUTF8(base::ToUpperASCII(country)); + const auto result = common_names_.find(country_utf8); if (result != common_names_.end()) return result->second; diff --git a/components/autofill/core/browser/personal_data_manager.cc b/components/autofill/core/browser/personal_data_manager.cc index da9a59f3de3092..2e643a89ed12fb 100644 --- a/components/autofill/core/browser/personal_data_manager.cc +++ b/components/autofill/core/browser/personal_data_manager.cc @@ -1313,7 +1313,7 @@ std::string PersonalDataManager::MostCommonCountryCodeFromProfiles() const { std::vector country_codes; AutofillCountry::GetAvailableCountries(&country_codes); for (size_t i = 0; i < profiles.size(); ++i) { - std::string country_code = base::StringToUpperASCII(base::UTF16ToASCII( + std::string country_code = base::ToUpperASCII(base::UTF16ToASCII( profiles[i]->GetRawInfo(ADDRESS_HOME_COUNTRY))); if (std::find(country_codes.begin(), country_codes.end(), country_code) != diff --git a/components/dom_distiller/core/viewer.cc b/components/dom_distiller/core/viewer.cc index 0a0dd546652d8a..7177cf6a726cce 100644 --- a/components/dom_distiller/core/viewer.cc +++ b/components/dom_distiller/core/viewer.cc @@ -260,7 +260,7 @@ scoped_ptr CreateViewRequest( std::string entry_id = url_utils::GetValueForKeyInUrlPathQuery(path, kEntryIdKey); bool has_valid_entry_id = !entry_id.empty(); - entry_id = base::StringToUpperASCII(entry_id); + entry_id = base::ToUpperASCII(entry_id); std::string requested_url_str = url_utils::GetValueForKeyInUrlPathQuery(path, kUrlKey); diff --git a/components/policy/core/common/cloud/cloud_policy_validator_unittest.cc b/components/policy/core/common/cloud/cloud_policy_validator_unittest.cc index 28a3d21f277173..77078cfd89be44 100644 --- a/components/policy/core/common/cloud/cloud_policy_validator_unittest.cc +++ b/components/policy/core/common/cloud/cloud_policy_validator_unittest.cc @@ -162,7 +162,7 @@ TEST_F(CloudPolicyValidatorTest, SuccessfulRunValidationWithNoDMTokens) { TEST_F(CloudPolicyValidatorTest, UsernameCanonicalization) { policy_.policy_data().set_username( - base::StringToUpperASCII(std::string(PolicyBuilder::kFakeUsername))); + base::ToUpperASCII(PolicyBuilder::kFakeUsername)); Validate(CheckStatus(CloudPolicyValidatorBase::VALIDATION_OK)); } diff --git a/components/test_runner/event_sender.cc b/components/test_runner/event_sender.cc index 521d780d6fcf28..1e72126164ff39 100644 --- a/components/test_runner/event_sender.cc +++ b/components/test_runner/event_sender.cc @@ -1365,7 +1365,8 @@ void EventSender::KeyDown(const std::string& code_str, code -= 'a' - 'A'; if ((code >= 'A' && code <= 'Z') || (code >= 'a' && code <= 'z')) { domString.assign("Key"); - domString.push_back(base::ToUpperASCII(code)); + domString.push_back( + base::ToUpperASCII(static_cast(code))); } else if (code >= '0' && code <= '9') { domString.assign("Digit"); domString.push_back(code); diff --git a/components/translate/core/language_detection/language_detection_util.cc b/components/translate/core/language_detection/language_detection_util.cc index 4ab86fc305b216..82b5e0d4fa89e2 100644 --- a/components/translate/core/language_detection/language_detection_util.cc +++ b/components/translate/core/language_detection/language_detection_util.cc @@ -270,10 +270,10 @@ void CorrectLanguageCodeTypo(std::string* code) { // Change everything up to a dash to lower-case and everything after to upper. size_t dash_index = code->find('-'); if (dash_index != std::string::npos) { - *code = base::StringToLowerASCII(code->substr(0, dash_index)) + - base::StringToUpperASCII(code->substr(dash_index)); + *code = base::ToLowerASCII(code->substr(0, dash_index)) + + base::ToUpperASCII(code->substr(dash_index)); } else { - *code = base::StringToLowerASCII(*code); + *code = base::ToLowerASCII(*code); } } diff --git a/content/browser/renderer_host/input/web_input_event_util.cc b/content/browser/renderer_host/input/web_input_event_util.cc index ab4880739f248f..973856df317f56 100644 --- a/content/browser/renderer_host/input/web_input_event_util.cc +++ b/content/browser/renderer_host/input/web_input_event_util.cc @@ -153,10 +153,11 @@ void UpdateWindowsKeyCodeAndKeyIdentifier(blink::WebKeyboardEvent* event, if (id) { base::strlcpy(event->keyIdentifier, id, sizeof(event->keyIdentifier) - 1); } else { - base::snprintf(event->keyIdentifier, - sizeof(event->keyIdentifier), - "U+%04X", - base::ToUpperASCII(static_cast(windows_key_code))); + base::snprintf( + event->keyIdentifier, + sizeof(event->keyIdentifier), + "U+%04X", + base::ToUpperASCII(static_cast(windows_key_code))); } } diff --git a/content/child/appcache/web_application_cache_host_impl.cc b/content/child/appcache/web_application_cache_host_impl.cc index c7328b39960ef1..7be7ee45b07c89 100644 --- a/content/child/appcache/web_application_cache_host_impl.cc +++ b/content/child/appcache/web_application_cache_host_impl.cc @@ -167,7 +167,7 @@ void WebApplicationCacheHostImpl::willStartMainResourceRequest( std::string method = request.httpMethod().utf8(); is_get_method_ = (method == kHttpGETMethod); - DCHECK(method == base::StringToUpperASCII(method)); + DCHECK(method == base::ToUpperASCII(method)); const WebApplicationCacheHostImpl* spawning_host_impl = static_cast(spawning_host); diff --git a/content/renderer/android/phone_number_detector.cc b/content/renderer/android/phone_number_detector.cc index 6a370a11f6a86e..54da5fee51a442 100644 --- a/content/renderer/android/phone_number_detector.cc +++ b/content/renderer/android/phone_number_detector.cc @@ -36,7 +36,7 @@ PhoneNumberDetector::PhoneNumberDetector() // Region should be empty or an ISO 3166-1 alpha-2 country code. PhoneNumberDetector::PhoneNumberDetector(const std::string& region) : region_code_(region.empty() ? RegionCode::GetUnknown() - : base::StringToUpperASCII(region)) { + : base::ToUpperASCII(region)) { } PhoneNumberDetector::~PhoneNumberDetector() { diff --git a/extensions/renderer/runtime_custom_bindings.cc b/extensions/renderer/runtime_custom_bindings.cc index a7a5ff6cf4fd3b..6e10e104c1abcb 100644 --- a/extensions/renderer/runtime_custom_bindings.cc +++ b/extensions/renderer/runtime_custom_bindings.cc @@ -125,8 +125,8 @@ void RuntimeCustomBindings::GetExtensionViews( // all views for the current extension. int browser_window_id = args[0]->Int32Value(); - std::string view_type_string = *v8::String::Utf8Value(args[1]); - base::StringToUpperASCII(&view_type_string); + std::string view_type_string = + base::ToUpperASCII(*v8::String::Utf8Value(args[1])); // |view_type| == VIEW_TYPE_INVALID means getting any type of // views. ViewType view_type = VIEW_TYPE_INVALID; diff --git a/media/base/mime_util.cc b/media/base/mime_util.cc index 8878edd8e73ac5..00a2c744cc4bb0 100644 --- a/media/base/mime_util.cc +++ b/media/base/mime_util.cc @@ -533,7 +533,7 @@ static bool ParseH264CodecID(const std::string& codec_id, return false; } - std::string profile = base::StringToUpperASCII(codec_id.substr(5, 4)); + std::string profile = base::ToUpperASCII(codec_id.substr(5, 4)); if (IsValidH264BaselineProfile(profile)) { *codec = MimeUtil::H264_BASELINE; } else if (profile == "4D40") { @@ -546,8 +546,7 @@ static bool ParseH264CodecID(const std::string& codec_id, return true; } - *is_ambiguous = - !IsValidH264Level(base::StringToUpperASCII(codec_id.substr(9))); + *is_ambiguous = !IsValidH264Level(base::ToUpperASCII(codec_id.substr(9))); return true; } diff --git a/net/http/http_auth_handler_ntlm_portable.cc b/net/http/http_auth_handler_ntlm_portable.cc index 5e1d5faedc597e..54d4492a4bfd3d 100644 --- a/net/http/http_auth_handler_ntlm_portable.cc +++ b/net/http/http_auth_handler_ntlm_portable.cc @@ -261,7 +261,7 @@ static void LM_Hash(const base::string16& password, uint8* hash) { // Convert password to OEM character set. We'll just use the native // filesystem charset. std::string passbuf = base::SysWideToNativeMB(base::UTF16ToWide(password)); - base::StringToUpperASCII(&passbuf); + passbuf = base::ToUpperASCII(passbuf); passbuf.resize(14, '\0'); uint8 k1[8], k2[8]; diff --git a/net/http/http_util_unittest.cc b/net/http/http_util_unittest.cc index 6ea1ca479e7edb..a5c984db66b1f5 100644 --- a/net/http/http_util_unittest.cc +++ b/net/http/http_util_unittest.cc @@ -50,8 +50,7 @@ TEST(HttpUtilTest, IsSafeHeader) { for (size_t i = 0; i < arraysize(unsafe_headers); ++i) { EXPECT_FALSE(HttpUtil::IsSafeHeader(unsafe_headers[i])) << unsafe_headers[i]; - EXPECT_FALSE(HttpUtil::IsSafeHeader( - base::StringToUpperASCII(std::string(unsafe_headers[i])))) + EXPECT_FALSE(HttpUtil::IsSafeHeader(base::ToUpperASCII(unsafe_headers[i]))) << unsafe_headers[i]; } static const char* const safe_headers[] = { @@ -96,8 +95,7 @@ TEST(HttpUtilTest, IsSafeHeader) { }; for (size_t i = 0; i < arraysize(safe_headers); ++i) { EXPECT_TRUE(HttpUtil::IsSafeHeader(safe_headers[i])) << safe_headers[i]; - EXPECT_TRUE(HttpUtil::IsSafeHeader( - base::StringToUpperASCII(std::string(safe_headers[i])))) + EXPECT_TRUE(HttpUtil::IsSafeHeader(base::ToUpperASCII(safe_headers[i]))) << safe_headers[i]; } } diff --git a/storage/common/fileapi/file_system_util.cc b/storage/common/fileapi/file_system_util.cc index 98b6cc81a4be8f..16d74e44427dc5 100644 --- a/storage/common/fileapi/file_system_util.cc +++ b/storage/common/fileapi/file_system_util.cc @@ -420,8 +420,8 @@ bool CrackIsolatedFileSystemName(const std::string& filesystem_name, // names, so we do a case insensitive compare by converting both strings // to uppercase. // TODO(benwells): Remove this when WebKit uses the same constant. - start_token = base::StringToUpperASCII(start_token); - std::string filesystem_name_upper = base::StringToUpperASCII(filesystem_name); + start_token = base::ToUpperASCII(start_token); + std::string filesystem_name_upper = base::ToUpperASCII(filesystem_name); size_t pos = filesystem_name_upper.find(start_token); if (pos == std::string::npos) return false; diff --git a/ui/base/ime/chromeos/input_method_descriptor.cc b/ui/base/ime/chromeos/input_method_descriptor.cc index 19d6ccadbc0691..eda8aa6b9a66d6 100644 --- a/ui/base/ime/chromeos/input_method_descriptor.cc +++ b/ui/base/ime/chromeos/input_method_descriptor.cc @@ -45,11 +45,10 @@ std::string InputMethodDescriptor::GetIndicator() const { // keyboard layout or language code. if (indicator_.empty()) { if (extension_ime_util::IsKeyboardLayoutExtension(id_)) { - return base::StringToUpperASCII( - GetPreferredKeyboardLayout().substr(0, 2)); + return base::ToUpperASCII(GetPreferredKeyboardLayout().substr(0, 2)); } DCHECK(language_codes_.size() > 0); - return base::StringToUpperASCII(language_codes_[0].substr(0, 2)); + return base::ToUpperASCII(language_codes_[0].substr(0, 2)); } return indicator_; }