summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortfarina <tfarina@chromium.org>2015-12-06 05:25:41 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-06 13:26:40 +0000
commit023b1dcc012e341a147031d05756666c6b77d29a (patch)
tree504ede72afe8ef47450807e78da3756d6649e43f
parentcdcc4b87e40c1b783541444d9484f33e81a177ba (diff)
downloadchromium_src-023b1dcc012e341a147031d05756666c6b77d29a.zip
chromium_src-023b1dcc012e341a147031d05756666c6b77d29a.tar.gz
chromium_src-023b1dcc012e341a147031d05756666c6b77d29a.tar.bz2
base: get rid of deprecated TrimWhitespace() function
This patch updates the callers to call TrimWhitespaceASCII() when possible. BUG=None R=brettw@chromium.org Review URL: https://codereview.chromium.org/1493503002 Cr-Commit-Position: refs/heads/master@{#363369}
-rw-r--r--base/command_line.cc8
-rw-r--r--base/strings/string_util.cc8
-rw-r--r--base/strings/string_util.h6
-rw-r--r--base/strings/string_util_unittest.cc2
-rw-r--r--chrome/browser/chromeos/power/cpu_data_collector.cc12
-rw-r--r--chrome/browser/devtools/device/android_device_manager.cc2
-rw-r--r--chrome/browser/google/google_brand_chromeos.cc2
-rw-r--r--chrome/browser/net/firefox_proxy_settings.cc2
-rw-r--r--chrome/browser/ui/search_engines/edit_search_engine_controller.cc6
-rw-r--r--chrome/test/chromedriver/net/adb_client_socket.cc2
-rw-r--r--chrome/tools/convert_dict/hunspell_reader.cc2
-rw-r--r--chromeos/dbus/power_policy_controller.cc2
-rw-r--r--components/google/core/browser/google_url_tracker.cc2
-rw-r--r--components/plugins/renderer/plugin_placeholder.cc4
-rw-r--r--components/safe_browsing_db/prefix_set_unittest.cc2
-rw-r--r--content/child/npapi/plugin_host.cc4
-rw-r--r--content/renderer/npapi/webplugin_impl_unittest.cc2
-rw-r--r--net/base/filename_util_internal.cc5
-rw-r--r--net/test/python_utils_unittest.cc2
-rw-r--r--pdf/document_loader.cc6
-rw-r--r--ui/base/clipboard/clipboard_util_win.cc4
-rw-r--r--ui/gfx/font_fallback_win.cc4
22 files changed, 45 insertions, 44 deletions
diff --git a/base/command_line.cc b/base/command_line.cc
index c2ce33d..e2dde1c 100644
--- a/base/command_line.cc
+++ b/base/command_line.cc
@@ -75,7 +75,11 @@ void AppendSwitchesAndArguments(CommandLine* command_line,
bool parse_switches = true;
for (size_t i = 1; i < argv.size(); ++i) {
CommandLine::StringType arg = argv[i];
+#if defined(OS_WIN)
TrimWhitespace(arg, TRIM_ALL, &arg);
+#else
+ TrimWhitespaceASCII(arg, TRIM_ALL, &arg);
+#endif
CommandLine::StringType switch_string;
CommandLine::StringType switch_value;
@@ -263,7 +267,11 @@ FilePath CommandLine::GetProgram() const {
}
void CommandLine::SetProgram(const FilePath& program) {
+#if defined(OS_WIN)
TrimWhitespace(program.value(), TRIM_ALL, &argv_[0]);
+#else
+ TrimWhitespaceASCII(program.value(), TRIM_ALL, &argv_[0]);
+#endif
}
bool CommandLine::HasSwitch(const base::StringPiece& switch_string) const {
diff --git a/base/strings/string_util.cc b/base/strings/string_util.cc
index 731a77d..72b8500 100644
--- a/base/strings/string_util.cc
+++ b/base/strings/string_util.cc
@@ -403,14 +403,6 @@ StringPiece TrimWhitespaceASCII(StringPiece input, TrimPositions positions) {
return TrimStringPieceT(input, StringPiece(kWhitespaceASCII), positions);
}
-// This function is only for backward-compatibility.
-// To be removed when all callers are updated.
-TrimPositions TrimWhitespace(const std::string& input,
- TrimPositions positions,
- std::string* output) {
- return TrimWhitespaceASCII(input, positions, output);
-}
-
template<typename STR>
STR CollapseWhitespaceT(const STR& text,
bool trim_sequences_with_line_breaks) {
diff --git a/base/strings/string_util.h b/base/strings/string_util.h
index 3976111..af7b6e6 100644
--- a/base/strings/string_util.h
+++ b/base/strings/string_util.h
@@ -243,12 +243,6 @@ BASE_EXPORT TrimPositions TrimWhitespaceASCII(const std::string& input,
BASE_EXPORT StringPiece TrimWhitespaceASCII(StringPiece input,
TrimPositions positions);
-// Deprecated. This function is only for backward compatibility and calls
-// TrimWhitespaceASCII().
-BASE_EXPORT TrimPositions TrimWhitespace(const std::string& input,
- TrimPositions positions,
- std::string* output);
-
// Searches for CR or LF characters. Removes all contiguous whitespace
// strings that contain them. This is useful when trying to deal with text
// copied from terminals.
diff --git a/base/strings/string_util_unittest.cc b/base/strings/string_util_unittest.cc
index 765ba83..1db7746 100644
--- a/base/strings/string_util_unittest.cc
+++ b/base/strings/string_util_unittest.cc
@@ -250,7 +250,7 @@ TEST(StringUtilTest, TrimWhitespace) {
for (size_t i = 0; i < arraysize(trim_cases_ascii); ++i) {
const trim_case_ascii& value = trim_cases_ascii[i];
EXPECT_EQ(value.return_value,
- TrimWhitespace(value.input, value.positions, &output_ascii));
+ TrimWhitespaceASCII(value.input, value.positions, &output_ascii));
EXPECT_EQ(value.output, output_ascii);
}
}
diff --git a/chrome/browser/chromeos/power/cpu_data_collector.cc b/chrome/browser/chromeos/power/cpu_data_collector.cc
index 3166c60..21c65fa 100644
--- a/chrome/browser/chromeos/power/cpu_data_collector.cc
+++ b/chrome/browser/chromeos/power/cpu_data_collector.cc
@@ -94,7 +94,8 @@ bool CpuIsOnline(const int i) {
std::string cpu_online_string;
if (base::ReadFileToString(base::FilePath(cpu_online_file),
&cpu_online_string)) {
- base::TrimWhitespace(cpu_online_string, base::TRIM_ALL, &cpu_online_string);
+ base::TrimWhitespaceASCII(cpu_online_string, base::TRIM_ALL,
+ &cpu_online_string);
if (base::StringToInt(cpu_online_string, &online))
return online == kCpuOnlineStatus;
}
@@ -159,9 +160,9 @@ void SampleCpuIdleData(
return;
}
- base::TrimWhitespace(state_name, base::TRIM_ALL, &state_name);
- base::TrimWhitespace(
- occupancy_time_string, base::TRIM_ALL, &occupancy_time_string);
+ base::TrimWhitespaceASCII(state_name, base::TRIM_ALL, &state_name);
+ base::TrimWhitespaceASCII(occupancy_time_string, base::TRIM_ALL,
+ &occupancy_time_string);
if (base::StringToInt64(occupancy_time_string, &occupancy_time_usec)) {
// idle state occupancy time in sysfs is recorded in microseconds.
int64 time_in_state_ms = occupancy_time_usec / 1000;
@@ -324,7 +325,8 @@ void SampleCpuStateOnBlockingPool(
int max_cpu;
// The possible CPUs are listed in the format "0-N". Hence, N is present
// in the substring starting at offset 2.
- base::TrimWhitespace(possible_string, base::TRIM_ALL, &possible_string);
+ base::TrimWhitespaceASCII(possible_string, base::TRIM_ALL,
+ &possible_string);
if (possible_string.find("-") != std::string::npos &&
possible_string.length() > 2 &&
base::StringToInt(possible_string.substr(2), &max_cpu)) {
diff --git a/chrome/browser/devtools/device/android_device_manager.cc b/chrome/browser/devtools/device/android_device_manager.cc
index 3426726..e7c58b6 100644
--- a/chrome/browser/devtools/device/android_device_manager.cc
+++ b/chrome/browser/devtools/device/android_device_manager.cc
@@ -223,7 +223,7 @@ class HttpRequest {
std::string value = response_.substr(
start_pos + header.length(), endline_pos - start_pos - header.length());
- base::TrimWhitespace(value, base::TRIM_ALL, &value);
+ base::TrimWhitespaceASCII(value, base::TRIM_ALL, &value);
return value;
}
diff --git a/chrome/browser/google/google_brand_chromeos.cc b/chrome/browser/google/google_brand_chromeos.cc
index 8ccec25..ddde682 100644
--- a/chrome/browser/google/google_brand_chromeos.cc
+++ b/chrome/browser/google/google_brand_chromeos.cc
@@ -31,7 +31,7 @@ std::string ReadBrandFromFile() {
base::FilePath brand_file_path(kRLZBrandFilePath);
if (!base::ReadFileToString(brand_file_path, &brand))
LOG(WARNING) << "Brand code file missing: " << brand_file_path.value();
- base::TrimWhitespace(brand, base::TRIM_ALL, &brand);
+ base::TrimWhitespaceASCII(brand, base::TRIM_ALL, &brand);
return brand;
}
diff --git a/chrome/browser/net/firefox_proxy_settings.cc b/chrome/browser/net/firefox_proxy_settings.cc
index 203d9557..16b3618 100644
--- a/chrome/browser/net/firefox_proxy_settings.cc
+++ b/chrome/browser/net/firefox_proxy_settings.cc
@@ -102,7 +102,7 @@ bool ParsePrefFile(const base::FilePath& pref_file,
}
std::string value = line.substr(start_value + 1,
stop_value - start_value - 1);
- base::TrimWhitespace(value, base::TRIM_ALL, &value);
+ base::TrimWhitespaceASCII(value, base::TRIM_ALL, &value);
// Value could be a boolean.
bool is_value_true = base::LowerCaseEqualsASCII(value, "true");
if (is_value_true || base::LowerCaseEqualsASCII(value, "false")) {
diff --git a/chrome/browser/ui/search_engines/edit_search_engine_controller.cc b/chrome/browser/ui/search_engines/edit_search_engine_controller.cc
index b81e9cb..837c8ea 100644
--- a/chrome/browser/ui/search_engines/edit_search_engine_controller.cc
+++ b/chrome/browser/ui/search_engines/edit_search_engine_controller.cc
@@ -127,9 +127,9 @@ void EditSearchEngineController::CleanUpCancelledAdd() {
std::string EditSearchEngineController::GetFixedUpURL(
const std::string& url_input) const {
std::string url;
- base::TrimWhitespace(TemplateURLRef::DisplayURLToURLRef(
- base::UTF8ToUTF16(url_input)),
- base::TRIM_ALL, &url);
+ base::TrimWhitespaceASCII(
+ TemplateURLRef::DisplayURLToURLRef(base::UTF8ToUTF16(url_input)),
+ base::TRIM_ALL, &url);
if (url.empty())
return url;
diff --git a/chrome/test/chromedriver/net/adb_client_socket.cc b/chrome/test/chromedriver/net/adb_client_socket.cc
index 14a10ba..752dde2 100644
--- a/chrome/test/chromedriver/net/adb_client_socket.cc
+++ b/chrome/test/chromedriver/net/adb_client_socket.cc
@@ -185,7 +185,7 @@ class HttpOverAdbSocket {
if (endline_pos != std::string::npos) {
std::string len = response_.substr(content_pos + 15,
endline_pos - content_pos - 15);
- base::TrimWhitespace(len, base::TRIM_ALL, &len);
+ base::TrimWhitespaceASCII(len, base::TRIM_ALL, &len);
if (!base::StringToInt(len, &expected_length)) {
CheckNetResultOrDie(net::ERR_FAILED);
return;
diff --git a/chrome/tools/convert_dict/hunspell_reader.cc b/chrome/tools/convert_dict/hunspell_reader.cc
index 6555fb7..5232443 100644
--- a/chrome/tools/convert_dict/hunspell_reader.cc
+++ b/chrome/tools/convert_dict/hunspell_reader.cc
@@ -23,7 +23,7 @@ void TrimLine(std::string* line) {
// Treat this text as an ASCII text and trim whitespace characters as
// hunspell does. The returned text is to be converted into UTF-8 text with
// the encoding defined in an affix file.
- base::TrimWhitespace(*line, base::TRIM_ALL, line);
+ base::TrimWhitespaceASCII(*line, base::TRIM_ALL, line);
}
std::string ReadLine(FILE* file) {
diff --git a/chromeos/dbus/power_policy_controller.cc b/chromeos/dbus/power_policy_controller.cc
index 336b72e..49c76c2 100644
--- a/chromeos/dbus/power_policy_controller.cc
+++ b/chromeos/dbus/power_policy_controller.cc
@@ -152,7 +152,7 @@ std::string PowerPolicyController::GetPolicyDebugString(
}
if (policy.has_reason())
str += base::StringPrintf("reason=\"%s\" ", policy.reason().c_str());
- base::TrimWhitespace(str, base::TRIM_TRAILING, &str);
+ base::TrimWhitespaceASCII(str, base::TRIM_TRAILING, &str);
return str;
}
diff --git a/components/google/core/browser/google_url_tracker.cc b/components/google/core/browser/google_url_tracker.cc
index fa0d140..f503265 100644
--- a/components/google/core/browser/google_url_tracker.cc
+++ b/components/google/core/browser/google_url_tracker.cc
@@ -97,7 +97,7 @@ void GoogleURLTracker::OnURLFetchComplete(const net::URLFetcher* source) {
// See if the response data was valid. It should be ".google.<TLD>".
std::string url_str;
source->GetResponseAsString(&url_str);
- base::TrimWhitespace(url_str, base::TRIM_ALL, &url_str);
+ base::TrimWhitespaceASCII(url_str, base::TRIM_ALL, &url_str);
if (!base::StartsWith(url_str, ".google.",
base::CompareCase::INSENSITIVE_ASCII))
return;
diff --git a/components/plugins/renderer/plugin_placeholder.cc b/components/plugins/renderer/plugin_placeholder.cc
index bfb3ef15..96fb0bb 100644
--- a/components/plugins/renderer/plugin_placeholder.cc
+++ b/components/plugins/renderer/plugin_placeholder.cc
@@ -81,7 +81,7 @@ void PluginPlaceholderBase::HidePlugin() {
if (base::EndsWith(width_str, "px", base::CompareCase::INSENSITIVE_ASCII)) {
width_str = width_str.substr(0, width_str.length() - 2);
}
- base::TrimWhitespace(width_str, base::TRIM_TRAILING, &width_str);
+ base::TrimWhitespaceASCII(width_str, base::TRIM_TRAILING, &width_str);
width_str += "[\\s]*px";
std::string height_str("height:[\\s]*");
height_str += element.getAttribute("height").utf8().data();
@@ -89,7 +89,7 @@ void PluginPlaceholderBase::HidePlugin() {
base::CompareCase::INSENSITIVE_ASCII)) {
height_str = height_str.substr(0, height_str.length() - 2);
}
- base::TrimWhitespace(height_str, base::TRIM_TRAILING, &height_str);
+ base::TrimWhitespaceASCII(height_str, base::TRIM_TRAILING, &height_str);
height_str += "[\\s]*px";
blink::WebNode parent = element;
while (!parent.parentNode().isNull()) {
diff --git a/components/safe_browsing_db/prefix_set_unittest.cc b/components/safe_browsing_db/prefix_set_unittest.cc
index 181efc7..d1de0db 100644
--- a/components/safe_browsing_db/prefix_set_unittest.cc
+++ b/components/safe_browsing_db/prefix_set_unittest.cc
@@ -199,7 +199,7 @@ class PrefixSetTest : public PlatformTest {
while (fgets(buf, sizeof(buf), file.get())) {
std::string trimmed;
if (base::TRIM_TRAILING !=
- base::TrimWhitespace(buf, base::TRIM_ALL, &trimmed))
+ base::TrimWhitespaceASCII(buf, base::TRIM_ALL, &trimmed))
return false;
unsigned prefix;
if (!base::StringToUint(trimmed, &prefix))
diff --git a/content/child/npapi/plugin_host.cc b/content/child/npapi/plugin_host.cc
index 4f3006e..7f03896 100644
--- a/content/child/npapi/plugin_host.cc
+++ b/content/child/npapi/plugin_host.cc
@@ -259,7 +259,7 @@ bool PluginHost::SetPostData(const char* buf,
case GETNAME:
// Got a value.
value = std::string(start, ptr - start);
- base::TrimWhitespace(value, base::TRIM_ALL, &value);
+ base::TrimWhitespaceASCII(value, base::TRIM_ALL, &value);
// If the name field is empty, we'll skip this header
// but we won't error out.
if (!name.empty() && name != "content-length") {
@@ -271,7 +271,7 @@ bool PluginHost::SetPostData(const char* buf,
case GETVALUE:
// Got a header.
name = base::ToLowerASCII(base::StringPiece(start, ptr - start));
- base::TrimWhitespace(name, base::TRIM_ALL, &name);
+ base::TrimWhitespaceASCII(name, base::TRIM_ALL, &name);
start = ptr + 1;
break;
case GETDATA: {
diff --git a/content/renderer/npapi/webplugin_impl_unittest.cc b/content/renderer/npapi/webplugin_impl_unittest.cc
index 4576ea4..760c874 100644
--- a/content/renderer/npapi/webplugin_impl_unittest.cc
+++ b/content/renderer/npapi/webplugin_impl_unittest.cc
@@ -19,7 +19,7 @@ namespace {
std::string GetHeader(const WebURLRequest& request, const char* name) {
std::string result;
- base::TrimWhitespace(
+ base::TrimWhitespaceASCII(
request.httpHeaderField(WebString::fromUTF8(name)).utf8(),
base::TRIM_ALL,
&result);
diff --git a/net/base/filename_util_internal.cc b/net/base/filename_util_internal.cc
index 57183dc..4cfedcd 100644
--- a/net/base/filename_util_internal.cc
+++ b/net/base/filename_util_internal.cc
@@ -31,7 +31,12 @@ void SanitizeGeneratedFileName(base::FilePath::StringType* filename,
size_t length = filename->size();
size_t pos = filename->find_last_not_of(FILE_PATH_LITERAL(" ."));
filename->resize((pos == std::string::npos) ? 0 : (pos + 1));
+#if defined(OS_WIN)
base::TrimWhitespace(*filename, base::TRIM_TRAILING, filename);
+#else
+ base::TrimWhitespaceASCII(*filename, base::TRIM_TRAILING, filename);
+#endif
+
if (filename->empty())
return;
size_t trimmed = length - filename->size();
diff --git a/net/test/python_utils_unittest.cc b/net/test/python_utils_unittest.cc
index 57b7f47..a713e72 100644
--- a/net/test/python_utils_unittest.cc
+++ b/net/test/python_utils_unittest.cc
@@ -61,6 +61,6 @@ TEST(PythonUtils, MAYBE_PythonRunTime) {
cmd_line.AppendArg(python_cmd);
std::string output;
EXPECT_TRUE(base::GetAppOutput(cmd_line, &output));
- base::TrimWhitespace(output, base::TRIM_TRAILING, &output);
+ base::TrimWhitespaceASCII(output, base::TRIM_TRAILING, &output);
EXPECT_EQ(input, output);
}
diff --git a/pdf/document_loader.cc b/pdf/document_loader.cc
index 868a8c4..5bbed1a 100644
--- a/pdf/document_loader.cc
+++ b/pdf/document_loader.cc
@@ -36,8 +36,8 @@ bool GetByteRange(const std::string& headers, uint32_t* start, uint32_t* end) {
std::string range_end;
if (pos != std::string::npos)
range_end = range.substr(pos + 1);
- TrimWhitespaceASCII(range, base::TRIM_LEADING, &range);
- TrimWhitespaceASCII(range_end, base::TRIM_LEADING, &range_end);
+ base::TrimWhitespaceASCII(range, base::TRIM_LEADING, &range);
+ base::TrimWhitespaceASCII(range_end, base::TRIM_LEADING, &range_end);
*start = atoi(range.c_str());
*end = atoi(range_end.c_str());
return true;
@@ -145,7 +145,7 @@ bool DocumentLoader::Init(const pp::URLLoader& loader,
if (semi_colon_pos != std::string::npos) {
type = type.substr(0, semi_colon_pos);
}
- TrimWhitespace(type, base::TRIM_ALL, &type);
+ TrimWhitespaceASCII(type, base::TRIM_ALL, &type);
} else if (base::LowerCaseEqualsASCII(it.name(), "content-disposition")) {
disposition = it.values();
}
diff --git a/ui/base/clipboard/clipboard_util_win.cc b/ui/base/clipboard/clipboard_util_win.cc
index c0c05b0..ed5fe5f 100644
--- a/ui/base/clipboard/clipboard_util_win.cc
+++ b/ui/base/clipboard/clipboard_util_win.cc
@@ -446,7 +446,7 @@ void ClipboardUtil::CFHtmlToHtml(const std::string& cf_html,
fragment_start != std::string::npos &&
fragment_end != std::string::npos) {
*html = cf_html.substr(fragment_start, fragment_end - fragment_start);
- base::TrimWhitespace(*html, base::TRIM_ALL, html);
+ base::TrimWhitespaceASCII(*html, base::TRIM_ALL, html);
}
}
@@ -464,7 +464,7 @@ void ClipboardUtil::CFHtmlExtractMetadata(const std::string& cf_html,
size_t src_start = line_start + src_url_str.length();
if (src_end != std::string::npos && src_start != std::string::npos) {
*base_url = cf_html.substr(src_start, src_end - src_start);
- base::TrimWhitespace(*base_url, base::TRIM_ALL, base_url);
+ base::TrimWhitespaceASCII(*base_url, base::TRIM_ALL, base_url);
}
}
}
diff --git a/ui/gfx/font_fallback_win.cc b/ui/gfx/font_fallback_win.cc
index 1612f3c..c578ba8 100644
--- a/ui/gfx/font_fallback_win.cc
+++ b/ui/gfx/font_fallback_win.cc
@@ -206,8 +206,8 @@ void ParseFontFamilyString(const std::string& family,
const size_t index = font_names->back().find('(');
if (index != std::string::npos) {
font_names->back().resize(index);
- base::TrimWhitespace(font_names->back(), base::TRIM_TRAILING,
- &font_names->back());
+ base::TrimWhitespaceASCII(font_names->back(), base::TRIM_TRAILING,
+ &font_names->back());
}
}
}