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

Unified Diff: chrome/browser/net/safe_search_util.cc

Issue 2695883003: Change uses of base::JoinString to pass StringPieces where possible. (Closed)
Patch Set: Fix android_webview compilation (and made FeatureList::SplitFeatureListString take StringPiece). Created 3 years, 9 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
Index: chrome/browser/net/safe_search_util.cc
diff --git a/chrome/browser/net/safe_search_util.cc b/chrome/browser/net/safe_search_util.cc
index cc1f6ded87a0c8f23fcc05bdcfb8298fe889a988..0468dd994f62798c577e840a2712d514f1ed447f 100644
--- a/chrome/browser/net/safe_search_util.cc
+++ b/chrome/browser/net/safe_search_util.cc
@@ -33,12 +33,12 @@ const char kYouTubeRestrictHeaderValueStrict[] = "Strict";
// Returns whether a URL parameter, |first_parameter| (e.g. foo=bar), has the
// same key as the the |second_parameter| (e.g. foo=baz). Both parameters
// must be in key=value form.
-bool HasSameParameterKey(const std::string& first_parameter,
- const std::string& second_parameter) {
+bool HasSameParameterKey(base::StringPiece first_parameter,
+ base::StringPiece second_parameter) {
DCHECK(second_parameter.find("=") != std::string::npos);
// Prefix for "foo=bar" is "foo=".
- std::string parameter_prefix = second_parameter.substr(
- 0, second_parameter.find("=") + 1);
+ base::StringPiece parameter_prefix =
+ second_parameter.substr(0, second_parameter.find("=") + 1);
return base::StartsWith(first_parameter, parameter_prefix,
base::CompareCase::INSENSITIVE_ASCII);
}
@@ -47,12 +47,12 @@ bool HasSameParameterKey(const std::string& first_parameter,
// so that SafeSearch is active. |query| is the string to examine and the
// return value is the |query| string modified such that SafeSearch is active.
std::string AddSafeSearchParameters(const std::string& query) {
- std::vector<std::string> new_parameters;
+ std::vector<base::StringPiece> new_parameters;
std::string safe_parameter = chrome::kSafeSearchSafeParameter;
std::string ssui_parameter = chrome::kSafeSearchSsuiParameter;
- for (const std::string& param : base::SplitString(
- query, "&", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
+ for (auto param : base::SplitStringPiece(query, "&", base::TRIM_WHITESPACE,
Nico 2017/03/15 13:52:11 const auto& (imho, s/auto/base::StringPiece/ is e
Matt Giuca 2017/03/17 00:16:27 See discussion on https://codereview.chromium.org/
Matt Giuca 2017/03/27 03:24:58 Done.
+ base::SPLIT_WANT_ALL)) {
if (!HasSameParameterKey(param, safe_parameter) &&
!HasSameParameterKey(param, ssui_parameter)) {
new_parameters.push_back(param);

Powered by Google App Engine
This is Rietveld 408576698