summaryrefslogtreecommitdiffstats
path: root/chrome/common/variations
diff options
context:
space:
mode:
authorbrettw <brettw@chromium.org>2015-07-01 12:26:54 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-01 19:28:35 +0000
commit94a2cc2c77b73aaaceae5de709c6b453f8fe2c0e (patch)
tree9326be0be8d8cd7813115464194f0182670e8f3c /chrome/common/variations
parentd3cb15365f7cca8be2d794be25be88f6a72771a4 (diff)
downloadchromium_src-94a2cc2c77b73aaaceae5de709c6b453f8fe2c0e.zip
chromium_src-94a2cc2c77b73aaaceae5de709c6b453f8fe2c0e.tar.gz
chromium_src-94a2cc2c77b73aaaceae5de709c6b453f8fe2c0e.tar.bz2
Fix some case-insensitive cases for StartsWith.
This is not all callers so the old function is not deleted. Most calls are replaced with either StartsWith with the enum, or StartsWith(base::i18n::ToLower(...) for cases that need truely-internationalized case comparison (or when I wasn't sure). The most interesting case is chrome/installer/util which can't depend on base/i18n and it wants Unicode case-insensitive compares. I replaced these with a call to the Win32 function CompareString Add a missing protobuf dependency in components/storage_monitor that a try run turned up. In a few cases there is some related cleanup when I touched code: SplitString calls in experiment_labels.cc (which I've been doing patches to update), for loop in gcapi_omaha_experiment.cc, In some cases, a ToLower call was pulled out of a loop as in autofill_agent.cc. From this file I also removed a redundant comparison since the code checked it if was equal or a prefix, and a prefix returns true if it's equal. BUG=506255 Review URL: https://codereview.chromium.org/1220653002 Cr-Commit-Position: refs/heads/master@{#337093}
Diffstat (limited to 'chrome/common/variations')
-rw-r--r--chrome/common/variations/experiment_labels.cc30
1 files changed, 18 insertions, 12 deletions
diff --git a/chrome/common/variations/experiment_labels.cc b/chrome/common/variations/experiment_labels.cc
index ad230f5..8ed156b 100644
--- a/chrome/common/variations/experiment_labels.cc
+++ b/chrome/common/variations/experiment_labels.cc
@@ -71,22 +71,24 @@ base::string16 BuildGoogleUpdateExperimentLabel(
base::string16 ExtractNonVariationLabels(const base::string16& labels) {
// First, split everything by the label separator.
- std::vector<base::string16> entries;
- base::SplitString(labels, google_update::kExperimentLabelSeparator, &entries);
+ std::vector<base::StringPiece16> entries = base::SplitStringPiece(
+ labels, base::StringPiece16(&google_update::kExperimentLabelSeparator, 1),
+ base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
// For each label, keep the ones that do not look like a Variations label.
base::string16 non_variation_labels;
- for (std::vector<base::string16>::const_iterator it = entries.begin();
- it != entries.end(); ++it) {
- if (it->empty() ||
- base::StartsWith(*it, base::ASCIIToUTF16(kVariationPrefix), false)) {
+ for (const base::StringPiece16& entry : entries) {
+ if (entry.empty() ||
+ base::StartsWith(entry,
+ base::ASCIIToUTF16(kVariationPrefix),
+ base::CompareCase::INSENSITIVE_ASCII)) {
continue;
}
// Dump the whole thing, including the timestamp.
if (!non_variation_labels.empty())
non_variation_labels += google_update::kExperimentLabelSeparator;
- non_variation_labels += *it;
+ entry.AppendToString(&non_variation_labels);
}
return non_variation_labels;
@@ -94,11 +96,15 @@ base::string16 ExtractNonVariationLabels(const base::string16& labels) {
base::string16 CombineExperimentLabels(const base::string16& variation_labels,
const base::string16& other_labels) {
- const base::string16 separator(1, google_update::kExperimentLabelSeparator);
- DCHECK(!base::StartsWith(variation_labels, separator, false));
- DCHECK(!base::EndsWith(variation_labels, separator, false));
- DCHECK(!base::StartsWith(other_labels, separator, false));
- DCHECK(!base::EndsWith(other_labels, separator, false));
+ base::StringPiece16 separator(&google_update::kExperimentLabelSeparator, 1);
+ DCHECK(!base::StartsWith(variation_labels, separator,
+ base::CompareCase::SENSITIVE));
+ DCHECK(!base::EndsWith(variation_labels, separator,
+ base::CompareCase::SENSITIVE));
+ DCHECK(!base::StartsWith(other_labels, separator,
+ base::CompareCase::SENSITIVE));
+ DCHECK(!base::EndsWith(other_labels, separator,
+ base::CompareCase::SENSITIVE));
// Note that if either label is empty, a separator is not necessary.
base::string16 combined_labels = other_labels;
if (!other_labels.empty() && !variation_labels.empty())