Index: chrome/common/variations/experiment_labels.cc |
diff --git a/chrome/common/variations/experiment_labels.cc b/chrome/common/variations/experiment_labels.cc |
index ad230f569beb0af8bc8b20676ebae2bee3616174..8ed156beb0c8c05a57c7cc3529688e53156ece6e 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, |
sky
2015/07/01 03:18:27
I'm not familiar with this code. How come it's ok
brettw
2015/07/01 16:54:26
The separator is a semicolon.
|
+ 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()) |