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

Unified Diff: chrome/common/variations/experiment_labels.cc

Issue 1220653002: Fix some case-insensitive cases for StartsWith (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: grt's review comments, Mac fix Created 5 years, 6 months 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 | « chrome/browser/enumerate_modules_model_win.cc ('k') | chrome/installer/gcapi/gcapi_omaha_experiment.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
+ 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())
« no previous file with comments | « chrome/browser/enumerate_modules_model_win.cc ('k') | chrome/installer/gcapi/gcapi_omaha_experiment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698