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

Unified Diff: chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc

Issue 889463003: GURL::Replacements methods accept a StringPiece instead of std::string&. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase (fixed some merge conflicts). Created 5 years, 10 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/ssl/ssl_browser_tests.cc ('k') | chrome/browser/task_manager/task_manager_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc
diff --git a/chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc b/chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc
index b9180d8ff6e0c28b7b70cb5a83e40dc82baae403..8475088de7d0e786a149b227dae21ea638c39dd5 100644
--- a/chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc
+++ b/chrome/browser/supervised_user/experimental/supervised_user_async_url_checker.cc
@@ -10,6 +10,7 @@
#include "base/json/json_reader.h"
#include "base/metrics/histogram.h"
#include "base/stl_util.h"
+#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
@@ -45,21 +46,16 @@ const size_t kDefaultCacheSize = 1000;
GURL GetNormalizedURL(const GURL& url) {
GURL::Replacements replacements;
// Set scheme to http.
- const std::string scheme(url::kHttpScheme);
- replacements.SetSchemeStr(scheme);
+ replacements.SetSchemeStr(url::kHttpScheme);
// Strip leading "www." (if any).
const std::string www("www.");
- std::string new_host;
- if (StartsWithASCII(url.host(), www, true)) {
- new_host = url.host().substr(www.size());
- replacements.SetHostStr(new_host);
- }
+ const std::string host(url.host());
+ if (StartsWithASCII(host, www, true))
+ replacements.SetHostStr(base::StringPiece(host).substr(www.size()));
// Strip trailing slash (if any).
- std::string new_path;
- if (EndsWith(url.path(), "/", true)) {
- new_path = url.path().substr(0, url.path().size() - 1);
- replacements.SetPathStr(new_path);
- }
+ const std::string path(url.path());
+ if (EndsWith(path, "/", true))
+ replacements.SetPathStr(base::StringPiece(path).substr(0, path.size() - 1));
return url.ReplaceComponents(replacements);
}
« no previous file with comments | « chrome/browser/ssl/ssl_browser_tests.cc ('k') | chrome/browser/task_manager/task_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698